/* Base tokens, themes and shared components.
   Brand colors come from docs/CONTRACT.md (see brand/palette.md). */

:root {
  color-scheme: light;
  --font-serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 16px;
  --radius: 14px;
  --radius-sm: 10px;
  --measure: 34rem;

  /* classic, light */
  --bg: #FAF5EA;
  --bg-2: #F4ECDA;
  --surface: #FFFDF8;
  --surface-2: #F3ECDC;
  --text: #1B1B1A;
  --muted: #595850;
  --line: #E0D5BC;
  --brand: #0F3B2E;
  --on-brand: #FAF5EA;
  --accent: #C9A24B;
  --accent-text: #73560F;
  --link: #0F3B2E;
  --danger: #A3232D;
  --focus: #0F3B2E;
  --shadow: 0 1px 2px rgba(27, 27, 26, .06), 0 8px 24px rgba(27, 27, 26, .07);
  --gift-box: #0F3B2E;
  --gift-lid: #165240;
  --gift-ribbon: #C9A24B;
  --gift-glow: rgba(201, 162, 75, .35);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #141412;
    --bg-2: #1A1A17;
    --surface: #1F1F1C;
    --surface-2: #292924;
    --text: #FAF5EA;
    --muted: #BDB8AA;
    --line: #3A3932;
    --brand: #1F6B53;
    --on-brand: #FAF5EA;
    --accent: #C9A24B;
    --accent-text: #E0C078;
    --link: #E0C078;
    --danger: #F2959B;
    --focus: #E0C078;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --gift-box: #1F6B53;
    --gift-lid: #267A60;
    --gift-ribbon: #C9A24B;
    --gift-glow: rgba(201, 162, 75, .3);
  }
}

/* Pro themes. Evergreen and midnight are dark by design in both settings. */
:root[data-theme="evergreen"] {
  color-scheme: dark;
  --bg: #0F3B2E;
  --bg-2: #0B2E24;
  --surface: #154839;
  --surface-2: #1B5644;
  --text: #FAF5EA;
  --muted: #C3D0C8;
  --line: #2A6451;
  --brand: #D4B164;
  --on-brand: #14251F;
  --accent: #D4B164;
  --accent-text: #E6CB8B;
  --link: #E6CB8B;
  --danger: #FFB1B6;
  --focus: #E6CB8B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .28);
  --gift-box: #FAF5EA;
  --gift-lid: #FFFFFF;
  --gift-ribbon: #C9A24B;
  --gift-glow: rgba(230, 203, 139, .35);
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0B1430;
  --bg-2: #080F26;
  --surface: #131F45;
  --surface-2: #1B2A5A;
  --text: #EEF1FA;
  --muted: #B3BCD9;
  --line: #2B3C73;
  --brand: #E3C77A;
  --on-brand: #101831;
  --accent: #E3C77A;
  --accent-text: #EBD597;
  --link: #EBD597;
  --danger: #FFB1B6;
  --focus: #EBD597;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
  --gift-box: #24367A;
  --gift-lid: #2E4391;
  --gift-ribbon: #E3C77A;
  --gift-glow: rgba(227, 199, 122, .35);
}

:root[data-theme="candycane"] {
  color-scheme: light;
  --bg: #FFF7F4;
  --bg-2: #FCEBE7;
  --surface: #FFFFFF;
  --surface-2: #FBEAE7;
  --text: #2A1215;
  --muted: #6A4A4D;
  --line: #EFCFCB;
  --brand: #A3232D;
  --on-brand: #FFFFFF;
  --accent: #A3232D;
  --accent-text: #8E1C26;
  --link: #8E1C26;
  --danger: #8E1C26;
  --focus: #8E1C26;
  --shadow: 0 1px 2px rgba(90, 20, 26, .06), 0 8px 24px rgba(90, 20, 26, .08);
  --gift-box: #A3232D;
  --gift-lid: #B8303A;
  --gift-ribbon: #FFFFFF;
  --gift-glow: rgba(163, 35, 45, .22);
}

