/* FR.ts (js/game/tinyswords.js): Tiny Swords pixel art by Pixel Frog. */
/* sized like FR.fx sprites (.fx-sp, --fx-sz). A unit stays inside its square (a spear or a swing never spills over
   the card or the text next to it), except in the battle arena where its attacks may reach out. */
.ts-svg {
  overflow: visible;
}
.ts-svg.ts-unit {
  overflow: hidden;
}
.bt-arena .ts-svg.ts-unit {
  overflow: visible;
}
.ts-svg image,
.ts-img {
  image-rendering: pixelated;
}
/* a strip of --n frames, each --fw wide, stepped right to left */
.ts-anim {
  animation-name: ts-step;
  animation-timing-function: steps(var(--n));
  animation-iteration-count: infinite;
}
@keyframes ts-step {
  to {
    transform: translateX(calc(var(--n) * var(--fw) * -1));
  }
}
body.ts-still .ts-anim {
  animation: none;
}

/* Tiny Swords portraits as trainer avatars (meta.js .mt-av-pix, onboarding picker) */
.mt-av-pix .mt-av-img,
.wd-avpick-img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  image-rendering: pixelated;
}
.wd-avpick-img {
  width: 2.2em;
  height: 2.2em;
}

/* battle scenery on the Tiny Swords meadow (battle.js sceneHtml): behind the fighters, never clickable */
.ts-scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.ts-scene .ts-at {
  position: absolute;
  display: block;
}
.ts-scene .ts-at > * {
  display: block;
}
.ts-scene ~ .bt-foe,
.ts-scene ~ .bt-me {
  position: relative;
  z-index: 1;
}

