/* Shared foundation for every page: fonts, type scale, level-token mapping (palette.css), buttons, forms, dialogs.
   Pages set data-level="1..7" on <body>; components read only the mapped tokens (--bg, --ink, --soft, --card,
   --card-ink, --accent, --on-accent, --line, --control, --shadow, --glow). */

@font-face { font-family: "Gloock"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/gloock-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Gloock"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/gloock-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url("../fonts/figtree-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url("../fonts/figtree-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --font-display: "Gloock", "Iowan Old Style", Georgia, serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Type scale (px at default zoom): 12.5 label · 14.5 small · 17 body · 20 lede · 26 h3 · 34 h2 · 44–80 display */
  --t-label: 0.78rem; --t-small: 0.9rem; --t-body: 1.0625rem; --t-lede: 1.25rem;
  --t-h3: 1.625rem; --t-h2: clamp(2rem, 5vw, 2.6rem); --t-display: clamp(2.75rem, 7.4vw, 5rem);

  --radius-card: 26px; --radius-field: 14px; --radius-pill: 999px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));

  /* Level-1 defaults so a page without data-level still renders. */
  --bg: var(--l1-bg); --ink: var(--l1-ink); --soft: var(--l1-soft); --card: var(--l1-card); --card-ink: var(--l1-card-ink);
  --accent: var(--l1-accent); --on-accent: var(--l1-on); --line: var(--l1-line); --control: var(--l1-control);
  --shadow: var(--l1-shadow); --glow: .2;
}
/* palette.css maps the accent's text color as --on per level; re-derive --on-accent wherever a level is set. */
[data-level] { --on-accent: var(--on); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 1.1s ease, color 1.1s ease;
}
h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.05; text-wrap: balance; }
img, svg { max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

.label {
  font-size: var(--t-label); font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--soft);
}
.help { font-size: var(--t-small); color: var(--soft); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--gutter-l); top: -100px; z-index: 50;
  background: var(--card); color: var(--card-ink); padding: 10px 16px; border-radius: var(--radius-field);
}
.skip-link:focus { top: calc(env(safe-area-inset-top, 0px) + 8px); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Buttons */
.btn {
  font: inherit; font-weight: 700; font-size: 1rem; line-height: 1.2;
  min-height: 44px; padding: 12px 20px; border-radius: var(--radius-pill);
  border: 1.5px solid transparent; background: none; color: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease, opacity .2s ease;
}
.btn:hover { color: inherit; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
/* Hover lifts with a shadow, not a transform: moving the button would let it slip out from under the pointer and flicker. */
.btn.primary:hover:not(:disabled):not([aria-disabled="true"]) { box-shadow: 0 10px 22px -12px var(--shadow); }
.btn.ghost { border-color: var(--control); color: var(--ink); }
.btn.ghost:hover { background: var(--card); color: var(--card-ink); }
.btn.quiet { color: var(--soft); text-decoration: underline; text-underline-offset: 3px; padding-inline: 8px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn.big { width: 100%; min-height: 54px; padding: 16px 22px; font-size: 1.0625rem; }
.btn.small { min-height: 44px; padding: 8px 16px; font-size: .9rem; }

/* Fields */
.field { display: grid; gap: 6px; font-size: var(--t-small); font-weight: 600; color: var(--soft); }
.input {
  font: inherit; font-size: 1.0625rem; width: 100%; min-width: 0;
  color: var(--card-ink); background: var(--card);
  border: 1.5px solid var(--control); border-radius: var(--radius-field); padding: 12px 14px;
}
.input::placeholder { color: var(--soft); opacity: .9; }
.input:focus-visible { outline-offset: 2px; }

/* Dialogs (native <dialog>, opened with showModal so the page behind is inert) */
.kd-dialog {
  width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto;
  padding: 0; border: 0; border-radius: var(--radius-card);
  background: var(--card); color: var(--card-ink);
  box-shadow: 0 30px 70px -30px var(--shadow);
}
.kd-dialog::backdrop { background: color-mix(in srgb, var(--bg) 74%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.kd-dialog .inner { padding: 26px; display: grid; gap: 14px; }
.kd-dialog h2 { font-size: 2rem; line-height: 1.1; }
.kd-dialog .btn.ghost { color: var(--card-ink); }
.kd-dialog .stack { display: grid; gap: 10px; }
.kd-dialog .close { justify-self: end; margin: -10px -10px 0 0; }
.kd-dialog ul { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }
.kd-dialog .price { font-family: var(--font-display); font-size: 2.2rem; line-height: 1; }
.kd-dialog .price small { font-family: var(--font-body); font-size: var(--t-small); color: inherit; opacity: .8; margin-left: 6px; }
.kd-dialog .error { color: inherit; font-weight: 600; border-left: 3px solid var(--accent); padding-left: 10px; }
.kd-dialog .note { font-size: var(--t-small); opacity: .85; }

/* Toast */
.kd-toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--card); color: var(--card-ink); border: 1.5px solid var(--control);
  border-radius: var(--radius-pill); padding: 10px 18px; font-weight: 600; font-size: var(--t-small);
  box-shadow: 0 16px 40px -20px var(--shadow);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