:root[data-theme="gold"] {
  color-scheme: light;
  --bg: #FBF6E6;
  --bg-2: #F5EAC9;
  --surface: #FFFDF5;
  --surface-2: #F4E9C8;
  --text: #1B1B1A;
  --muted: #5C5440;
  --line: #E2D09A;
  --brand: #1B1B1A;
  --on-brand: #F3D98B;
  --accent: #C9A24B;
  --accent-text: #6E520D;
  --link: #6B4F0F;
  --danger: #A3232D;
  --focus: #1B1B1A;
  --shadow: 0 1px 2px rgba(60, 45, 5, .07), 0 8px 24px rgba(60, 45, 5, .09);
  --gift-box: #C9A24B;
  --gift-lid: #D9B765;
  --gift-ribbon: #1B1B1A;
  --gift-glow: rgba(201, 162, 75, .45);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="candycane"] {
    color-scheme: dark;
    --bg: #2A0E12;
    --bg-2: #210A0E;
    --surface: #3A151A;
    --surface-2: #4A1C22;
    --text: #FFF1EF;
    --muted: #E3BFBC;
    --line: #63292F;
    --brand: #FFF1EF;
    --on-brand: #7A1820;
    --accent: #FF9BA3;
    --accent-text: #FFB8BE;
    --link: #FFB8BE;
    --danger: #FFB8BE;
    --focus: #FFB8BE;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
    --gift-box: #FFF1EF;
    --gift-lid: #FFFFFF;
    --gift-ribbon: #C7303B;
    --gift-glow: rgba(255, 155, 163, .3);
  }

  :root[data-theme="gold"] {
    color-scheme: dark;
    --bg: #141310;
    --bg-2: #0F0E0B;
    --surface: #1F1D17;
    --surface-2: #2B281B;
    --text: #F7EFD9;
    --muted: #C2B99F;
    --line: #453E25;
    --brand: #C9A24B;
    --on-brand: #1B1B1A;
    --accent: #C9A24B;
    --accent-text: #E0C078;
    --link: #E0C078;
    --danger: #F2959B;
    --focus: #E0C078;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .4);
    --gift-box: #C9A24B;
    --gift-lid: #D9B765;
    --gift-ribbon: #1B1B1A;
    --gift-glow: rgba(201, 162, 75, .35);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.55;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.01em;
  margin: 0 0 .5em;
  text-wrap: balance;
}

h1 { font-size: clamp(1.9rem, 6vw + .5rem, 3.25rem); }
h2 { font-size: clamp(1.45rem, 3vw + .8rem, 2.1rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.25em; }
img, svg { max-width: 100%; }

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: .6rem 1rem;
  background: var(--brand);
  color: var(--on-brand);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: .5rem; }

.muted { color: var(--muted); }
.small { font-size: .9375rem; }

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--narrow { max-width: calc(var(--measure) + 2 * var(--gutter)); }

/* ---------- brand mark ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -.01em;
}
.brand__mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  flex: none;
  display: block;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 48px;
  padding: .7rem 1.4rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background-color .12s ease;
}
.btn:hover { opacity: .92; }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn--block { display: flex; width: 100%; }
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn--ghost:hover { background: var(--surface-2); opacity: 1; }
.btn--small { min-height: 44px; padding: .45rem 1rem; font-size: .9375rem; }
.btn--danger { color: var(--danger); }

/* ---------- forms ---------- */
.field { display: grid; gap: .35rem; margin-bottom: .9rem; }
.field label { font-weight: 600; font-size: .9375rem; }
.field .hint { color: var(--muted); font-size: .875rem; }
.input {
  width: 100%;
  min-height: 48px;
  padding: .65rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem; /* 16px: prevents iOS focus zoom */
}
textarea.input { min-height: 5.5rem; resize: vertical; }
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus-visible { outline-offset: 0; border-color: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }

.form-error {
  color: var(--danger);
  font-size: .9375rem;
  font-weight: 600;
  margin: 0 0 .8rem;
}

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* ---------- config placeholders (owner still has to supply) ---------- */
.cfg-missing {
  background: #FFE9A8;
  color: #3A2A00;
  border: 1px dashed #8A6A00;
  border-radius: 4px;
  padding: 0 .3em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85em;
  font-weight: 600;
  white-space: normal;
}

/* ---------- site footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.75rem 0 2.5rem;
  color: var(--muted);
  font-size: .9375rem;
}
.site-footer nav ul {
  list-style: none;
  padding: 0;
  margin: 0 0 .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
}
.site-footer a { color: var(--muted); display: inline-block; padding: .35rem 0; }
.site-footer p { margin: 0; }

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