/* ============================================================
   Plates — Swiss / International Typographic Style
   Lexend · strict grid · hairline rules · single red accent
   ============================================================ */

/* Plate-font @font-face rules are emitted inline by views/page.php with
   mtime cache-busting (see the $fontFace helper there), not declared here. */

:root {
  --bg:        #f4f3ee;   /* warm off-white paper */
  --bg-card:   #ffffff;
  --ink:       #0a0a0a;
  --ink-2:     #45464a;
  --muted:     #76787d;
  --line:      #0a0a0a;
  --line-soft: #d9d8d2;
  --accent:    #ff3b30;   /* single red accent */
  --eu:        #003399;   /* EU band blue */
  --good:      #1a7f37;
  --bad:       #cf222e;

  --maxw: 1180px;
  --gut: 28px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
iconify-icon { display: inline-block; vertical-align: -0.125em; }
::selection { background: var(--accent); color: #fff; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar { border-bottom: 1.5px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: 14px var(--gut); display: flex; align-items: baseline; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { background: var(--ink); color: #fff; font-weight: 800; font-size: 14px; letter-spacing: -.02em; width: 28px; height: 28px; display: grid; place-items: center; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand-sub { color: var(--muted); font-size: 13px; font-weight: 400; letter-spacing: .02em; text-transform: uppercase; margin-left: auto; }

/* ---- layout ---- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gut) 80px; }

/* ---- masthead ---- */
.masthead { padding: 64px 0 44px; border-bottom: 1.5px solid var(--line); }
.masthead-no { font-size: 13px; font-weight: 600; letter-spacing: .14em; color: var(--accent); margin-bottom: 22px; }
.masthead-title { font-size: clamp(38px, 7.5vw, 84px); font-weight: 800; letter-spacing: -.045em; line-height: .96; margin: 0 0 24px; }
.masthead-lead { font-size: clamp(15px, 2vw, 18px); color: var(--ink-2); max-width: 60ch; margin: 0 0 34px; line-height: 1.55; }

/* ============================================================
   Finder — tabbed tool
   ============================================================ */
.finder { border: 1.5px solid var(--line); background: var(--bg-card); }
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1.5px solid var(--line); }
.tab { font-family: inherit; cursor: pointer; background: none; border: none; border-right: 1.5px solid var(--line-soft); color: var(--muted); font-size: 14px; font-weight: 600; padding: 14px 20px; transition: color .15s, background .15s; }
.tab:last-child { border-right: 0; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; }

.panel { padding: 26px; }
.panel-hint { font-size: 13.5px; color: var(--muted); margin: 0 0 20px; max-width: 64ch; line-height: 1.5; }

/* ---- filter grid ---- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 40px; }
.filter-set { display: flex; flex-direction: column; gap: 12px; }
.filter-cap { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { cursor: pointer; width: 30px; height: 30px; border: 1.5px solid var(--line-soft); position: relative; transition: transform .1s; }
.sw:hover { transform: scale(1.08); }
.sw.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.sw[data-name]::after { content: attr(data-name); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 10px; font-weight: 600; padding: 3px 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 5; }
.sw:hover::after { opacity: 1; }

.opt-row { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { font-family: inherit; cursor: pointer; background: none; border: 1.5px solid var(--line-soft); color: var(--ink-2); font-size: 13px; font-weight: 500; padding: 7px 13px; transition: all .15s; }
.opt:hover { border-color: var(--ink); }
.opt.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.reset { margin-top: 22px; font-family: inherit; cursor: pointer; background: none; border: 1.5px solid var(--line-soft); color: var(--ink-2); font-size: 13px; font-weight: 600; padding: 8px 14px; display: inline-flex; align-items: center; gap: 6px; }
.reset:hover { border-color: var(--accent); color: var(--accent); }

/* ---- search bar ---- */
.searchbar { display: flex; align-items: stretch; border: 1.5px solid var(--line); background: var(--bg-card); }
.searchbar .at { display: grid; place-items: center; width: 50px; font-size: 20px; color: var(--muted); border-right: 1.5px solid var(--line-soft); }
.searchbar input { flex: 1; border: none; outline: none; background: none; font-family: inherit; font-size: 18px; font-weight: 500; padding: 15px 14px; color: var(--ink); min-width: 0; }
.searchbar input::placeholder { color: #b3b2ac; }

/* ---- colour match ---- */
.color-inputs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 22px; }
.color-field { display: flex; flex-direction: column; gap: 8px; }
.color-field > span { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.color-field input[type=color] { width: 64px; height: 40px; padding: 0; border: 1.5px solid var(--line); background: none; cursor: pointer; }
.color-field input[type=text] { width: 100px; border: 1.5px solid var(--line-soft); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; padding: 8px 10px; outline: none; }
.color-field input[type=text]:focus { border-color: var(--ink); }
.go-btn { font-family: inherit; cursor: pointer; background: var(--ink); color: #fff; border: 1.5px solid var(--ink); font-size: 15px; font-weight: 600; padding: 11px 22px; display: inline-flex; align-items: center; gap: 8px; transition: background .15s; }
.go-btn:hover { background: var(--accent); border-color: var(--accent); }

/* ============================================================
   Results
   ============================================================ */
.results { padding-top: 40px; }
.results-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 26px; }
.results-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.results-count { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .04em; }

.loader { display: flex; align-items: center; gap: 14px; color: var(--muted); margin: 40px 0; font-size: 15px; font-weight: 500; }
.spin { width: 20px; height: 20px; border: 2.5px solid var(--line-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { margin: 30px 0; padding: 20px 22px; border: 1.5px solid var(--line-soft); color: var(--muted); font-weight: 500; }

/* ---- card grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); border-top: 1.5px solid var(--line); border-left: 1.5px solid var(--line); }
.card { border-right: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); padding: 22px; cursor: pointer; background: var(--bg-card); transition: background .12s; position: relative; display: flex; flex-direction: column; gap: 14px; }
.card:hover { background: #fbfaf6; }
.card:hover .card-name { color: var(--accent); }
.card-plate { width: 100%; }
.plate-svg { overflow: hidden; }
/* grid debug overlay — hidden by default; window.debug(true) adds .debug to
   <body>, revealing the per-box outlines, padding/gap hatches and centre line. */
.plate-box .box-outline { stroke: none; }
.plate-debug { display: none; }
body.debug .plate-box .box-outline { stroke: #ff3b30; stroke-width: 0.9; }
body.debug .plate-debug { display: block; }
.card-plate .plate-svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.12)); }
/* NOTE: do NOT set font-family on .plate-svg text — a CSS rule beats the SVG's
   own per-country font-family presentation attribute and would force every
   plate back to one font. The renderer sets the real plate face inline. */
.card-head { display: flex; align-items: baseline; gap: 10px; }
.card-code { font-size: 12px; font-weight: 800; letter-spacing: .06em; color: #fff; background: var(--ink); padding: 3px 8px; flex-shrink: 0; }
.card-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; transition: color .15s; }
.card-region { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); flex-shrink: 0; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; font-weight: 600; border: 1.5px solid var(--line-soft); padding: 3px 8px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; }
.tag.eu { border-color: var(--eu); color: var(--eu); }
.tag.special { border-color: var(--accent); color: var(--accent); }
.tag iconify-icon { font-size: 13px; }

.card-variant { margin-top: -4px; font-size: 12px; font-weight: 600; color: var(--accent); display: flex; align-items: center; gap: 6px; }
.card-variant iconify-icon { font-size: 14px; }

/* score pill (for colour-match / decode ranked views) */
.card-score { position: absolute; top: 0; right: 0; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; padding: 4px 9px; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.card-score.mid { background: var(--ink); }
.card-score.lo { background: var(--muted); }

/* ============================================================
   Detail drawer
   ============================================================ */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10,10,10,.45); z-index: 60; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%); background: var(--bg); z-index: 70; overflow-y: auto; border-left: 1.5px solid var(--line); box-shadow: -8px 0 30px rgba(0,0,0,.12); animation: slide .22s cubic-bezier(.2,.8,.2,1); }
