/* Premodern Zone
   Colour and type: jeppesen.dev (cream + ink, Clash Grotesk + Author).
   Page order: britishmuseum.org homepage.
   One bold element: the opening hand of cards in the hero. Everything else stays quiet. */

:root {
  --cream: #f2ede4;
  --panel: #e9e2d5;
  --ink: #252525;
  --ink-soft: #5b5b5b;
  --line: rgba(37, 37, 37, 0.16);
  --line-dark: rgba(242, 237, 228, 0.18);
  --cream-soft: rgba(242, 237, 228, 0.72);
  --white: #fff;
  --highlight: #f6d77a;   /* "to add" markers on draft legal pages */
  /* Text fallbacks for mana symbols, shown only if a symbol image fails to load */
  --mana-w: #efe6c8; --mana-w-ink: #5a4f2c; --mana-u: #4e7fb0; --mana-b: #3b3a38;
  --mana-r: #c3563f; --mana-g: #4c8a5a; --mana-c: #c9c1b3;

  --font-display: "Clash Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Author", "Helvetica Neue", Arial, sans-serif;

  --margin: clamp(16px, 3.2vw, 48px);
  --max: 1320px;
  --radius: 6px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 400 17px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* faint paper grain (as on the reference site) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

img { display: block; max-width: 100%; }
a { color: inherit; }
p { margin: 0; }

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 580;
  line-height: 1.04;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
h2 { font-size: clamp(32px, 4vw, 56px); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--margin); }
.muted { color: var(--ink-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
.dark :focus-visible { outline-color: var(--cream); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--cream);
  font: 600 15px/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn:hover { background: #000; }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: var(--cream); }
.dark .btn { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.dark .btn:hover { background: var(--white); }

.text-link {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.text-link:hover { text-decoration-thickness: 2.5px; }

/* ---------- Logo ---------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  font: 600 19px/1 var(--font-display);
}
.logo svg { width: 44px; height: 32px; flex: none; }
.logo .mark-bg { fill: var(--ink); }
.logo .mark-text { fill: var(--cream); font: 600 14.5px var(--font-display); letter-spacing: -.02em; }
.dark .logo .mark-bg, .menu .logo .mark-bg { fill: var(--cream); }
.dark .logo .mark-text, .menu .logo .mark-text { fill: var(--ink); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--cream) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: 72px; }
.header-nav { display: flex; gap: 4px; }
.header-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 17px;
  text-decoration: none;
}
.header-nav a:hover { background: var(--panel); }
.header-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1.5px; }
.menu-btn { display: none; }
.header-actions { display: flex; gap: 8px; }

/* ---------- Mobile menu ---------- */
.menu {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  padding: 14px var(--margin) 32px;
  background: var(--ink);
  color: var(--cream);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.menu.open { opacity: 1; visibility: visible; }
.menu-top { display: flex; justify-content: space-between; align-items: center; }
.menu .btn { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.menu ul { list-style: none; margin: auto 0; padding: 0; }
.menu ul a {
  display: block;
  padding: 4px 0;
  font: 580 clamp(40px, 11vw, 72px)/1.1 var(--font-display);
  text-decoration: none;
}
.menu-foot { color: var(--cream-soft); font-size: 14px; }

/* ---------- Hero ---------- */
.hero { padding-top: clamp(40px, 7vw, 96px); text-align: center; overflow: hidden; }
.hero h1 { font-size: clamp(44px, 6.6vw, 100px); max-width: 14ch; margin: 0 auto; }
.hero .intro { max-width: 44ch; margin: 22px auto 0; color: var(--ink-soft); font-size: clamp(17px, 1.4vw, 20px); font-weight: 500; }
.hero .actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 30px; }

/* The opening hand: nine cards fanned around a point far below them. */
.hand {
  --w: clamp(112px, 13vw, 196px);  /* card width */
  --step: 7deg;                    /* angle between cards */
  position: relative;
  height: calc(var(--w) * 1.393 * 1.6);
  margin-top: clamp(40px, 6vw, 72px);
}
.hand a {
  --a: calc((var(--i) - 4) * var(--step));
  position: absolute;
  top: 24px;
  left: 50%;
  width: var(--w);
  margin-left: calc(var(--w) / -2);
  border-radius: 4.75% / 3.5%;
  transform-origin: 50% 260%;
  transform: rotate(var(--a));
  transition: transform .25s var(--ease);
  box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 10px 24px -12px rgba(0,0,0,.35);
  animation: deal .9s var(--ease) backwards;
  animation-delay: calc(150ms + var(--i) * 70ms);
}
.hand a:hover, .hand a:focus-visible { transform: rotate(var(--a)) translateY(-22px); z-index: 10; }
.hand a:focus-visible { outline-offset: 4px; }
.hand img { width: 100%; height: auto; aspect-ratio: 488 / 680; border-radius: inherit; background: var(--panel); }

@keyframes deal {
  from { transform: translateY(60px) rotate(0deg); opacity: 0; }
  to   { transform: rotate(var(--a)); opacity: 1; }
}

.hand-caption {
  min-height: 1.6em;
  margin-top: -8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
}

/* British Museum's "Free entry / Open today" strip */
.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 40px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.facts div { padding: 18px 20px; }
.facts div + div { border-left: 1px solid var(--line); }
.facts dt { color: var(--ink-soft); font-size: 14px; font-weight: 500; }
.facts dd { margin: 2px 0 0; font: 580 20px/1.2 var(--font-display); }

/* ---------- Sections ---------- */
.section { padding: clamp(72px, 9vw, 128px) 0; }
.section + .section { padding-top: 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px 40px; flex-wrap: wrap; margin-bottom: 32px; }
.section-head p { max-width: 44ch; }

/* Events: a table that shows its future shape, with an honest empty state */
.events-table { border-top: 1.5px solid var(--ink); }
.events-cols {
  display: grid;
  grid-template-columns: 1fr 2.4fr 1.4fr 1.4fr;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
}
.events-cols--past { grid-template-columns: 1fr 2.2fr 1.4fr .8fr 1.6fr; }
.events-empty {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 36px 0;
  border-bottom: 1px solid var(--line);
}
.events-empty strong { display: block; font: 580 24px/1.2 var(--font-display); }
.events-empty p { margin-top: 6px; }
.events-empty .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Explore: a typographic index rather than a card grid */
.index { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.index li { border-bottom: 1px solid var(--line); }
.index a {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 1.6fr auto;
  align-items: center;
  gap: 24px;
  padding: 28px 0;
  text-decoration: none;
  transition: padding .25s var(--ease), background .25s;
}
.index a:hover { background: var(--panel); padding-left: 20px; padding-right: 20px; }
.index h3 { font-size: clamp(40px, 5.4vw, 80px); line-height: 1; }
.index p { color: var(--ink-soft); font-weight: 500; max-width: 42ch; }
.index .open { font-weight: 600; font-size: 15px; white-space: nowrap; }
.build-note { margin-top: 20px; color: var(--ink-soft); }

/* Read: articles and guides */
.read { display: grid; grid-template-columns: 1fr 1.3fr; gap: clamp(32px, 6vw, 96px); }
.read .lead p { margin-top: 16px; max-width: 40ch; }
.read .lead .btn { margin-top: 28px; }
.kinds { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.kinds li { display: grid; grid-template-columns: 1fr 1.5fr; gap: 24px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.kinds strong { font: 580 22px/1.2 var(--font-display); }
.kinds span { color: var(--ink-soft); font-weight: 500; }

/* ---------- Dark closing block: newsletter + footer ---------- */
.dark { background: var(--ink); color: var(--cream); }
.newsletter { padding: clamp(72px, 9vw, 120px) 0; border-bottom: 1px solid var(--line-dark); }
.newsletter .wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: end; }
.newsletter p { color: var(--cream-soft); margin-top: 14px; max-width: 40ch; }
.newsletter label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.newsletter .row { display: flex; gap: 8px; flex-wrap: wrap; }
.newsletter input {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: rgba(242, 237, 228, .06);
  color: var(--cream);
  font: 500 16px var(--font-body);
}
.newsletter input::placeholder { color: rgba(242, 237, 228, .45); }
.newsletter .hint { margin-top: 10px; font-size: 14px; color: var(--cream-soft); min-height: 1.5em; }

.site-footer { padding: 56px 0 32px; }
.footer-cols { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 32px; }
.footer-cols h4 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--cream-soft); }
.footer-cols ul { list-style: none; margin: 0; padding: 0; }
.footer-cols li a { display: inline-block; padding: 5px 0; text-decoration: none; font-weight: 500; }
.footer-cols li a:hover { text-decoration: underline; text-underline-offset: 4px; }
.footer-cols .about p { margin-top: 12px; color: var(--cream-soft); max-width: 32ch; }
.legal { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line-dark); color: rgba(242, 237, 228, .6); font-size: 13px; }
.legal p + p { margin-top: 6px; }
.legal a { text-underline-offset: 3px; }
.legal--full h2 { font-size: 18px; color: var(--cream); margin-bottom: 10px; }
.legal--full ul { margin: 12px 0 0; padding-left: 1.1em; max-width: 90ch; }
.legal--full li + li { margin-top: 4px; }

/* ---------- Inner pages ---------- */
/* only vertical padding here, so .wrap keeps its side margins */
.page { padding-top: clamp(56px, 8vw, 112px); padding-bottom: clamp(56px, 8vw, 112px); }
.page h1 { font-size: clamp(48px, 8vw, 120px); }
.page .intro { margin-top: 20px; max-width: 48ch; font-size: clamp(18px, 1.5vw, 21px); font-weight: 500; color: var(--ink-soft); }
.page .status { display: inline-block; margin-top: 24px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 14px; font-weight: 600; }
.page .body { margin-top: 48px; max-width: 64ch; border-top: 1.5px solid var(--ink); }
.page .body h2 { font-size: 26px; margin: 32px 0 10px; }
.page .body p, .page .body li { color: var(--ink-soft); font-weight: 500; }
.page .body ul { padding-left: 1.1em; margin: 10px 0 0; }
.page .body li + li { margin-top: 6px; }
.page .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 40px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .header-nav, .header-cta { display: none; }
  .menu-btn { display: inline-flex; }
}
@media (max-width: 860px) {
  .facts { grid-template-columns: 1fr 1fr; }
  .facts div:nth-child(3) { border-left: 0; }
  .facts div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .events-cols { display: none; }
  .index a { grid-template-columns: 1fr auto; gap: 8px 16px; }
  .index p { grid-column: 1 / -1; grid-row: 2; }
  .read, .newsletter .wrap { grid-template-columns: 1fr; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
  .footer-cols .about { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .hand { --step: 4.6deg; --w: 104px; }
  .kinds li { grid-template-columns: 1fr; gap: 4px; }
  .facts dd { font-size: 18px; }
  .index a:hover { padding-left: 0; padding-right: 0; }
}
@media (max-width: 420px) {
  /* not enough room for the name beside Donate + Menu: the PMZ mark stands alone */
  .site-header .logo-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Chat widget (chat.js) ---------- */
.chat {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.chat-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--cream);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px -6px rgba(0, 0, 0, .45);
  transition: transform .15s var(--ease);
}
.chat-launcher:hover { transform: scale(1.05); }
.chat.is-open .chat-launcher svg { display: none; }
.chat.is-open .chat-launcher::before { content: "×"; font: 400 30px/1 var(--font-body); }

.chat-icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.chat-icon-btn:hover { background: rgba(37, 37, 37, .08); }

/* teaser bubble */
.chat-teaser {
  display: flex;
  align-items: flex-start;
  max-width: 300px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px 12px 4px 12px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .35);
  animation: chat-in .35s var(--ease);
}
.chat-teaser[hidden] { display: none; }
.chat-teaser-body {
  flex: 1;
  padding: 14px 4px 14px 16px;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: 500 14px/1.45 var(--font-body);
}
.chat-teaser-body strong { display: block; font: 580 17px/1.25 var(--font-display); margin-bottom: 2px; }
.chat-teaser-close { flex: none; margin: 2px; color: var(--ink-soft); }

/* panel */
.chat-panel {
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .45);
  overflow: hidden;
  animation: chat-in .25s var(--ease);
}
.chat-panel[hidden] { display: none; }
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 10px 18px;
  background: var(--ink);
  color: var(--cream);
}
.chat-head h2 { font-size: 18px; }
.chat-head p { font-size: 13px; color: var(--cream-soft); }
.chat-head .chat-icon-btn:hover { background: rgba(242, 237, 228, .12); }
.chat-head-actions { display: flex; }
.chat-mute .slash { display: none; }
.chat-mute.is-muted .slash { display: inline; }
.chat-mute.is-muted .wave { display: none; }
.chat-head :focus-visible { outline-color: var(--cream); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.msg--bot { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 4px; }
.msg--user { align-self: flex-end; background: var(--ink); color: var(--cream); border-bottom-right-radius: 4px; }
.msg--typing { color: var(--ink-soft); font-style: italic; }

.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.chat-suggest[hidden] { display: none; }
.chat-suggest button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: var(--ink);
  font: 600 13px var(--font-body);
  cursor: pointer;
}
.chat-suggest button:hover { border-color: var(--ink); }

.chat-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--white) 53%, transparent);
  color: var(--ink);
  font: 500 16px var(--font-body);   /* 16px stops iOS zooming into the field */
}
.chat-form input:focus { border-color: var(--ink); outline: none; }
.chat-note { padding: 0 16px 12px; font-size: 12px; color: var(--ink-soft); }
.chat-note a { text-underline-offset: 2px; }

