/*
 * B&B interface kit, shared by the game (phone), the Studio and the editor (Windows).
 * Idea: aizome, indigo-dyed cloth, with sashiko, the white running stitch sewn through it. Surfaces are indigo; whatever can be moved, switched or selected is
 * drawn as thread: sliders are a row of stitches that fills as you pull, the open tab is underlined with stitches, dividers are stitched, and the seal (the one
 * vermilion mark) is the brand. Nothing here uses blur or large shadows: the page sits over a WebGL scene on a phone GPU.
 *
 * Type: Shippori Mincho for titles and the numbers that matter (the date, the clock), Zen Kaku Gothic New for everything you tap. Both SIL OFL 1.1, bundled
 * (Latin subset), so the app needs no network. Colour names are the traditional dye names.
 */
@font-face { font-family: "Zen Kaku Gothic New"; font-weight: 400; font-display: swap; src: url(./fonts/zen-kaku-gothic-new-400.woff2) format("woff2"); }
@font-face { font-family: "Zen Kaku Gothic New"; font-weight: 500; font-display: swap; src: url(./fonts/zen-kaku-gothic-new-500.woff2) format("woff2"); }
@font-face { font-family: "Zen Kaku Gothic New"; font-weight: 700; font-display: swap; src: url(./fonts/zen-kaku-gothic-new-700.woff2) format("woff2"); }
@font-face { font-family: "Shippori Mincho"; font-weight: 600; font-display: swap; src: url(./fonts/shippori-mincho-600.woff2) format("woff2"); }
@font-face { font-family: "Shippori Mincho"; font-weight: 800; font-display: swap; src: url(./fonts/shippori-mincho-800.woff2) format("woff2"); }

:root {
  color-scheme: dark;
  /* dye names: kon (deep indigo), ai (indigo), hana (raised indigo), thread (sashiko white), asagi (shallow blue-green), shu (seal vermilion), yamabuki (kerria gold), moegi (young-leaf green) */
  --kon: #121a2e;
  --ai: #1a2540;
  --hana: #263558;
  --line: #34446d;
  --thread: #e3e7ea;
  --thread-dim: #9aa8c6;
  --thread-faint: #5d6c92;
  --asagi: #3dbdb3;
  --asagi-deep: #1f6f6c;
  --shu: #d4503a;
  --yamabuki: #e2b240;
  --moegi: #9cc45c;
  --sheet: rgba(18, 26, 46, 0.93);
  --font-ui: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --font-title: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --r-sm: 6px;
  --r-md: 10px;
  --stitch: repeating-linear-gradient(90deg, var(--thread-faint) 0 5px, transparent 5px 9px);
}

body, button, input, select, textarea { font-family: var(--font-ui); }
button, input, select, textarea { font-size: 14px; font-weight: 500; }
.title { font-family: var(--font-title); font-weight: 600; letter-spacing: 0.01em; }
.num { font-variant-numeric: tabular-nums; }

/* buttons: quiet by default, the thread colour says "this one is on" */
.btn, button.btn {
  min-height: 40px; padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--ai); color: var(--thread);
  cursor: pointer; text-align: left; touch-action: manipulation;
}
.btn:hover { border-color: var(--thread-faint); background: var(--hana); }
.btn[aria-pressed="true"] { border-color: var(--asagi); background: var(--hana); box-shadow: inset 3px 0 0 var(--asagi); }
.btn.primary { background: var(--asagi-deep); border-color: var(--asagi); color: #f4fbfa; font-weight: 700; }
.btn.primary:hover { background: #26867f; }
.btn.danger { border-color: var(--shu); color: #ffb9ae; }
.btn:disabled, .toggle:disabled { opacity: 0.45; cursor: default; }
:where(button, a, input, select, summary):focus-visible { outline: 2px solid var(--asagi); outline-offset: 2px; }

/* a row of choices, one picked (presets, camera modes, speeds) */
.choices { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--ai); }
.choices > button { min-height: 38px; padding: 6px 4px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--thread-dim); cursor: pointer; text-align: center; }
.choices > button:first-child { border-left: 0; }
.choices > button[aria-pressed="true"] { background: var(--hana); color: var(--thread); box-shadow: inset 0 -3px 0 var(--asagi); }
.choices.stack { grid-auto-flow: row; }
.choices.stack > button { border-left: 0; border-top: 1px solid var(--line); text-align: left; padding: 8px 12px; }
.choices.stack > button:first-child { border-top: 0; }
.choices.stack > button[aria-pressed="true"] { box-shadow: inset 3px 0 0 var(--asagi); }

/* a switch with its meaning written under it */
.toggle {
  position: relative; display: block; width: 100%; padding: 9px 56px 9px 12px; min-height: 48px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--ai);
  color: var(--thread); text-align: left; cursor: pointer; touch-action: manipulation;
}
.toggle small { display: block; margin-top: 1px; font-size: 12px; font-weight: 400; line-height: 1.35; color: var(--thread-dim); }
.toggle::before { content: ""; position: absolute; right: 12px; top: 50%; width: 34px; height: 20px; margin-top: -10px; border-radius: 10px; background: var(--kon); border: 1px solid var(--line); }
.toggle::after { content: ""; position: absolute; right: 31px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--thread-faint); transition: transform 0.14s ease, background 0.14s ease; }
.toggle[aria-pressed="true"]::before { background: var(--asagi-deep); border-color: var(--asagi); }
.toggle[aria-pressed="true"]::after { background: var(--thread); transform: translateX(14px); }

