/* Tablelight. Tokens, fonts, layout and components. Source of truth: DESIGN.md */

/* Fonts: self-hosted latin subsets (SIL OFL, see ../fonts/OFL-*.txt) */
@font-face { font-family: "Newsreader"; src: url("../fonts/newsreader-roman.woff2") format("woff2");
  font-style: normal; font-weight: 400; font-display: swap;
  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: "Newsreader"; src: url("../fonts/newsreader-italic.woff2") format("woff2");
  font-style: italic; font-weight: 400; font-display: swap;
  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: "Schibsted Grotesk"; src: url("../fonts/schibsted-grotesk.woff2") format("woff2");
  font-style: normal; font-weight: 400 600; font-display: swap;
  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; }

/* Metric-matched fallbacks (letter-frequency-weighted advance width, opsz 18, wght 400) */
@font-face { font-family: "Newsreader Fallback"; src: local("Georgia");
  size-adjust: 91.5%; ascent-override: 80.3%; descent-override: 29%; line-gap-override: 0%; }
@font-face { font-family: "Newsreader Fallback"; font-style: italic; src: local("Georgia Italic"), local("Georgia-Italic");
  size-adjust: 82.2%; ascent-override: 89.4%; descent-override: 32.2%; line-gap-override: 0%; }
@font-face { font-family: "Newsreader Fallback Android"; src: local("Noto Serif"), local("NotoSerif");
  size-adjust: 83.9%; ascent-override: 87.6%; descent-override: 31.6%; line-gap-override: 0%; }
@font-face { font-family: "Newsreader Fallback Android"; font-style: italic; src: local("Noto Serif Italic"), local("NotoSerif-Italic");
  size-adjust: 79.4%; ascent-override: 92.6%; descent-override: 33.4%; line-gap-override: 0%; }
@font-face { font-family: "Schibsted Fallback"; src: local("Arial"), local("ArialMT");
  size-adjust: 105.2%; ascent-override: 92.8%; descent-override: 24.5%; line-gap-override: 0%; }
@font-face { font-family: "Schibsted Fallback Android"; src: local("Roboto"), local("Roboto-Regular");
  size-adjust: 104.7%; ascent-override: 93.3%; descent-override: 24.6%; line-gap-override: 0%; }