@keyframes chat-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 560px) {
  .chat-panel { height: calc(100dvh - 104px); }
}

/* ---------- Rules page ---------- */
.rules-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 40px 0 0;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1px solid var(--line);
}
.rules-facts div { padding: 18px 20px 18px 0; }
.rules-facts div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.rules-facts dt { color: var(--ink-soft); font-size: 14px; font-weight: 500; }
.rules-facts dd { margin: 2px 0 0; font: 580 clamp(22px, 2.4vw, 32px)/1.15 var(--font-display); }

.rules-block {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2.4fr;
  gap: 16px 48px;
  padding: 48px 0;
  border-bottom: 1px solid var(--line);
}
.rules-block h2 { font-size: clamp(26px, 2.6vw, 36px); }
.rules-text { max-width: 64ch; }
.rules-text p + p { margin-top: 14px; }
.rules-text strong { font-weight: 600; }
.rules-block .muted { margin-bottom: 16px; }

.set-list {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 3 200px;
  column-gap: 32px;
}
.set-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  break-inside: avoid;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}
/* set symbols are black SVGs; a fixed box keeps names aligned whatever the symbol's shape */
.set-list img { width: 22px; height: 22px; object-fit: contain; flex: none; }

/* banned cards as a grid of card images */
.ban-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px;
}
.ban-list a { display: block; border-radius: 4.75% / 3.5%; transition: transform .2s var(--ease); }
.ban-list a:hover, .ban-list a:focus-visible { transform: translateY(-4px); }
.ban-list img {
  width: 100%;
  height: auto;
  aspect-ratio: 488 / 680;
  border-radius: inherit;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15), 0 8px 18px -10px rgba(0, 0, 0, .35);
}

