/* Shared styles: fonts, color tokens, base elements, panels, buttons, forms. */

/* ---------- Fonts (self-hosted, OFL; latin subset) ---------- */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/cormorant-garamond-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: "Cormorant Garamond";
  font-style: italic;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/cormorant-garamond-italic-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: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/hanken-grotesk-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: "Pinyon Script";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/pinyon-script-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;
}

/* Card fonts: designs pick pairings from these (see src/designs/options.rs).
   Browsers only download the ones a page uses. size-adjust evens out their widths
   against Cormorant (text) and Pinyon Script (display), so a design that fits in
   one pairing fits in the others. */
@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/eb-garamond-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: "EB Garamond";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/eb-garamond-italic-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: "Libre Caslon Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  size-adjust: 83%;
  src: url("../fonts/libre-caslon-text-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: "Libre Caslon Text";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  size-adjust: 83%;
  src: url("../fonts/libre-caslon-text-italic-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: "Bodoni Moda";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  size-adjust: 86%;
  src: url("../fonts/bodoni-moda-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: "Bodoni Moda";
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  size-adjust: 86%;
  src: url("../fonts/bodoni-moda-italic-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: Jost;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  size-adjust: 94%;
  src: url("../fonts/jost-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: Jost;
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  size-adjust: 94%;
  src: url("../fonts/jost-italic-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: Italianno;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  size-adjust: 133%;
  src: url("../fonts/italianno-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;
}

/* ---------- Tokens ---------- */
:root {
  /* App chrome: changes with the theme. */
  --bg: #E6DECF;
  --text: #23302A;
  --text-soft: #58635C;
  --surface: #FBF8F1;
  --rule: rgb(35 48 42 / .15);
  --btn: #2F4A3A;
  --btn-text: #FBF8F1;
  --link: #2F4A3A;
  --focus: #2F4A3A;
  --error: #8A2E3B;
  --choice-on: rgb(47 74 58 / .07);
  --vignette: rgb(70 50 25 / .10);
  --linen: rgb(70 50 25 / .022);

  /* Physical objects: paper stays paper in dark mode. */
  --object-shadow: 0 1px 2px rgb(60 40 20 / .10), 0 22px 44px -18px rgb(60 40 20 / .45);
  --envelope-paper: #F2ECDF;
  --card-paper: #FBF8F1;
  --card-ink: #23302A;
  --liner-a: #2F4A3A;
  --liner-b: #E9E1CF;

  --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-script: "Pinyon Script", "Snell Roundhand", "Apple Chancery", cursive;
  --ease-out: cubic-bezier(.22, .8, .24, 1);
  --ease-inout: cubic-bezier(.65, 0, .35, 1);

  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .25 0 0 0 0 .16 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1F1C;
    --text: #ECE6DA;
    --text-soft: #B4B8B0;
    --surface: #232A26;
    --rule: rgb(236 230 218 / .14);
    --btn: #DDE7DC;
    --btn-text: #1D3026;
    --link: #BCD5C2;
    --focus: #BCD5C2;
    --error: #F0A3AE;
    --choice-on: rgb(188 213 194 / .09);
    --vignette: rgb(0 0 0 / .35);
    --linen: rgb(255 255 255 / .018);
    --object-shadow: 0 1px 2px rgb(0 0 0 / .3), 0 26px 50px -18px rgb(0 0 0 / .75);
  }
}
:root[data-theme="dark"] {
  --bg: #1A1F1C;
  --text: #ECE6DA;
  --text-soft: #B4B8B0;
  --surface: #232A26;
  --rule: rgb(236 230 218 / .14);
  --btn: #DDE7DC;
  --btn-text: #1D3026;
  --link: #BCD5C2;
  --focus: #BCD5C2;
  --error: #F0A3AE;
  --choice-on: rgb(188 213 194 / .09);
  --vignette: rgb(0 0 0 / .35);
  --linen: rgb(255 255 255 / .018);
  --object-shadow: 0 1px 2px rgb(0 0 0 / .3), 0 26px 50px -18px rgb(0 0 0 / .75);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background-color: var(--bg);
  background-image:
    radial-gradient(130% 90% at 50% 35%, transparent 45%, var(--vignette)),
    repeating-linear-gradient(0deg, var(--linen) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, var(--linen) 0 1px, transparent 1px 4px),
    var(--noise);
  background-attachment: fixed;
  color: var(--text);
  font: 400 16px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: clamp(20px, 5.5vw, 32px);
}
.panel h1, .panel h2 { margin: 0 0 4px; font: 500 clamp(26px, 7vw, 32px)/1.15 var(--font-serif); letter-spacing: .005em; }
.panel p { margin: 10px 0 0; }
.panel-sub { color: var(--text-soft); font-size: 15px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 28px;
  font: 600 13px/1 var(--font-ui); letter-spacing: .14em; text-transform: uppercase;
  border: 0; border-radius: 999px; cursor: pointer;
  text-decoration: none;
  transition: transform 160ms var(--ease-out), opacity 300ms;
}
.btn:active { transform: scale(.98); }
.btn-primary { color: var(--btn-text); background: var(--btn); }
.btn-block { width: 100%; min-height: 52px; margin-top: 22px; }
.text-btn {
  font: inherit; color: var(--link); background: none; border: 0; padding: 0; min-height: 32px;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; cursor: pointer;
}

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-top: 18px; }
.field > span, .field > label { font-weight: 500; }
.field small { font-weight: 400; color: var(--text-soft); }
.field textarea {
  width: 100%; min-height: 96px; resize: vertical;
  font: 400 16px/1.5 var(--font-ui); color: var(--text);
  background: transparent; border: 1px solid var(--rule); border-radius: 4px; padding: 12px 14px;
}
.field-error { margin: 6px 0 0; color: var(--error); font-size: 15px; font-weight: 500; }
[aria-invalid="true"] { border-color: var(--error) !important; }
.form-alt { text-align: center; font-size: 15px; }

/* ---------- The card box (each design styles the inside) ---------- */
.card {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  container-type: inline-size;
  border-radius: 2px;
  background-color: var(--card-paper);
  background-image: linear-gradient(170deg, rgb(255 255 255 / .5), transparent 35%), var(--noise);
  box-shadow: var(--object-shadow);
  color: var(--card-ink);
}

/* ---------- Simple message pages (404, 500) ---------- */
.page-message { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.page-message .panel { max-width: 480px; }
.page-message p { color: var(--text-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