/* tabs: the open one is underlined with stitches */
.tabs { display: flex; flex: none; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > :is(button, a) {
  position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; border: 0; background: transparent; color: var(--thread-dim); cursor: pointer; text-decoration: none; line-height: 1.2; text-align: center;
}
.tabs > :is(button, a):hover { color: var(--thread); }
.tabs > [aria-pressed="true"], .tabs > [aria-selected="true"] { color: var(--thread); font-weight: 700; }
.tabs > [aria-pressed="true"]::after, .tabs > [aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 4px; height: 2px; background: repeating-linear-gradient(90deg, var(--asagi) 0 6px, transparent 6px 10px);
}

/* sliders: stitches that fill as you pull. --f (0..1) is set by the page from the value (ui/ranges.ts); without it the whole row shows as unfilled. */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; min-height: 30px; margin: 0; background: transparent; --f: 0; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--asagi) 0 6px, transparent 6px 10px) 0 0 / calc(10px + (100% - 20px) * var(--f)) 100% no-repeat, repeating-linear-gradient(90deg, var(--thread-faint) 0 6px, transparent 6px 10px);
}
input[type="range"]::-moz-range-track { height: 4px; background: repeating-linear-gradient(90deg, var(--thread-faint) 0 6px, transparent 6px 10px); }
input[type="range"]::-moz-range-progress { height: 4px; background: repeating-linear-gradient(90deg, var(--asagi) 0 6px, transparent 6px 10px); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 5px; background: var(--thread); border: 2px solid var(--kon); box-shadow: 0 0 0 1px var(--asagi); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 5px; background: var(--thread); border: 2px solid var(--kon); box-shadow: 0 0 0 1px var(--asagi); }
input[type="range"]:disabled { opacity: 0.4; }
.field { display: grid; gap: 0; }
.field > span { display: flex; justify-content: space-between; align-items: baseline; color: var(--thread); }
.field > span output { color: var(--asagi); font-variant-numeric: tabular-nums; font-weight: 700; }
.field > small { color: var(--thread-dim); font-size: 12px; line-height: 1.35; }

/* stitched divider, and the seal */
.stitched { border: 0; height: 2px; margin: 6px 0; background: var(--stitch); background-size: auto 2px; }
.seal {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 5px; background: var(--shu); color: #fff2ee;
  font: 800 15px/1 var(--font-title); transform: rotate(-4deg); box-shadow: inset 0 0 0 1.5px rgba(255, 242, 238, 0.55);
}

/* a ledger line: a name and its value, ruled by a stitch */
.ledger { margin: 0; padding: 0; list-style: none; }
.ledger > li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0 8px; background: var(--stitch) 0 100% / 100% 1px no-repeat; }
.ledger > li span:last-child { color: var(--thread); font-variant-numeric: tabular-nums; text-align: right; }
.ledger > li span:first-child { color: var(--thread-dim); }

@media (prefers-reduced-motion: reduce) { .toggle::after { transition: none; } }