.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid;
  grid-template-columns: 170px 1fr auto;
  gap: 8px 24px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.history time { color: var(--ink-soft); font-size: 15px; font-variant-numeric: tabular-nums; }
.history span { font-weight: 600; }
.history .text-link { font-size: 14px; }

@media (max-width: 760px) {
  .rules-block { grid-template-columns: 1fr; padding: 36px 0; }
  .rules-facts { grid-template-columns: 1fr; }
  .rules-facts div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .history li { grid-template-columns: 1fr auto; }
  .history time { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .ban-list { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}

/* ---------- Cards page ---------- */
.cards-page { padding-top: clamp(40px, 5vw, 72px); padding-bottom: 80px; }
.cards-head h1 { font-size: clamp(48px, 7vw, 96px); }
.cards-head .intro { margin-top: 12px; color: var(--ink-soft); font-weight: 500; font-size: clamp(17px, 1.4vw, 19px); }
.cards-layout { display: grid; grid-template-columns: 290px 1fr; gap: 40px; margin-top: 36px; align-items: start; }

/* filters column */
.filters {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}
.filters-top { display: none; }
.f-group { border: 0; margin: 0; padding: 0 0 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); min-width: 0; }
.f-group legend {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: 0; margin-bottom: 10px; font-weight: 600; font-size: 15px;
}
.f-input, .f-select, .range-row input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--white) 40%, transparent);
  color: var(--ink);
  font: 500 16px var(--font-body);
}
.f-input + .f-input { margin-top: 8px; }
.f-input:focus, .f-select:focus, .range-row input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 1px var(--ink); }

.tog-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tog {
  min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 99px;
  background: transparent; color: var(--ink);
  font: 600 14px var(--font-body); cursor: pointer;
}
.tog:hover { border-color: var(--ink); }
.tog[aria-pressed="true"] { background: var(--ink); color: var(--cream); border-color: var(--ink); }

