/* Sellómetro: same look as the Hobby Lab sites (Electómetro, Primómetro, Doseuró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;
  --paper: #fbf7ec; --paper-edge: rgba(80, 60, 20, 0.18);
  --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;
    --paper: #efe9da; --paper-edge: rgba(0, 0, 0, 0.35);
    --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;
  --paper: #efe9da; --paper-edge: rgba(0, 0, 0, 0.35);
  --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, .top nav a[aria-current="page"] { 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%; min-width: 0; text-overflow: ellipsis;
}
.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; }
/* the darker accent: white on --accent is only 4.4:1 in the light theme */
.btn-primary { background: var(--accent-ink); color: var(--on-accent); border-color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-ink); 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 minmax(0, 1fr); max-width: 100%; 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); }
.error { background: var(--badge-bg); color: var(--badge-text); border-radius: var(--radius); padding: 12px 16px; }

/* ---------- eras ---------- */
.eras { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.era-btn {
  display: flex; flex-direction: column; gap: 2px; width: 100%; height: 100%; text-align: left; cursor: pointer;
  padding: 12px 14px; border: 1px solid transparent; border-radius: 12px; background: var(--surface-2); color: inherit; text-decoration: none;
}
.era-btn:hover { border-color: var(--accent); }
.era-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); }
.era-name { font-weight: 650; }
.era-range { font-size: 13px; color: var(--muted); }
.era-count { margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.era-count b { font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 4px; }
.era-btn.is-ext .era-count { color: var(--accent-ink); }

/* ---------- stamps: a paper stamp with a perforated edge, drawn in CSS ---------- */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.item { 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); }
.stamp {
  --r: 4px;
  display: block; aspect-ratio: 4 / 5; margin-bottom: 10px; padding: calc(2.2 * var(--r));
  background: var(--paper);
  filter: drop-shadow(0 1px 1px var(--paper-edge));
  -webkit-mask:
    radial-gradient(var(--r), #0000 97%, #000) round calc(-1.5 * var(--r)) calc(-1.5 * var(--r)) / calc(3 * var(--r)) calc(3 * var(--r)),
    linear-gradient(#000 0 0) no-repeat 50% / calc(100% - 3 * var(--r)) calc(100% - 3 * var(--r));
  mask:
    radial-gradient(var(--r), #0000 97%, #000) round calc(-1.5 * var(--r)) calc(-1.5 * var(--r)) / calc(3 * var(--r)) calc(3 * var(--r)),
    linear-gradient(#000 0 0) no-repeat 50% / calc(100% - 3 * var(--r)) calc(100% - 3 * var(--r));
}
.stamp-in {
  display: grid; grid-template-rows: auto auto 1fr auto; height: 100%; padding: 10px 10px 8px;
  background: var(--ink-c, #7a2e2e); color: #fff; border-radius: 2px;
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .14), rgba(0, 0, 0, .12));
}
.st-country { font-size: 10.5px; letter-spacing: .14em; font-weight: 700; opacity: .9; }
.st-face { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.st-face small { font-size: 12px; font-weight: 600; opacity: .85; margin-left: 4px; }
.st-title { align-self: end; font-size: 12.5px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.st-year { justify-self: end; font-size: 11px; font-weight: 700; letter-spacing: .06em; opacity: .9; margin-top: 4px; }
/* stamp inks: deep colours so white text keeps a 4.5:1 contrast */
.ink-0 { --ink-c: #8a2f2a; } .ink-1 { --ink-c: #1f4f7a; } .ink-2 { --ink-c: #2f6236; } .ink-3 { --ink-c: #6a3a7a; }
.ink-4 { --ink-c: #7a5114; } .ink-5 { --ink-c: #1e5e5e; } .ink-6 { --ink-c: #5a4636; } .ink-7 { --ink-c: #8a2f5a; }
.ink-8 { --ink-c: #3a4a8a; } .ink-9 { --ink-c: #4a5a1e; }
/* stamp pictures, shown from the FESOFI catalogue (247 x 300, the stamp on a pale canvas) */
.photo { display: block; aspect-ratio: 247 / 300; margin-bottom: 10px; border-radius: 6px; overflow: hidden; background: var(--paper); }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-big { width: min(247px, 70vw); }
.pic-src { margin: 6px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.card-meta { font-size: 12.5px; color: var(--muted); }
.card-subject { font-weight: 600; font-size: .9rem; line-height: 1.3; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-motifs { font-size: 12.5px; color: var(--ink-2); line-height: 1.3; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* the values of a series in the dialog */
.vals { list-style: none; margin: .5rem 0 1rem; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.vals a { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 8px; border-radius: 10px; background: var(--surface-2); color: var(--ink); text-decoration: none; border: 1px solid transparent; font-size: 12.5px; line-height: 1.3; }
.vals a:hover { border-color: var(--accent); }
.vals img { display: block; width: 100%; height: auto; aspect-ratio: 247 / 300; border-radius: 4px; margin-bottom: 4px; background: var(--paper); }
.val-n { color: var(--muted); }
.val-v { font-weight: 700; }
.val-m { color: var(--ink-2); }
.badge { display: inline-block; background: var(--badge-bg); color: var(--badge-text); border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 600; }
.item .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; content-visibility: auto; contain-intrinsic-size: auto 640px; }
.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); }
.group-note { margin: -4px 0 12px; color: var(--ink-2); font-size: 14px; }

/* ---------- method and text pages ---------- */
.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; }
.prose { color: var(--ink-2); max-width: 75ch; }
.prose h3 { color: var(--ink); font-size: 16px; margin: 22px 0 6px; }
.prose h3:first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose li { margin: 0 0 6px; }
.prose code, .code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .95em; background: var(--surface-2); border-radius: 6px; padding: 1px 6px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); }
.timeline b { color: var(--ink); font-variant-numeric: tabular-nums; }
.timeline span { color: var(--ink-2); }
.codebox { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 14px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.codebox span { padding: 6px 8px; border-radius: 8px; background: var(--accent-wash); color: var(--ink); font-weight: 700; }
.legend { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 14px; }
.legend dt { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; color: var(--ink); }
.legend dd { margin: 0; }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.links a { display: block; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.links a:hover { border-color: var(--accent); }
.links small { display: block; color: var(--muted); }

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: start center; align-content: start; }
.dlg-img .stamp { width: min(240px, 70vw); --r: 6px; }
.dlg-img .st-face { font-size: 34px; }
.dlg-img .st-title { font-size: 15px; -webkit-line-clamp: 6; line-clamp: 6; }
.dlg-img .st-country { font-size: 12px; }
.dlg-img .st-year { font-size: 13px; }
.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); }
.dlg-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.dlg-tags .tag { margin-top: 0; }
.dlg-topics { font-size: 14px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: .5rem 0 1rem; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; color: var(--ink-2); }
.official { white-space: pre-line; }
.see { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }
.corr { margin: .25rem 0 0; padding-left: 1.1rem; color: var(--ink-2); }
.corr li { margin-bottom: 4px; }

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

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