/* Tokens */
:root {
  color-scheme: light dark;
  --paper:        #F5EFE3;
  --paper-deep:   #EEE6D6;
  --sheet:        #FCF9F2;
  --ink:          #1B1F27;
  --ink-soft:     #454B57;
  --ink-muted:    #565C68;
  --accent:       #234BA0;
  --accent-hover: #1B3C85;
  --on-accent:    #FCF9F2;
  --field-border: #7F7A6E;
  --rule:         rgb(27 31 39 / 0.16);
  --error:        #9E2A1C;
  --selection:    rgb(35 75 160 / 0.18);
  --shadow-sheet: 0 1px 0 rgb(27 31 39 / .05), 0 24px 48px -24px rgb(35 75 160 / .06);

  --font-serif: "Newsreader", "Newsreader Fallback", "Newsreader Fallback Android", Georgia, serif;
  --font-sans:  "Schibsted Grotesk", "Schibsted Fallback", "Schibsted Fallback Android", Arial, sans-serif;

  --fs-display:   clamp(2.5rem,   1.929rem + 2.857vw, 4.5rem);
  --fs-h2:        clamp(1.875rem, 1.536rem + 1.905vw, 3.25rem);
  --fs-statement: clamp(1.75rem,  1.504rem + 1.524vw, 2.875rem);
  --fs-h3:        clamp(1.375rem, 1.259rem + 0.476vw, 1.6875rem);
  --fs-lead:      clamp(1.125rem, 1.055rem + 0.286vw, 1.3125rem);
  --fs-body:      clamp(1.0625rem, 1.016rem + 0.19vw, 1.1875rem);
  --fs-ui:        1rem;
  --fs-small:     0.875rem;
  --fs-eyebrow:   0.75rem;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;
  --section-y: clamp(4.5rem, 2.8rem + 7vw, 9rem);
  --gutter:    clamp(1.25rem, 0.6rem + 2.8vw, 4rem);
  --container: 76rem;
  --radius:    2px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:  cubic-bezier(0.7, 0, 0.84, 0);
  --ease-std: cubic-bezier(0.32, 0.72, 0, 1);
  --d-fast: 160ms;  --d-mid: 320ms;  --d-exit: 200ms;  --d-slow: 800ms;  --d-hero: 1600ms;
  --stagger: 60ms;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper:        #15171C;
    --paper-deep:   #1C1F26;
    --sheet:        #1C1F26;
    --ink:          #EDE6D8;
    --ink-soft:     #C4BCAE;
    --ink-muted:    #A39C90;
    --accent:       #99B5F0;
    --accent-hover: #BBCFF6;
    --on-accent:    #15171C;
    --field-border: #7D786E;
    --rule:         rgb(237 230 216 / 0.16);
    --error:        #F0A08F;
    --selection:    rgb(153 181 240 / 0.25);
    --shadow-sheet: 0 0 0 1px var(--rule);
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { font-synthesis: none; font-optical-sizing: auto; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; hanging-punctuation: first; }
body {
  margin: 0; min-width: 320px;
  background: var(--paper); color: var(--ink);
  font-family: var(--font-serif); font-size: var(--fs-body); line-height: 1.6;
  font-variant-numeric: oldstyle-nums;
}
h1, h2, h3, p, ol, figure { margin: 0; }
h1, h2, h3, summary, strong, b { font-weight: 400; } /* Newsreader ships only at 400 */
[hidden] { display: none !important; }              /* no component rule may reveal a hidden element */
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); }
::selection { background: var(--selection); }
h1, h2, h3, .statement { text-wrap: balance; }
p, li { text-wrap: pretty; }
section { scroll-margin-top: 24px; }
[tabindex="-1"]:focus { outline: none; }

a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius);
}

/* Paper grain: fixed, never on a scrolling container */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: url("../img/grain-light.webp") repeat; background-size: 160px 160px; opacity: .5;
}
@media (prefers-color-scheme: dark) {
  body::after { background-image: url("../img/grain-dark.webp"); opacity: .35; }
}
@media print { body::after { display: none; } }

/* Type roles */
h1 { font-size: var(--fs-display); line-height: 1.1; letter-spacing: -0.02em; max-width: 9.5em; padding-bottom: .08em; }
h1 em { font-style: italic; }
h2 { font-size: var(--fs-h2); line-height: 1.1; letter-spacing: -0.015em; }
h3 { font-size: var(--fs-h3); line-height: 1.25; font-style: italic; }
.lead { font-size: var(--fs-lead); line-height: 1.5; }
.eyebrow {
  font: 600 var(--fs-eyebrow)/1.2 var(--font-sans); letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft); font-variant-numeric: lining-nums;
}
.field-error, .field-help, .footer {
  font: 400 var(--fs-small)/1.45 var(--font-sans); font-variant-numeric: lining-nums;
}

/* Layout */
.container { width: min(100% - 2 * var(--gutter), var(--container)); margin-inline: auto; }
.band { background: var(--paper-deep); }