/* colour swatches: our own coloured circles with letters, not Wizards' mana symbols */
.swatch-row { display: flex; gap: 8px; margin-bottom: 12px; }
.swatch {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 2px solid transparent; background: transparent; cursor: pointer;
  font: 700 14px var(--font-body);
  opacity: .45; transition: opacity .15s, transform .15s;
}
.swatch:hover { opacity: .8; }
.swatch[aria-pressed="true"] { opacity: 1; border-color: var(--ink); transform: scale(1.06); }
.swatch--W, .pip--W { background: var(--mana-w); color: var(--mana-w-ink); }
.swatch--U, .pip--U { background: var(--mana-u); color: var(--white); }
.swatch--B, .pip--B { background: var(--mana-b); color: var(--cream); }
.swatch--R, .pip--R { background: var(--mana-r); color: var(--white); }
.swatch--G, .pip--G { background: var(--mana-g); color: var(--white); }
.swatch--C, .pip--N { background: var(--mana-c); color: var(--mana-b); }

.check { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 15px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

.set-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.set-btn {
  aspect-ratio: 1; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; cursor: pointer; opacity: .4;
}
.set-btn img { width: 24px; height: 24px; object-fit: contain; }
.set-btn:hover { opacity: .8; background: var(--panel); }
.set-btn[aria-pressed="true"] { opacity: 1; background: var(--panel); border-color: var(--ink); }

.link-btn { border: 0; background: none; padding: 0; color: var(--ink); font: 600 14px var(--font-body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.range-row { display: grid; grid-template-columns: 1fr 64px auto 64px; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; }
.range-row + .range-row { margin-top: 8px; }
.range-row input { min-height: 40px; padding: 0 8px; text-align: center; }
.range-row > span[aria-hidden] { color: var(--ink-soft); font-size: 13px; }
.f-reset { width: 100%; }

/* results column */
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
#results-count { font: 580 20px var(--font-display); }
.results-controls { display: flex; gap: 8px; }
.f-select { width: auto; padding-right: 32px; }
.filters-open { display: none; }

.card-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.card-btn {
  position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in;
  border-radius: 4.75% / 3.5%;
  transition: transform .2s var(--ease);
}
.card-btn:hover { transform: translateY(-4px); }
.card-btn img {
  display: block; width: 100%; height: auto; aspect-ratio: 488 / 680; border-radius: inherit;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0,0,0,.15), 0 8px 18px -10px rgba(0,0,0,.35);
}
.banned-tag {
  position: absolute; left: 8px; top: 8px;
  padding: 3px 8px; border-radius: 99px;
  background: var(--ink); color: var(--cream); font: 600 12px var(--font-body);
}
.cards-empty { padding: 48px 0; border-top: 1px solid var(--line); }
.cards-empty strong { display: block; font: 580 24px var(--font-display); margin-bottom: 6px; }
.cards-source { margin-top: 32px; font-size: 13px; }

/* card details */
.card-dialog {
  width: min(860px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 14px;
  background: var(--cream); color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.5);
}
.card-dialog::backdrop { background: rgba(20, 20, 20, .55); }
.cd-inner { display: grid; grid-template-columns: minmax(0, 1fr) 1.1fr; gap: 28px; padding: 24px; }
.cd-inner > img { width: 100%; height: auto; border-radius: 4.75% / 3.5%; background: var(--panel); }
.cd-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cd-top h2 { font-size: clamp(26px, 3vw, 34px); }
.cd-cost { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 3px; align-items: center; min-height: 24px; }
.pip { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 99px; font: 700 12px var(--font-body); }
.cd-type { margin-top: 10px; font-weight: 600; }
.cd-text { margin-top: 10px; white-space: pre-line; color: var(--ink-soft); font-weight: 500; }
.cd-meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 18px 0 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 15px; }
.cd-meta dt { color: var(--ink-soft); }
.cd-meta dd { margin: 0; font-weight: 500; }
.cd-meta .is-banned { font-weight: 700; }

@media (max-width: 900px) {
  .cards-layout { grid-template-columns: 1fr; }
  .filters-open { display: inline-flex; }
  .filters {
    position: fixed; inset: 0; z-index: 85; top: 0; max-height: none;
    padding: 16px var(--margin) 32px; background: var(--cream);
    transform: translateX(-100%); visibility: hidden;
    transition: transform .25s var(--ease), visibility .25s;
  }
  .filters.open { transform: none; visibility: visible; }
  .filters-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
  .filters-top h2 { font-size: 28px; }
  .set-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cd-inner { grid-template-columns: 1fr; padding: 16px; }
  .cd-inner > img { max-width: 260px; margin: 0 auto; }
  .results-controls { width: 100%; }
  .f-select { flex: 1; }
}

/* ---------- Decks and Strategy pages ---------- */
.muted { color: var(--ink-soft); font-weight: 500; }
.decks h2, .strategy h2 { font-size: clamp(28px, 3vw, 42px); }
.meta-block, .arch-block, .guides-block, .lib-block, .write-block { padding: clamp(48px, 6vw, 80px) 0; border-bottom: 1px solid var(--line); }
.decks .meta-block { margin-top: 24px; border-top: 1.5px solid var(--ink); }
.strategy .guides-block { margin-top: 24px; border-top: 1.5px solid var(--ink); }
.credit { padding-top: 32px; max-width: 72ch; font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.btn--sm { min-height: 40px; padding: 0 16px; font-size: 15px; }

/* Pie chart colours: a categorical palette checked for colour blindness on the cream background.
   Four of them are below 3:1 contrast, so every slice also has a visible name and figure in the legend. */
.meta-grid {
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c-other: #d3cbbd;
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 40px clamp(40px, 6vw, 96px);
  align-items: center;
  margin-top: 36px;
}
.donut-wrap { position: relative; margin: 0; aspect-ratio: 1; }
.donut { width: 100%; height: 100%; display: block; overflow: visible; }
.slice {
  fill: none;
  stroke-width: 22;
  cursor: pointer;
  transition: stroke-width .2s var(--ease), opacity .2s var(--ease);
  animation: draw .9s var(--ease) backwards;
  animation-delay: calc(var(--i) * 60ms);
}
@keyframes draw { from { opacity: 0; } }
.meta-grid.is-focus .slice { opacity: .3; }
.meta-grid.is-focus .slice.is-on { opacity: 1; stroke-width: 26; }
.donut-centre {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none; padding: 0 28%;
}
.donut-centre b { font: 600 clamp(36px, 4.4vw, 56px)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.donut-centre span { margin-top: 6px; font-size: 15px; font-weight: 600; color: var(--ink-soft); line-height: 1.3; }

.donut-legend { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.donut-legend li {
  display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 14px;
  min-height: 52px; border-bottom: 1px solid var(--line);
  transition: opacity .2s var(--ease);
}
.meta-grid.is-focus .donut-legend li { opacity: .4; }
.meta-grid.is-focus .donut-legend li.is-on { opacity: 1; }
.swatch-dot { width: 14px; height: 14px; border-radius: 4px; }
.lg-name { font: 560 20px/1.2 var(--font-display); }
.lg-name a { color: inherit; text-decoration: none; }
.lg-name a:hover { text-decoration: underline; text-underline-offset: 4px; }
.lg-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.donut-legend li[data-key="other"] .lg-name { color: var(--ink-soft); }
.meta-note { margin-top: 20px; font-size: 15px; max-width: 60ch; }

/* archetype list */
.arch-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; margin-bottom: 24px; }
.arch-tools { display: grid; grid-template-columns: minmax(240px, 420px) auto; gap: 12px 20px; align-items: center; margin-bottom: 28px; }
.arch-cols, .arch summary {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 140px minmax(160px, 300px) 24px;
  gap: 20px;
  align-items: center;
}
.arch-cols { padding-bottom: 10px; border-bottom: 1.5px solid var(--ink); font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.arch-list { list-style: none; margin: 0; padding: 0; }
.arch { border-bottom: 1px solid var(--line); scroll-margin-top: 96px; }
.arch summary { list-style: none; cursor: pointer; padding: 16px 0; min-height: 44px; }
.arch summary::-webkit-details-marker { display: none; }
.arch summary:hover .arch-title { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.arch summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.arch-rank { font: 500 15px var(--font-display); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.arch-name { display: flex; flex-direction: column; min-width: 0; }
.arch-title { font: 560 clamp(19px, 1.7vw, 22px)/1.25 var(--font-display); }
.arch-styles { font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.arch-colors { display: flex; gap: 4px; }
.arch-share { display: flex; align-items: center; gap: 12px; }
.arch-pct { min-width: 4.4em; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }
.arch-bar { flex: 1; height: 6px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.arch-bar i { display: block; height: 100%; background: var(--ink); border-radius: inherit; }
.chev { transition: transform .2s var(--ease); color: var(--ink-soft); }
.arch details[open] .chev { transform: rotate(180deg); }
.arch.is-target { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 40% { background: var(--panel); } 100% { background: transparent; } }

.arch-body { padding: 0 0 28px calc(84px + 20px); max-width: 860px; }
.arch-art { display: block; width: 84px; aspect-ratio: 626 / 457; height: auto; object-fit: cover; border-radius: 6px; background: var(--panel); }
.arch-desc { font-size: 17px; max-width: 64ch; }
.arch-body h4 { margin: 20px 0 10px; font: 600 15px var(--font-body); }
.key-cards { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.key-cards a {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 99px;
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600;
}
.key-cards a:hover { border-color: var(--ink); }
.arch-links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-top: 22px; }
.arch-links:empty { display: none; }
.arch-empty { padding: 40px 0; text-align: center; }
.arch-empty .btn { margin-top: 12px; }

/* guides by archetype */
.guide-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 12px; }
.guide-tools label { font-weight: 600; font-size: 15px; }
.guide-tools .f-select { width: auto; min-width: 240px; }
.guide-group {
  display: grid; grid-template-columns: minmax(200px, 1fr) 2.4fr; gap: 12px 48px;
  padding: 28px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 96px;
}
.guide-group:target { animation: flash 1.6s var(--ease); }
.gg-head h3 { font-size: clamp(22px, 2vw, 28px); }
.gg-head .muted { font-size: 14px; margin-top: 2px; }
.gg-deck { display: inline-block; margin-top: 10px; font-size: 14px; }
.guide-list { list-style: none; padding: 0; margin: 0; }
.guide-list li + li { border-top: 1px solid var(--line); }
.guide-list a, .lib-col li a { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; color: var(--ink); text-decoration: none; }
.guide-list li:first-child a { padding-top: 0; }
.guide-list a:hover .g-title, .lib-col li a:hover .g-title { text-decoration: underline; text-underline-offset: 3px; }
.g-title { font-weight: 600; }
.g-meta { font-size: 14px; color: var(--ink-soft); font-weight: 500; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.g-kind { padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; font-weight: 600; }
.no-guide { margin-top: 28px; max-width: 72ch; }

/* library */
.intro-sm { margin-top: 12px; max-width: 56ch; color: var(--ink-soft); font-weight: 500; font-size: 18px; }
.lib-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px; margin-top: 40px; }
.lib-col { border-top: 1.5px solid var(--ink); padding-top: 16px; }
.lib-col h3 { font-size: 24px; }
.lib-col > p { font-size: 15px; margin-top: 2px; }
.lib-col ul { list-style: none; padding: 0; margin: 16px 0 0; }
.lib-col li + li { border-top: 1px solid var(--line); }
.lib-col li a { padding-bottom: 2px; }
.lib-col li p { font-size: 16px; color: var(--ink-soft); padding-bottom: 14px; }

.write-block { display: grid; grid-template-columns: minmax(180px, 1fr) 2.4fr; gap: 16px 48px; }
.write-block p { max-width: 60ch; }
.write-block p + p { margin-top: 12px; }
.write-block .btn { margin-top: 24px; }

@media (max-width: 1100px) {
  .lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .meta-grid { grid-template-columns: 1fr; }
  .donut-wrap { max-width: 340px; width: 100%; margin: 0 auto; }
  .arch-cols { display: none; }
  .arch-tools { grid-template-columns: 1fr; }
  .arch summary {
    grid-template-columns: 64px minmax(0, 1fr) auto 24px;
    grid-template-areas: "art name colors chev" "art share share .";
    gap: 6px 12px;
  }
  .arch-art { grid-area: art; width: 64px; align-self: start; margin-top: 2px; }
  .arch-name { grid-area: name; }
  .arch-colors { grid-area: colors; }
  .arch-share { grid-area: share; }
  .chev { grid-area: chev; }
  .arch-body { padding-left: calc(64px + 12px); }
  .guide-group, .write-block { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .lib-grid { grid-template-columns: 1fr; }
  .arch-body { padding-left: 0; }
  .lg-name { font-size: 18px; }
  .guide-tools .f-select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .slice, .arch.is-target, .guide-group:target { animation: none; }
  .slice, .chev, .donut-legend li { transition: none; }
}

/* Magic mana symbols (images from Scryfall) */
.mana { display: inline-block; width: 22px; height: 22px; vertical-align: middle; border-radius: 50%; box-shadow: -1px 1px 0 rgba(0, 0, 0, .55); }
#cd-cost .mana { width: 20px; height: 20px; margin-right: 2px; }
.swatch img { width: 30px; height: 30px; border-radius: 50%; box-shadow: -1px 1px 0 rgba(0, 0, 0, .55); }
.arch-colors { align-items: center; }

/* ---------- Strategy: deck tiles with card art ---------- */
.deck-tiles {
  list-style: none; margin: 32px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px;
}
.deck-tile {
  position: relative; display: block; width: 100%;
  aspect-ratio: 626 / 457;
  padding: 0; border: 0; border-radius: 10px; overflow: hidden;
  background: var(--ink); color: var(--white); text-align: left; cursor: pointer;
  font: inherit;
}
.tile-art {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transition: transform .5s var(--ease);
}
/* dark fade at the bottom so the white text always reads */
.deck-tile::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(0,0,0,.35) 60%, rgba(0,0,0,.82) 100%);
}
.deck-tile:hover .tile-art, .deck-tile:focus-visible .tile-art { transform: scale(1.05); }
.deck-tile:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.tile-mana { position: absolute; z-index: 1; top: 12px; left: 12px; display: flex; gap: 3px; }
.tile-mana .mana { width: 20px; height: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.tile-text { position: absolute; z-index: 1; left: 16px; right: 16px; bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.tile-name { font: 600 clamp(20px, 1.8vw, 26px)/1.1 var(--font-display); text-shadow: 0 1px 8px rgba(0,0,0,.5); }
.tile-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; font-weight: 600; color: rgba(255,255,255,.88); }
.tile-meta span { font-weight: 500; color: rgba(255,255,255,.72); }

/* pop-up with the deck's guides */
.guide-dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: 14px; overflow: auto;
  background: var(--cream); color: var(--ink);
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.guide-dialog::backdrop { background: rgba(20, 18, 15, .6); backdrop-filter: blur(3px); }
.guide-dialog[open] { animation: pop .28s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.gd-hero { position: relative; aspect-ratio: 16 / 7; overflow: hidden; background: var(--ink); color: var(--white); }
.gd-hero > img { width: 100%; height: 100%; object-fit: cover; }
.gd-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.15) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,.8) 100%); }
.gd-title { position: absolute; z-index: 1; left: 28px; right: 28px; bottom: 20px; }
.gd-title .tile-mana { position: static; margin-bottom: 8px; }
.gd-title h3 { font-size: clamp(28px, 4vw, 40px); line-height: 1.05; }
.gd-title p { margin-top: 4px; font-weight: 600; color: rgba(255,255,255,.8); }
.gd-close {
  position: absolute; z-index: 2; top: 12px; right: 12px;
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.5); color: var(--white); cursor: pointer;
}
.gd-close:hover { background: rgba(0,0,0,.75); }
.gd-close:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
.gd-body { padding: 24px 28px 28px; }
.gd-desc { color: var(--ink-soft); font-weight: 500; }
.gd-body h4 { margin: 24px 0 8px; padding-bottom: 8px; border-bottom: 1.5px solid var(--ink); font: 600 15px var(--font-body); }
.gd-body .guide-list li:first-child a { padding-top: 10px; }
.gd-body .guide-list li { border-bottom: 1px solid var(--line); }
.gd-body .guide-list li + li { border-top: 0; }
.gd-credit { margin-top: 20px; font-size: 13px; color: var(--ink-soft); }

@media (max-width: 1100px) { .deck-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .deck-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
@media (max-width: 480px) {
  .deck-tiles { grid-template-columns: 1fr; }
  .gd-title { left: 20px; right: 20px; }
  .gd-body { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .tile-art { transition: none; }
  .deck-tile:hover .tile-art { transform: none; }
  .guide-dialog[open] { animation: none; }
}

/* Donate: icon-only button in the header */
.btn--icon { width: 44px; padding: 0; }
.donate-btn .steam { transition: transform .4s var(--ease), opacity .4s var(--ease); }
.donate-btn:hover .steam, .donate-btn:focus-visible .steam { transform: translateY(-1.5px); opacity: .7; }
@media (prefers-reduced-motion: reduce) { .donate-btn .steam { transition: none; } }

/* ---------- Inverted colours (test, homepage only: see DARK_PAGES in build.py) ----------
   Only the site's existing colours are used: the footer's dark grey (#252525) becomes the page
   background and the cream (#f2ede4) becomes the text. Lines and soft text reuse the cream tints
   the footer already uses. */
body.theme-dark {
  --cream: #252525;                        /* page background (was the text colour) */
  --ink: #f2ede4;                          /* text (was the background) */
  --ink-soft: var(--cream-soft);           /* rgba(242, 237, 228, .72), from the footer */
  --line: var(--line-dark);                /* rgba(242, 237, 228, .18), from the footer */
  --panel: rgba(242, 237, 228, .06);       /* the newsletter field's fill */
}
.theme-dark .btn:hover { background: var(--white); border-color: var(--white); }
.theme-dark .btn--ghost:hover { background: var(--ink); color: var(--cream); }
/* the newsletter and footer block already has these colours: keep it as is, divided by a hairline */
.theme-dark .dark {
  --cream: #f2ede4;
  --ink: #252525;
  --ink-soft: #5b5b5b;
  --line: rgba(37, 37, 37, 0.16);
  border-top: 1px solid var(--line-dark);
}

/* ---------- Results: homepage Past tournaments rows, Decks page results line ---------- */
.events-row {
  display: grid;
  grid-template-columns: 1fr 2.2fr 1.4fr .8fr 1.6fr;
  gap: 16px;
  align-items: center;
  min-height: 60px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.events-row:hover .ev-name { text-decoration: underline; text-underline-offset: 3px; }
.events-row:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.ev-date, .ev-where, .ev-players { color: var(--ink-soft); font-weight: 500; font-size: 15px; }
.ev-players { font-variant-numeric: tabular-nums; }
.ev-name { font-weight: 600; }
.ev-winner { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.ev-winner img { width: 52px; aspect-ratio: 626 / 457; height: auto; object-fit: cover; border-radius: 4px; flex: none; }
.events-foot { padding-top: 16px; font-size: 14px; }
.events-foot .text-link + .text-link, .events-foot .text-link:last-child { margin-left: 4px; }

.arch-results { margin-top: 12px; font-size: 15px; font-weight: 600; }
span.arch-art { background: var(--panel); }

@media (max-width: 860px) {
  .events-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name winner" "meta winner";
    gap: 2px 16px;
  }
  .ev-name { grid-area: name; }
  .ev-winner { grid-area: winner; justify-self: end; text-align: right; }
  .ev-date { grid-area: meta; font-size: 14px; }
  .ev-where, .ev-players { display: none; }
}
@media (max-width: 480px) {
  .ev-winner { flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; }
}

/* ---------- Events page (results list) and event pages (top decks, decklist pop-ups) ---------- */
.events-page h2, .event-page h2 { font-size: clamp(28px, 3vw, 42px); }
.results-block, .upcoming-block { padding: clamp(48px, 6vw, 80px) 0; border-bottom: 1px solid var(--line); }
.events-page .results-block { margin-top: 24px; border-top: 1.5px solid var(--ink); }
.upcoming-block p { margin-top: 12px; max-width: 60ch; color: var(--ink-soft); font-weight: 500; }
.upcoming-block .actions { margin-top: 24px; }
.events-cols {
  display: grid; grid-template-columns: 1fr 2.2fr 1.4fr .8fr 1.6fr; gap: 16px;
  padding-bottom: 10px; border-bottom: 1.5px solid var(--ink);
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
}
.ev-month h3 { margin: 32px 0 4px; font: 600 15px var(--font-body); color: var(--ink-soft); }

.event-page h1 { font-size: clamp(36px, 5.5vw, 76px); line-height: 1.02; max-width: 18ch; overflow-wrap: anywhere; }
.event-page .back { margin-bottom: 20px; font-weight: 600; }
.ev-facts { display: flex; flex-wrap: wrap; gap: 12px 48px; margin: 28px 0 0; padding: 20px 0 48px; border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--line); }
.ev-facts dt { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.ev-facts dd { margin: 2px 0 0; font: 560 20px var(--font-display); }
.event-page section { padding-top: clamp(40px, 5vw, 64px); }
.event-page section > .muted { margin-top: 6px; }

.standings { list-style: none; margin: 24px 0 0; padding: 0; border-top: 1.5px solid var(--ink); }
.standings li { border-bottom: 1px solid var(--line); }
.standing {
  display: grid; grid-template-columns: 64px 84px minmax(0, 1fr) 140px auto; gap: 20px; align-items: center;
  width: 100%; min-height: 44px; padding: 14px 0; border: 0; background: none;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.standing > img, .st-art { display: block; width: 84px; aspect-ratio: 626 / 457; height: auto; object-fit: cover; border-radius: 6px; background: var(--panel); }
.st-rank { font: 600 17px var(--font-display); font-variant-numeric: tabular-nums; }
.st-name { font: 560 clamp(19px, 1.7vw, 22px)/1.25 var(--font-display); }
.st-open { font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.standing:hover .st-name { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.standing:hover .st-open { color: var(--ink); }
.standing:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* decklist pop-up: reuses .guide-dialog, wider so main deck and sideboard sit side by side */
.deck-dialog { width: min(920px, calc(100vw - 32px)); }
.dl-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 0 40px; }
.dl-cols > section { min-width: 0; }
.dl-cols > section:first-child { columns: 2; column-gap: 32px; }
.dl-cols > section:first-child > h4 { column-span: all; }
.gd-body .dl-cols h4 { margin-top: 0; display: flex; justify-content: space-between; }
.dl-group { break-inside: avoid; margin-top: 16px; }
.dl-group h5 { margin: 0 0 4px; font: 600 14px var(--font-body); color: var(--ink-soft); }
.dl-group h5 span { font-variant-numeric: tabular-nums; }
.dl-group ul { list-style: none; margin: 0; padding: 0; }
.dl-group li { display: flex; gap: 10px; padding: 3px 0; font-size: 15px; }
.dl-qty { min-width: 1.2em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.dl-group a { color: var(--ink); font-weight: 500; text-decoration: none; }
.dl-group a:hover { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 860px) {
  .events-cols { display: none; }
  .standing { grid-template-columns: 52px 64px minmax(0, 1fr) auto; gap: 14px; }
  .standing > img, .st-art { width: 64px; }
  .st-open { display: none; }
  .dl-cols { grid-template-columns: 1fr; }
  .dl-cols > section + section { margin-top: 28px; }
}
@media (max-width: 480px) {
  .standing { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .standing > img, .standing .st-art { display: none; }
  .dl-cols > section:first-child { columns: 1; }
}
/* The Decks page's mobile layout puts .arch-colors in a named grid area; standings rows have no such area. */
.standing .arch-colors { grid-area: auto; }

/* ---------- Decks page: every saved decklist of an archetype, inside its row ---------- */
.arch-body { max-width: none; }
.dlt { margin-top: 28px; }
.dlt h4 { margin: 0 0 10px; font: 600 15px var(--font-body); }
.dlt h4 .muted { margin-left: 6px; font-size: 14px; }
.dlt-cols, .dlt-row {
  display: grid;
  grid-template-columns: 88px 64px minmax(0, 1.2fr) 96px minmax(0, 2fr) 64px;
  gap: 16px;
  align-items: center;
}
.dlt-cols { padding-bottom: 8px; border-bottom: 1.5px solid var(--ink); font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.dlt-cols span:last-child, .dlt-players { text-align: right; }
.dlt-list { list-style: none; margin: 0; padding: 0; }
.dlt-list li { border-bottom: 1px solid var(--line); }
.dlt-row { min-height: 52px; padding: 8px 0; color: var(--ink); text-decoration: none; font-size: 15px; }
.dlt-row:hover .dlt-deck { text-decoration: underline; text-underline-offset: 3px; }
.dlt-row:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.dlt-date, .dlt-players { color: var(--ink-soft); font-weight: 500; font-variant-numeric: tabular-nums; }
.dlt-rank { font-weight: 600; font-variant-numeric: tabular-nums; }
.dlt-deck { font-weight: 600; overflow-wrap: anywhere; }
.dlt-row .mana { width: 20px; height: 20px; }
.dlt-event { display: flex; flex-direction: column; font-weight: 500; }
.dlt-event span { font-size: 13px; color: var(--ink-soft); }
.dlt-more summary {
  display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px;
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.dlt-more[open] summary { display: none; }

@media (max-width: 860px) {
  .arch-body { padding-left: 0; }
  .dlt-cols { display: none; }
  .dlt-row {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas: "rank deck colors" "rank event event" "rank date date";
    gap: 2px 12px;
    padding: 12px 0;
  }
  .dlt-rank { grid-area: rank; align-self: start; }
  .dlt-deck { grid-area: deck; }
  .dlt-row .arch-colors { grid-area: colors; }
  .dlt-event { grid-area: event; }
  .dlt-date { grid-area: date; font-size: 13px; }
  .dlt-players { display: none; }
}
.dlt-tools { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 4px 0 14px; }
.dlt-more summary[hidden] { display: none; }
.dlt-empty { padding: 16px 0; font-size: 15px; }

/* ---------- Legal pages ---------- */
.page .body .table-scroll { overflow-x: auto; margin-top: 14px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.legal-table th, .legal-table td { padding: 10px 12px 10px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.legal-table th { font-weight: 600; color: var(--ink); border-bottom: 1.5px solid var(--ink); }
.legal-table td { color: var(--ink-soft); font-weight: 500; }
.legal-table code { font-size: 13px; }
mark.todo { background: var(--highlight); color: var(--ink); padding: 0 4px; border-radius: 3px; font-weight: 600; }

/* Small text buttons (e.g. "Select all" on the Cards page): enlarge the tap area to about 44px tall
   with padding, and cancel it with negative margin so nothing moves on screen. */
.link-btn { padding: 14px 8px; margin: -14px -8px; }

/* ---------- Review fixes (22 Nov 2026) ---------- */
/* Legal tables fit their column from tablet up; only phones scroll them sideways. The scroll box can
   take keyboard focus (tabindex in legal_text.py), so it gets a visible focus ring. */
.table-scroll:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
@media (max-width: 640px) { .legal-table { min-width: 560px; } }

/* Phones and touch screens: tap targets at least 44px tall. */
@media (max-width: 860px), (pointer: coarse) {
  .footer-cols li a { display: inline-flex; align-items: center; min-height: 44px; padding: 0; }
  .tog, .key-cards a { min-height: 44px; }
  .tog-row, .key-cards { gap: 8px; }
}

/* Phones: a smaller chat button, and room below the page so it never covers the last lines. */
@media (max-width: 640px) {
  .chat-launcher { width: 48px; height: 48px; }
  .site-footer { padding-bottom: 88px; }
}

/* Phones: deck names get the whole row; colour symbols and share sit on the line below. */
@media (max-width: 860px) {
  .arch summary {
    grid-template-columns: 64px auto minmax(0, 1fr) 24px;
    grid-template-areas: "art name name chev" "art colors share share";
  }
}