/* the world map on the Tiny Swords island (world.js mapSvgTs) */
.wd-map-ts image {
  image-rendering: pixelated;
}
.wd-fog-ts {
  opacity: 0.95;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.15));
}
/* roads as dirt paths with a dark outline, like the pack's ground; a locked one stays faint */
.wd-map-ts .wd-road {
  stroke: rgba(92, 64, 40, 0.35);
  stroke-width: 6;
}
.wd-map-ts .wd-road.on {
  stroke: #c79a5f;
  filter: drop-shadow(0 0 0.6px #3b2a1c) drop-shadow(0 0 0.6px #3b2a1c);
}
.wd-map-ts .wd-road-dash.on {
  stroke: #e9cf9a;
}

/* ================================================================ « Royaume » colour theme (Tiny Swords UI)
   A light parchment theme (the 8 tokens, like the shop themes in game-meta.css), plus the pack's UI pieces:
   the sea around one parchment sheet, ink-outlined panels, blue buttons, ribbon titles, a wood frame for the map.
   Registered as a free shop theme by meta.js. Slices: tools/tinyswords.py (img/ts/ui). */
:root[data-theme="royaume"] {
  color-scheme: light;
}
[data-theme="royaume"] {
  --bg: #f2e8cb;
  --main: #1b6682;
  --caret: #c98a12;
  --sub: #8a7a5a;
  --sub-alt: #e6d7ae;
  --text: #2a2338;
  --error: #b3261e;
  --error-extra: #e2938a;
  --ts-ink: #2c2a3d;
}
[data-theme="royaume"] body {
  background: #47aba9 url(../img/ts/terrain/water.png) 0 0 / 64px 64px;
}
/* « Royaume de nuit »: the same Tiny Swords pieces in the dark. Never sold nor equipped: js/core/theme.js shows it
   instead of a light theme when the learner wants dark mode (prefs scheme « dark », or « auto » with the phone in
   dark mode). The rules match both royaume themes ([data-theme^="royaume"]); only the tokens (the sheet's inner line
   and drop shadow are tokens too) and the sea change. */
:root[data-theme="royaume-nuit"] {
  color-scheme: dark;
}
[data-theme="royaume-nuit"] {
  --bg: #1c2030;
  --main: #6cc0dc;
  --caret: #e2a93b;
  --sub: #6d7290;
  --sub-alt: #272c40;
  --text: #efe6cc;
  --error: #ef6b62;
  --error-extra: #8a3b36;
  --ts-ink: #07080d;
  --ts-sheet-line: #2c3249;
  --ts-sheet-drop: rgba(0, 0, 0, 0.45);
}
[data-theme="royaume-nuit"] body {
  background: linear-gradient(rgba(5, 12, 20, 0.8), rgba(5, 12, 20, 0.8)), #0f2a33 url(../img/ts/terrain/water.png) 0 0 / 64px 64px;
}
/* the sheet: parchment with the pack's ink outline and a drop shadow on the water (the paper 9-slice's edges
   streak when stretched this tall) */
[data-theme^="royaume"] #app {
  margin: 1rem auto;
  background: var(--bg);
  border: 3px solid var(--ts-ink);
  border-radius: 10px;
  box-shadow: inset 0 0 0 4px var(--ts-sheet-line, #e3d4a8), 0 6px 0 var(--ts-sheet-drop, rgba(28, 60, 66, 0.35));
}
/* panels: a darker parchment with the pack's ink outline */
[data-theme^="royaume"] .g-card {
  background: var(--sub-alt);
  border: 2px solid var(--ts-ink);
  border-radius: 6px;
  box-shadow: inset 0 -3px 0 rgba(90, 64, 30, 0.18), 0 2px 0 rgba(44, 42, 61, 0.25);
}
/* list items and unchosen chips: the same ink outline as the panels */
[data-theme^="royaume"] .g-item,
[data-theme^="royaume"] .g-chip:not(.on) {
  border: 2px solid var(--ts-ink);
}
/* buttons: secondary = parchment with ink outline; primary = the blue Tiny Swords button (pressed while active) */
[data-theme^="royaume"] .g-btn:not(.ghost):not(.primary) {
  border: 2px solid var(--ts-ink);
  border-radius: 6px;
  box-shadow: inset 0 -2px 0 rgba(90, 64, 30, 0.2);
}
[data-theme^="royaume"] .g-btn.primary {
  background: none;
  color: #fff;
  text-shadow: 0 1px 0 var(--ts-ink), 0 -1px 0 var(--ts-ink), 1px 0 0 var(--ts-ink), -1px 0 0 var(--ts-ink);
  border: 12px solid transparent;
  border-image: url(../img/ts/ui/btn-blue.png) 47 45 47 45 fill / 12px stretch;
  border-radius: 0;
  padding: 0.15rem 0.6rem 0.35rem;
  image-rendering: pixelated;
}
[data-theme^="royaume"] .g-btn.primary:active {
  border-image-source: url(../img/ts/ui/btn-blue-pressed.png);
  border-image-slice: 36 50 49 50 fill;
  transform: translateY(1px);
}
[data-theme^="royaume"] .g-btn.primary:hover {
  filter: brightness(1.08);
}
/* the start button (.g-cta): white on the blue button art is 3.6:1, so the theme's own --main with --bg text
   (≥ 5.5:1), the pack's ink outline and a pixel drop shadow; it also sets it apart from the other blue buttons */
[data-theme^="royaume"] .g-btn.g-cta {
  --g-cta-drop: 0 4px 0 var(--ts-ink);
  background: var(--main);
  color: var(--bg);
  text-shadow: none;
  border: 3px solid var(--ts-ink);
  border-image: none;
  border-radius: 8px;
  padding: 0.95rem 2rem;
  image-rendering: auto;
}
[data-theme^="royaume"] .g-btn.g-cta:active {
  border-image: none;
}
/* titles on a ribbon: the caps keep their proportions (98 × 103 source px) at the title's height */
[data-theme^="royaume"] .wd-sec-head > .g-h,
[data-theme^="royaume"] .g-top > .g-h {
  --ts-rh: 2.6rem;
  display: inline-block;
  line-height: calc(var(--ts-rh) - 0.35rem);
  min-height: var(--ts-rh);
  margin: 0;
  padding: 0 0.4rem 0.35rem;
  white-space: nowrap;
  border-style: solid;
  border-color: transparent;
  border-width: 0 calc(var(--ts-rh) * 0.95);
  border-image: url(../img/ts/ui/ribbon-blue.png) 0 97 0 98 fill / 0 calc(var(--ts-rh) * 0.95) stretch;
  image-rendering: pixelated;
  color: #fff;
  text-shadow: 0 1px 0 var(--ts-ink), 0 -1px 0 var(--ts-ink), 1px 0 0 var(--ts-ink), -1px 0 0 var(--ts-ink);
  font-size: 1.05rem;
}
[data-theme^="royaume"] .wd-sec-head > .g-h .g-en,
[data-theme^="royaume"] .g-top > .g-h .g-en {
  color: #e8f4f4;
}
/* the map in the wood table frame */
[data-theme^="royaume"] .wd-map {
  border: 14px solid transparent;
  border-image: url(../img/ts/ui/wood.png) 85 84 103 84 / 14px 14px 17px stretch;
  border-radius: 0;
  box-shadow: none;
  image-rendering: pixelated;
}

/* a portrait avatar (generated art, meta.js) as the trainer in battle */
.bt-me-sprite .bt-av-img {
  display: block;
  width: 6.5rem;
  height: 6.5rem;
  object-fit: contain;
  object-position: bottom;
}

/* an emoji turned into a Tiny Swords icon (tinyswords.js iconize): one line high, sits on the text baseline */
.ts-ico {
  display: inline-block;
  height: 1.2em;
  width: auto;
  max-width: 2.4em;
  vertical-align: -0.22em;
  object-fit: contain;
  image-rendering: pixelated;
}

/* a ribbon title on a phone: it may wrap (the ribbon stretches with it) rather than run off the page */
@media (max-width: 640px) {
  [data-theme^="royaume"] .wd-sec-head > .g-h,
  [data-theme^="royaume"] .g-top > .g-h {
    --ts-rh: 2.3rem;
    white-space: normal;
    max-width: 100%;
    line-height: 1.25;
    padding-top: 0.35rem;
    padding-bottom: 0.55rem;
    font-size: 0.98rem;
  }
}

/* the header dock, its menus and the HUD buttons in the pack's ink outline */
[data-theme^="royaume"] .nav-dock,
[data-theme^="royaume"] .nav-menu {
  border: 2px solid var(--ts-ink);
  box-shadow: inset 0 -3px 0 rgba(90, 64, 30, 0.18), 0 3px 0 rgba(44, 42, 61, 0.25);
}
[data-theme^="royaume"] .nav-hud,
[data-theme^="royaume"] #xp-chip {
  border: 2px solid var(--ts-ink);
  box-shadow: inset 0 -2px 0 rgba(90, 64, 30, 0.2);
}
[data-theme^="royaume"] .nav-tab.active,
[data-theme^="royaume"] .nav-group:has(.nav-item.active) > .nav-grp-btn {
  box-shadow: 0 0 0 2px var(--ts-ink), 0 3px 0 2px var(--ts-ink);
}

/* phones: the bottom tab bar and its sheet keep only their top edge; the current tab is marked by its icon pill */
@media (max-width: 700px) {
  [data-theme^="royaume"] .nav-dock,
  [data-theme^="royaume"] .nav-menu {
    border-width: 2px 0 0;
    box-shadow: 0 -2px 0 rgba(44, 42, 61, 0.15);
  }
  [data-theme^="royaume"] .nav-tab.active,
  [data-theme^="royaume"] .nav-group:has(.nav-item.active) > .nav-grp-btn {
    box-shadow: none;
  }
  /* edge to edge on a phone: the sheet's frame and the sea would only eat the screen */
  [data-theme^="royaume"] #app {
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