@keyframes slide { from { transform: translateX(40px); opacity: .6; } }
.drawer-inner { padding: 28px var(--gut) 60px; }
.drawer-close { position: sticky; top: 0; float: right; font-family: inherit; cursor: pointer; background: var(--bg); border: 1.5px solid var(--line); width: 38px; height: 38px; display: grid; place-items: center; font-size: 20px; z-index: 2; }
.drawer-close:hover { background: var(--ink); color: #fff; }

.dr-no { font-size: 12px; font-weight: 600; letter-spacing: .14em; color: var(--accent); margin-bottom: 14px; }
.dr-title { font-size: clamp(30px, 6vw, 44px); font-weight: 800; letter-spacing: -.03em; line-height: 1; margin: 0 0 6px; }
.dr-sub { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; font-weight: 500; margin-bottom: 26px; }
.dr-sub .code-chip { background: var(--ink); color: #fff; font-weight: 800; font-size: 12px; padding: 3px 8px; letter-spacing: .06em; }

.dr-plate { margin: 0 0 30px; }
.dr-plate .plate-svg { width: 100%; height: auto; filter: drop-shadow(0 2px 6px rgba(0,0,0,.15)); }

.dr-block { padding: 22px 0; border-top: 1.5px solid var(--line); }
.dr-block h3 { font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.dr-block p { margin: 0 0 10px; font-size: 15px; line-height: 1.55; color: var(--ink-2); }

.dr-facts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1.5px solid var(--line); border-left: 1.5px solid var(--line); }
.dr-fact { border-right: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); padding: 14px 16px; }
.dr-fact b { display: block; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.dr-fact span { display: block; margin-top: 5px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.dr-fact .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; }
.spec-facts { margin-bottom: 16px; }
.spec-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0; border-top: 1.5px solid var(--line-soft); }
.spec-list dt { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 11px 16px 11px 0; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.spec-list dd { margin: 0; font-size: 14px; color: var(--ink-2); padding: 11px 0; border-bottom: 1px solid var(--line-soft); line-height: 1.45; }

/* ---- region/city code lookup ---- */
.dr-block h3 .rc-count { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 8px; vertical-align: middle; }
.rc-hint { font-size: 13.5px; color: var(--muted); margin: 0 0 14px; }
.rc-search { width: 100%; border: 1.5px solid var(--line); background: var(--bg-card); font-family: inherit; font-size: 15px; padding: 11px 13px; outline: none; margin-bottom: 14px; }
.rc-search:focus { border-color: var(--accent); }
.rc-tablewrap { max-height: 280px; overflow-y: auto; border: 1.5px solid var(--line-soft); }
.rc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rc-table tr { border-bottom: 1px solid var(--line-soft); }
.rc-table tr:last-child { border-bottom: 0; }
.rc-table tr:nth-child(2n) { background: #faf9f5; }
.rc-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; padding: 8px 12px; white-space: nowrap; width: 1%; border-right: 1px solid var(--line-soft); color: var(--ink); }
.rc-place { padding: 8px 12px; color: var(--ink-2); }

/* ---- wikipedia link ---- */
.wiki-link { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; border: 1.5px solid var(--line); padding: 11px 16px; transition: all .15s; }
.wiki-link:hover { background: var(--ink); color: #fff; }
.wiki-link iconify-icon:last-child { font-size: 13px; opacity: .7; }

.dr-specials { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 540px) { .dr-specials { grid-template-columns: 1fr; } }
.dr-special { border: 1.5px solid var(--line-soft); padding: 12px; }
.dr-special .plate-svg { width: 100%; height: auto; margin-bottom: 12px; }
.dr-special .sp-label { font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.dr-special .sp-label::before { content: ""; width: 9px; height: 9px; background: var(--accent); }
.dr-special .sp-note { font-size: 13.5px; color: var(--ink-2); margin: 6px 0 0; line-height: 1.5; }

/* ---- footer ---- */
.foot { border-top: 1.5px solid var(--line); }
.foot-inner { max-width: var(--maxw); margin: 0 auto; padding: 26px var(--gut); display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.foot-inner a { color: var(--ink); font-weight: 600; text-decoration: none; }
.foot-inner a:hover { color: var(--accent); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .filters { grid-template-columns: 1fr; gap: 22px; }
  .tab { padding: 12px 14px; font-size: 13px; }
  .grid { grid-template-columns: 1fr; }
  .masthead { padding: 44px 0 32px; }
}