/* Skip link */
.skip-link {
  position: absolute; top: 8px; left: 8px; z-index: 100;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  background: var(--accent); color: var(--on-accent); border-radius: var(--radius);
  font: 500 var(--fs-ui)/1.2 var(--font-sans); text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* Wordmark and mark */
.wordmark {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  font-family: var(--font-serif); font-size: 1.25rem; line-height: 1; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none;
}
.mark { width: 1em; height: 1em; flex: none; }
.mark circle { fill: var(--accent); }
.mark rect { fill: var(--ink); }

/* Masthead (not sticky) */
.masthead__inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.masthead__cta { display: none; }

/* Links */
.link { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.link--solo { display: inline-flex; align-items: center; min-height: 44px; }
button.link {
  appearance: none; background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; cursor: pointer;
  display: inline-flex; align-items: center; min-height: 44px;
}
@media (hover: hover) { .link:hover { text-decoration-thickness: 2px; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 56px; padding: 0 28px;
  font: 500 var(--fs-ui)/1.2 var(--font-sans); letter-spacing: 0.01em; font-variant-numeric: lining-nums;
  color: var(--on-accent); background: var(--accent); border: 0; border-radius: var(--radius);
  text-decoration: none; touch-action: manipulation; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--d-fast) var(--ease-std), transform 120ms var(--ease-std);
}
@media (hover: hover) { .btn:hover { background-color: var(--accent-hover); } }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[aria-busy="true"] { pointer-events: none; }

/* 1. Hero */
.hero__text { width: min(100% - 2 * var(--gutter), var(--container)); margin-inline: auto; padding-top: 28px; }
.hero__sub { margin-top: 16px; color: var(--ink); }
.hero .btn { margin-top: 28px; }
.hero__photo { margin-top: 32px; overflow: hidden; background: var(--paper-deep); }
.hero__photo img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 60%; }

/* 2. About */
.about { padding-block: var(--section-y); }
.about h2 { margin-bottom: 24px; }
.about p { max-width: 62ch; }
.about p + p { margin-top: 20px; }
@supports ((initial-letter: 3) or (-webkit-initial-letter: 3)) {
  .dropcap::first-letter { -webkit-initial-letter: 3; initial-letter: 3; margin-right: .08em; color: var(--accent); }
}
@supports not ((initial-letter: 3) or (-webkit-initial-letter: 3)) {
  .dropcap::first-letter { float: left; font-size: 3.4em; line-height: .8; margin: .06em .08em 0 0; color: var(--accent); }
}

/* 3. Interlude */
.interlude__photo { overflow: hidden; background: var(--paper-deep); }
.interlude__photo img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.statement {
  font-size: var(--fs-statement); line-height: 1.15; letter-spacing: -0.01em; font-style: italic;
  text-align: center; margin-inline: auto; padding: 72px 0 calc(72px + .08em);
}

/* 4. Details */
.details { padding-block: var(--section-y); }
.details__photo { margin-top: 32px; overflow: hidden; border-radius: var(--radius); background: var(--paper); }
.details__photo img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.details__body { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--rule); }
.entry + .entry { margin-top: 32px; }
.entry p { margin-top: 8px; color: var(--ink-soft); max-width: 62ch; }
.details__cta { margin-top: 40px; }

/* 5. Invitation */
.invite { padding-block: var(--section-y); }
.invite__intro h2 { margin-top: 16px; }
.invite__intro .lead { margin-top: 16px; }
.sheet { margin-top: 32px; padding: 24px; background: var(--sheet); border-radius: var(--radius); box-shadow: var(--shadow-sheet); }
.invite__steps { margin-top: 48px; }
.steps { list-style: none; padding: 0; margin-top: 24px; }
.steps li + li { margin-top: 32px; }
.steps li::before { content: ""; display: block; width: 24px; height: 2px; margin-bottom: 16px; background: var(--accent); }
.steps__title { color: var(--ink); }
.steps li p + p { color: var(--ink-soft); }

/* Form sheet states (6.2) */
.invite-fallback { color: var(--ink); }
html:not(.form-ready) .invite-form { display: none; }
.form-ready .invite-fallback       { display: none; }
.invite__stage { display: grid; }
.invite-form, .invite-done { grid-area: 1 / 1; }
.invite-form { transition: opacity var(--d-mid) var(--ease-out); }
.invite-done { align-self: start; opacity: 0; transform: translateY(8px); visibility: hidden; }
.is-done .invite-form { opacity: 0; transition: opacity var(--d-exit) var(--ease-in); }
.is-done .invite-done { opacity: 1; transform: none; visibility: visible;
  transition: opacity var(--d-mid) var(--ease-out), transform var(--d-mid) var(--ease-out); }
