/* blank — flat matte, mono type, product plates (light grey in light mode, dark grey in dark mode). */

@font-face { font-family: 'Space Mono'; src: url(../fonts/space-mono-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url(../fonts/space-mono-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --mono: 'Space Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r: 10px;      /* plates */
  --rs: 6px;      /* controls */
  --gutter: clamp(16px, 4vw, 40px);
  --max: 1240px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.2, .7, .1, 1);
}
/* --plate must match the colour baked into the images (build_pilot.py VARIANTS) */
[data-theme='dark']  { --bg: #1a1a1c; --plate: #545454; --plate-ink: rgba(255,255,255,.34); --ink: #e6e6e3; --mute: #85858a; --faint: #4c4c51; --line: rgba(255,255,255,.12); --chip: rgba(255,255,255,.07); --chip2: rgba(255,255,255,.13); --pop: #242427; }
[data-theme='light'] { --bg: #e9ebee; --plate: #d9d9d9; --plate-ink: rgba(0,0,0,.38);       --ink: #141416; --mute: #66666b; --faint: #a7a7aa; --line: rgba(0,0,0,.14);       --chip: rgba(0,0,0,.06);       --chip2: rgba(0,0,0,.11);       --pop: #f1f2f4; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 13px/1.6 var(--mono); min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
html.fade *, html.fade *::before { transition: background-color .3s, color .3s !important; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; background: none; border: 0; border-radius: 0; }
button { cursor: pointer; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px dashed var(--ink); outline-offset: 3px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; height: 66px; padding: 0 var(--gutter); max-width: var(--max); margin: 0 auto; }
.mark { display: inline-flex; align-items: center; font-weight: 700; font-size: 20px; letter-spacing: -.03em; }
.cur { display: inline-block; width: 2px; height: 1em; margin-left: 4px; background: var(--ink); }
.tools { display: flex; align-items: center; gap: 6px; }

.region { position: relative; }
#region-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 11px; border-radius: var(--rs); background: var(--chip); color: var(--mute); transition: color .2s, background .2s; }
#region-btn:hover, #region-btn[aria-expanded='true'] { color: var(--ink); background: var(--chip2); }
.chev { transition: transform .25s var(--ease); } #region-btn[aria-expanded='true'] .chev { transform: rotate(180deg); }
.flag { display: inline-block; flex: none; width: 24px; height: 16px; border-radius: 3px; overflow: hidden; }
.flag svg { display: block; width: 100%; height: 100%; }
[data-theme='dark'] .flag svg { filter: saturate(.75) brightness(.86); } /* softer on dark */
#region-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 216px; list-style: none; padding: 5px; background: var(--pop); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 14px 40px rgba(0,0,0,.3); transform-origin: top right; animation: pop .22s var(--spring); }
#region-menu[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(-4px); } }
#region-menu li { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 5px; cursor: pointer; }
#region-menu li:hover, #region-menu li:focus-visible { background: var(--chip); outline: none; }
#region-menu li[aria-selected='true'] { background: var(--chip); font-weight: 700; }
#region-menu li small { margin-left: auto; color: var(--mute); font-size: 12px; }

/* light / dark: one icon that morphs between moon and sun */
.theme { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--rs); color: var(--mute); transition: color .2s, background .2s; }
.theme:hover { color: var(--ink); background: var(--chip); }
.theme svg { overflow: visible; }
.theme .moon, .theme .sun { transform-box: fill-box; transform-origin: center; transition: transform .6s var(--spring), opacity .3s; }
[data-theme='dark'] .theme .sun { opacity: 0; transform: rotate(-90deg) scale(.3); }
[data-theme='light'] .theme .moon { opacity: 0; transform: rotate(90deg) scale(.3); }

/* search + filter */
main { max-width: var(--max); margin: 0 auto; }
.filters { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: flex-start; gap: 8px; padding: 12px var(--gutter); background: var(--bg); border-bottom: 1px dashed var(--line); }
.search { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 360px; height: 36px; padding: 0 12px; border-radius: var(--rs); background: var(--chip); color: var(--mute); transition: background .2s, color .2s; }
.search:focus-within { background: var(--chip2); color: var(--ink); }
#q { flex: 1; min-width: 0; height: 100%; outline: none; color: var(--ink); }
#q::placeholder { color: var(--faint); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }
.filter { position: relative; flex: none; }
#filter-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 13px; border-radius: var(--rs); background: var(--chip); color: var(--mute); transition: color .2s, background .2s; }
#filter-btn:hover, #filter-btn[aria-expanded='true'] { color: var(--ink); background: var(--chip2); }
#filter-btn b[hidden] { display: none; }
#filter-btn b { display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--ink); color: var(--bg); font-size: 10px; font-weight: 700; }
#filter-panel { position: absolute; left: 0; top: calc(100% + 8px); z-index: 40; width: min(400px, calc(100vw - 2 * var(--gutter))); padding: 18px; background: var(--pop); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.3); transform-origin: top left; animation: pop .22s var(--spring); }
#filter-panel[hidden] { display: none; }
@media (max-width: 719px) { #filter-panel { left: auto; right: 0; transform-origin: top right; } }
.fp-label { margin-bottom: 9px; color: var(--mute); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.fp-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.fp-opts button { padding: 6px 11px; border-radius: var(--rs); background: var(--chip); color: var(--mute); transition: background .2s, color .2s; }
.fp-opts button:hover { background: var(--chip2); color: var(--ink); }
.fp-opts button[aria-pressed='true'] { background: var(--ink); color: var(--bg); }
.fp-foot { display: flex; justify-content: space-between; align-items: center; color: var(--mute); font-size: 12px; }
.fp-foot button { color: var(--mute); text-decoration: underline; text-underline-offset: 3px; } .fp-foot button:hover { color: var(--ink); }

/* grid */
.grid { display: grid; gap: 34px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 22px var(--gutter) 88px; }
@media (min-width: 720px)  { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 42px 20px; } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { display: block; min-width: 0; text-align: left; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 30ms); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.plate { position: relative; aspect-ratio: 1; background: var(--plate); border-radius: var(--r); overflow: hidden; transition: transform .45s var(--spring), background-color .3s; }
.plate::before { content: attr(data-n); position: absolute; top: 9px; left: 11px; z-index: 1; font-size: 10px; letter-spacing: .06em; color: var(--plate-ink); }
.plate img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.card:hover .plate img { transform: scale(1.04); }
.card:active .plate { transform: scale(.975); }
.plate.none { display: grid; place-items: center; padding: 16px; color: var(--plate-ink); text-align: center; }
.info { padding: 12px 1px 0; }
.info .name { display: flex; align-items: baseline; line-height: 1.35; }
.info .name::before { content: '>'; display: inline-block; width: 0; opacity: 0; overflow: hidden; color: var(--mute); transition: width .25s var(--ease), opacity .25s; }
.card:hover .info .name::before { width: 1.5ch; opacity: 1; }
.info .row { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; color: var(--mute); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.info .row i { flex: 1; min-width: 10px; border-bottom: 1px dotted var(--faint); transform: translateY(-3px); }
.info .row b { font-weight: 400; color: var(--ink); text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--mute); padding: 90px 0; }

footer { max-width: var(--max); margin: 0 auto; padding: 26px var(--gutter) max(34px, env(safe-area-inset-bottom)); border-top: 1px dashed var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px 40px; color: var(--mute); font-size: 11px; line-height: 1.8; }
footer .tag { color: var(--ink); font-weight: 700; font-size: 12px; margin-bottom: 4px; }
footer p { max-width: 62ch; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 16px; align-self: flex-end; }
kbd { font: inherit; background: var(--chip2); border-radius: 4px; padding: 1px 6px; margin-right: 4px; color: var(--ink); }
@media (hover: none) { .keys { display: none; } }

/* detail page */
dialog { margin: 0; padding: 0; border: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; background: var(--bg); color: var(--ink); overflow: auto; font: inherit; }
dialog:focus { outline: none; }
dialog[open] { display: grid; grid-template-columns: 1fr; grid-auto-rows: max-content; align-content: start; animation: sheet .35s var(--ease); }
dialog::backdrop { background: #000; }
@keyframes sheet { from { opacity: 0; transform: translateY(16px); } }
.s-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 12px var(--gutter); background: var(--bg); }
.nav { display: flex; gap: 6px; }
.icon { min-width: 40px; height: 34px; padding: 0 12px; display: grid; place-items: center; border-radius: var(--rs); background: var(--chip); font-size: 12px; transition: background .2s, transform .2s var(--spring); }
.icon:hover { background: var(--chip2); } .icon:active { transform: scale(.92); }
.s-plate { display: grid; place-items: center; width: calc(100% - 2 * var(--gutter)); margin: 4px var(--gutter) 0; height: min(calc(100vw - 2 * var(--gutter)), 62dvh); background: var(--plate); border-radius: var(--r); overflow: hidden; transition: background-color .3s; }
.s-plate img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; }
.s-info { display: flex; flex-direction: column; padding: 28px var(--gutter) 56px; }
.s-head { display: grid; gap: 8px; }
.s-info .brand { color: var(--mute); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; line-height: 1; }
h2 { font-weight: 700; font-size: clamp(24px, 3vw, 34px); line-height: 1.1; letter-spacing: -.035em; }
.colour { display: flex; align-items: center; gap: 9px; color: var(--mute); font-size: 12px; line-height: 1; }
.colour::before { content: ''; flex: none; width: 9px; height: 9px; border-radius: 50%; background: #0c0c0d; box-shadow: 0 0 0 1px var(--line); }
.desc { margin: 24px 0 28px; max-width: 56ch; line-height: 1.75; opacity: .86; }
.specs { border-top: 1px dashed var(--line); }
.specs div { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding: 11px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.specs dt { color: var(--mute); flex: none; }
.specs dd { text-align: right; }
.s-foot { margin-top: auto; padding-top: 32px; }
.buy { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.buy .price { font-size: 28px; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.btn { display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 20px; border-radius: var(--rs); background: var(--ink); color: var(--bg); font-weight: 700; transition: transform .3s var(--spring); }
.btn span { display: inline-block; transition: transform .3s var(--spring); }
.btn:hover { transform: translateY(-2px); } .btn:hover span { transform: translate(3px, -3px); }
.btn:active { transform: scale(.97); }
.note { margin-top: 14px; color: var(--mute); font-size: 11px; }
body.lock { overflow: hidden; }

@media (min-width: 900px) {
  /* one grid, one gutter: plate, controls, text and button share the same top, bottom and side edges */
  dialog[open] { grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); grid-template-rows: auto minmax(0, 1fr); height: 100dvh; overflow: hidden; align-content: stretch; gap: 0 clamp(32px, 5vw, 72px); padding: var(--gutter); }
  .s-plate { grid-column: 1; grid-row: 1 / 3; width: auto; height: auto; margin: 0; }
  .s-top { grid-column: 2; grid-row: 1; position: static; padding: 0 0 clamp(24px, 5vh, 48px); background: none; }
  .s-info { grid-column: 2; grid-row: 2; overflow: auto; padding: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
