/* Doseurómetro: same look as the Hobby Lab sites (Electómetro, Primómetro) on jordijoan.es; motion in ../shared/motion.css */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f3f2ee;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #5f5d58;
  --border: rgba(11, 11, 11, 0.12);
  --accent: #2a78d6; --accent-ink: #1c5cab; --accent-wash: rgba(42, 120, 214, 0.10);
  --on-accent: #ffffff;
  --badge-bg: #fff1c2; --badge-text: #5a4300;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px rgba(11, 11, 11, 0.04);
  --glow: none;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #070b14; --surface: #0e1525; --surface-2: #151f36;
    --ink: #eef2fb; --ink-2: #b7c1d8; --muted: #8a96b2;
    --border: rgba(150, 175, 255, 0.13);
    --accent: #7c9cff; --accent-ink: #aabcff; --accent-wash: rgba(124, 156, 255, 0.16);
    --on-accent: #0a1020;
    --badge-bg: #3d3210; --badge-text: #ffe28a;
    --shadow: none;
    --glow: radial-gradient(1100px 520px at 72% -8%, rgba(96, 120, 255, 0.20), transparent 70%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #070b14; --surface: #0e1525; --surface-2: #151f36;
  --ink: #eef2fb; --ink-2: #b7c1d8; --muted: #8a96b2;
  --border: rgba(150, 175, 255, 0.13);
  --accent: #7c9cff; --accent-ink: #aabcff; --accent-wash: rgba(124, 156, 255, 0.16);
  --on-accent: #0a1020;
  --badge-bg: #3d3210; --badge-text: #ffe28a;
  --shadow: none;
  --glow: radial-gradient(1100px 520px at 72% -8%, rgba(96, 120, 255, 0.20), transparent 70%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--page) var(--glow) no-repeat; color: var(--ink);
  font: 15px/1.5 var(--font);
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--on-accent); padding: .5rem 1rem; z-index: 40; border-radius: 8px; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.top .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.top nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.top nav a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.top nav a:hover { background: var(--accent-wash); color: var(--ink); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer;
}

/* ---------- filter row: small label over the value, as in the Electómetro's pickers ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; padding: 20px 0 4px; }
.field {
  display: flex; flex-direction: column; justify-content: center; min-width: 140px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.field:focus-within { border-color: var(--accent); }
.field label { font-size: 12px; color: var(--muted); line-height: 1.2; }
.field input, .field select {
  font: inherit; font-weight: 600; color: var(--ink); background: transparent;
  border: 0; padding: 0; min-height: 26px; width: 100%;
}
.field select option { background: var(--surface); color: var(--ink); }
.field-search { flex: 1 1 260px; }
.field-year { min-width: 110px; }
.btn {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; min-height: 44px; cursor: pointer;
}
.btn:hover { background: var(--accent-wash); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.1); }

/* ---------- hero ---------- */
.hero { padding: 34px 0 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 32px; align-items: end; }
.hero-copy { min-width: 0; }
.hero h1 { margin: 2px 0 10px; font-size: clamp(34px, 5.4vw, 60px); line-height: 1.02; letter-spacing: -0.03em; font-weight: 750; }
.hero .sub { margin: 0; color: var(--ink-2); max-width: 72ch; }
.hl-count[hidden] { display: none; }
@media (max-width: 760px) { .hero { grid-template-columns: minmax(0, 1fr); } }
/* plain fallbacks for the local preview, where ../shared/motion.css is not served */
.hl-pills { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; padding: 0; }
.hl-pills li { padding: 3px 12px; border-radius: 999px; background: var(--accent-wash); color: var(--accent-ink); font-size: 13px; font-weight: 500; }
.hl-count { display: inline-grid; grid-template-columns: auto auto; align-items: center; gap: 2px 12px; padding: 14px 18px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); }
.hl-count b { font-size: 40px; line-height: 1; grid-row: span 2; }