.is-done.is-settled .invite-form { visibility: hidden; }

/* Form fields */
.invite-form label[for="email"] { display: block; margin-bottom: 8px; font: 500 var(--fs-ui)/1.2 var(--font-sans); color: var(--ink); }
.invite-form input[type="email"] {
  display: block; width: 100%; height: 56px; padding: 0 16px; margin: 0;
  font: 400 var(--fs-ui) var(--font-sans); font-variant-numeric: lining-nums; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--field-border); border-radius: var(--radius);
  appearance: none; -webkit-appearance: none;
}
.invite-form input::placeholder { color: var(--ink-muted); opacity: 1; }
.invite-form input:focus-visible { border-color: var(--accent); }
.invite-form input:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: inset 0 0 0 100px var(--sheet); }
.invite-form input[aria-invalid="true"] { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }
.field-error { display: flex; align-items: flex-start; gap: 6px; color: var(--error); }
.field-error:not(:empty) { margin-top: 8px; animation: tl-fade 160ms var(--ease-out); }
.field-error svg { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.field-help { margin-top: 8px; color: var(--ink-muted); }
.invite-form .btn { margin-top: 20px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.invite-done__icon { display: block; width: 28px; height: 28px; color: var(--accent); }
.invite-done h3 { margin-top: 16px; }
.invite-done p { margin-top: 12px; }
.invite-done .link { margin-top: 8px; }
.done-email { font-family: var(--font-sans); font-size: .9em; font-weight: 600; font-variant-numeric: lining-nums; overflow-wrap: anywhere; }

/* 6. Questions */
.questions { padding-block: var(--section-y); }
.faq { margin-top: 32px; }
.faq__item { border-bottom: 1px solid var(--rule); }
.faq__item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 56px; padding-block: 16px; list-style: none; cursor: pointer;
  font-size: 1.25rem; line-height: 1.3; color: var(--ink); -webkit-tap-highlight-color: transparent;
}
.faq__item summary::-webkit-details-marker { display: none; }
.faq__q { transition: color var(--d-fast) var(--ease-std); }
@media (hover: hover) { .faq__item summary:hover .faq__q { color: var(--accent); } }
.faq__icon { position: relative; flex: none; width: 12px; height: 12px; }
.faq__icon::before, .faq__icon::after {
  content: ""; position: absolute; left: 0; top: 50%; width: 12px; height: 1.5px; margin-top: -0.75px; background: var(--accent);
}
.faq__icon::after { transform: rotate(90deg); transition: transform 240ms var(--ease-std); }
.faq__item[open] .faq__icon::after { transform: rotate(180deg); }
.faq__a { padding-bottom: 24px; color: var(--ink-soft); max-width: 62ch; }

/* 7. Footer */
.footer { border-top: 1px solid var(--rule); padding: 64px 0 calc(48px + env(safe-area-inset-bottom)); }
.footer__inner { display: grid; gap: 16px; }
.footer__tagline { margin-top: 4px; color: var(--ink-soft); }
.footer__legal { color: var(--ink-muted); }

/* md: 768 to 1023 keeps one column at a 38rem measure */
@media (min-width: 768px) {
  .btn { width: auto; min-width: 240px; white-space: nowrap; }
  .btn--block { width: 100%; }
  .hero__photo img { aspect-ratio: 1 / 1; object-position: 50% 40%; }
  .interlude__photo img { aspect-ratio: 1600 / 686; }
}
@media (min-width: 768px) and (max-width: 1023.98px) {
  .container, .hero__text { width: min(100% - 2 * var(--gutter), 38rem); }
}
/* Phones in landscape: the 1:1 hero photo sits in the 38rem measure instead of full bleed */
@media (min-width: 768px) and (max-width: 1023.98px) and (max-height: 540px) {
  .hero__photo { width: min(100% - 2 * var(--gutter), 38rem); margin-inline: auto; border-radius: var(--radius); }
}

/* lg: 12-column grid from 1024 */
@media (min-width: 1024px) {
  .wordmark { font-size: 1.375rem; }
  .masthead__inner { min-height: 72px; }
  .masthead__cta {
    display: inline-flex; align-items: center; min-height: 44px;
    font: 500 .9375rem/1.2 var(--font-sans); letter-spacing: 0.01em; text-underline-offset: 6px;
  }

  .grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; }

  .hero {
    display: grid;
    grid-template-columns: max(var(--gutter), (100% - var(--container)) / 2) minmax(0, 7fr) minmax(0, 5fr) max(var(--gutter), (100% - var(--container)) / 2);
    min-height: min(calc(100vh - 72px), 56rem);
    min-height: min(calc(100svh - 72px), 56rem);
  }
  .hero__text { grid-column: 2; grid-row: 1; align-self: center; width: auto; margin: 0; padding: 48px 48px 48px 0; }
  .hero__sub { max-width: 34ch; margin-top: 24px; }
  .hero .btn { margin-top: 40px; }
  /* Right-aligned frame, never wider than .94 x hero height, so >= 85% of the 4:5 photo height shows */
  .hero__photo {
    grid-column: 3 / 5; grid-row: 1; margin: 0; position: relative; justify-self: end; width: 100%;
    max-width: calc(min(100vh - 72px, 56rem) * .94);
    max-width: calc(min(100svh - 72px, 56rem) * .94);
  }
  .hero__photo img { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; }

  .about .grid12 > * { grid-column: 3 / 9; }
  .about h2 { margin-bottom: 32px; }

  .statement { max-width: 22ch; padding: 96px 0 calc(96px + .08em); }

  .details__grid { grid-template-rows: auto 1fr; row-gap: 48px; align-items: start; }
  .details__photo { grid-column: 1 / 6; grid-row: 1 / span 2; margin: 0; position: sticky; top: 96px; }
  .details__head { grid-column: 7 / 13; grid-row: 1; }
  .details__body { grid-column: 7 / 13; grid-row: 2; margin: 0; padding-top: 48px; }
  .entry + .entry { margin-top: 48px; }
  .details__cta { margin-top: 48px; }

  .invite__grid { grid-template-rows: auto 1fr; row-gap: 48px; }
  .invite__intro { grid-column: 1 / 6; grid-row: 1; }
  .invite__intro .lead { max-width: 34ch; }
  .invite__steps { grid-column: 1 / 6; grid-row: 2; align-self: start; margin: 0; }
  .sheet { grid-column: 7 / 13; grid-row: 1 / span 2; align-self: start; margin: 0; padding: 48px; }

  .questions .grid12 > * { grid-column: 3 / 11; }
  .faq { margin-top: 48px; }
  .faq__item summary { font-size: 1.375rem; }

  .footer__inner { grid-template-columns: 1fr auto; align-items: center; row-gap: 32px; column-gap: 24px; }
  .footer__contact { justify-self: end; }
  .footer__legal { grid-column: 1 / -1; }
}

/* Motion (3.6): transform and opacity only */
@keyframes tl-settle { from { transform: scale(1.04); } to { transform: none; } }
@keyframes tl-rise { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }
@keyframes tl-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .hero__photo img { animation: tl-settle var(--d-hero) var(--ease-out) both; }
  .hero__sub { animation: tl-rise 600ms var(--ease-out) 80ms both; }
  .hero .btn { animation: tl-rise 600ms var(--ease-out) 160ms both; }

  .js .reveal {
    opacity: 0; transform: translateY(16px);
    transition: opacity var(--d-slow) var(--ease-out), transform var(--d-slow) var(--ease-out);
    transition-delay: calc(var(--i, 0) * var(--stagger));
  }
  .js .reveal.is-in { opacity: 1; transform: none; }
  .js .develop { transform: scale(1.03); transition: transform 1200ms var(--ease-out); }
  .js .develop.is-in { transform: none; }
}

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