/* ---------- panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; min-width: 0; margin-top: 16px;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 16px; }
.card h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.card .hint { color: var(--muted); font-size: 13px; }
.card-head .seg { margin-left: auto; }
.seg { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-size: 14px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); font-weight: 600; }
.topics { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 20px; }
.topics[hidden] { display: none; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 32px; padding: 5px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 13px;
}
.chip small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chip:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.chip[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); font-weight: 600; }
.chip[aria-pressed="true"] small { color: var(--ink-2); }
.dlg-topics { font-size: 14px; }
.error { background: var(--badge-bg); color: var(--badge-text); border-radius: var(--radius); padding: 12px 16px; }

/* ---------- coins ---------- */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.coin { margin: 0; min-width: 0; }
.card-btn {
  display: flex; flex-direction: column; width: 100%; height: 100%; text-align: left;
  color: inherit; background: var(--surface-2);
  border: 1px solid transparent; border-radius: 12px; padding: 12px; cursor: pointer;
}
.card-btn:hover { border-color: var(--accent); }
.thumb { aspect-ratio: 1; display: grid; place-items: center; margin-bottom: 8px; }
/* the notice images are square scans on white: show just the coin */
.thumb img { width: 100%; height: 100%; object-fit: contain; clip-path: circle(48%); }
.ph {
  width: 80%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  border: 4px solid var(--border); color: var(--muted); font-weight: 700; font-size: 1.5rem;
}
.ph.big { width: 70%; max-width: 280px; }
.card-meta { font-size: 12.5px; color: var(--muted); }
.card-subject { font-weight: 600; font-size: .92rem; line-height: 1.3; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; background: var(--badge-bg); color: var(--badge-text); border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; }
.coin .badge { margin-top: 6px; align-self: flex-start; }
.tag { display: inline-block; align-self: flex-start; margin-top: 6px; padding: 2px 10px; border-radius: 999px; background: var(--accent-wash); color: var(--accent-ink); font-size: .78rem; font-weight: 600; }
.more { text-align: center; }
.more .btn { margin-top: 20px; }
.grid[hidden], .groups[hidden], .more [hidden] { display: none; }

.group { margin: 0 0 28px; }
.group:last-child { margin-bottom: 0; }
.group-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font: 650 22px/1.15 var(--hl-display, var(--font)); letter-spacing: -0.02em; }
.group-sub { font: 400 13px/1.4 var(--font); letter-spacing: 0; color: var(--muted); }

/* ---------- method ---------- */
.method { columns: 2 320px; column-gap: 32px; color: var(--ink-2); }
.method h3 { break-after: avoid; margin: 0 0 4px; font-size: 15px; color: var(--ink); }
.method p { margin: 0 0 14px; break-inside: avoid; }

footer { margin: 32px 0 0; padding: 22px 0 40px; border-top: 1px solid var(--border); color: var(--ink-2); font-size: 14px; }
footer p { margin: 0 0 6px; max-width: 90ch; }

/* ---------- detail dialog ---------- */
dialog {
  width: min(900px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 0;
  border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgba(3, 6, 14, .7); }
.dlg-bar {
  position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.dlg-pos { flex: 1; text-align: center; font-size: .875rem; color: var(--muted); }
.dlg-content { padding: 16px; display: grid; gap: 16px; }
.dlg-img { display: grid; place-items: center; background: var(--surface-2); border-radius: var(--radius); padding: 12px; }
.dlg-img img { width: 100%; max-width: 360px; height: auto; aspect-ratio: 1; object-fit: contain; clip-path: circle(48%); }
.dlg-content h2 { margin: 0 0 4px; }
.dlg-content h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.dlg-content p { margin: 0 0 .5rem; max-width: 70ch; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 1rem 0; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; color: var(--ink-2); }
.btn-link { display: inline-block; text-decoration: none; margin-top: 8px; padding-top: 10px; }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (min-width: 800px) {
  .dlg-content { grid-template-columns: 1fr 1.3fr; padding: 24px; }
}
@media (max-width: 560px) {
  .card { padding: 16px; }
  .top nav a.hide-sm { display: none; }
  .field { flex: 1 1 140px; }
  .field-search { flex-basis: 100%; }
  .card-head .seg { margin-left: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .card-btn { transition: border-color .15s, transform .15s; }
  .card-btn:hover { transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
