/* CALM AGAIN — shared design system (sales page, reader, thank-you, legal pages).
   Arc: night → dawn → paper. Three voices: Instrument Serif (brand display),
   Instrument Sans (UI/text), EB Garamond (verbatim book text only). */

@font-face { font-family: "Instrument Serif"; src: url("../fonts/instrument-serif-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/instrument-serif-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("../fonts/eb-garamond-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("../fonts/eb-garamond-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
/* Metric-matched fallback so the hero headline does not reflow when the serif arrives */
@font-face { font-family: "Instrument Serif Fallback"; src: local("Georgia"), local("Times New Roman"); size-adjust: 88%; ascent-override: 98%; descent-override: 26%; }

:root {
  /* Palette: four colours plus alpha */
  --night: #0d1020;
  --ink: #17162a;
  --paper: #f2ebe4;          /* base after dawn; also the cream used on night */
  --page: #f7f2ec;           /* book sheets */
  --paper-deep: #e9e0d6;     /* footer band, open details */
  --dawn: #e09a80;           /* light only: glow, focus on dark, progress line */
  --cream: var(--paper);
  --muted: #66636d;          /* ink 64% on light */
  --cream-muted: rgba(242, 235, 228, .64);
  --hair: rgba(23, 22, 42, .12);
  --hair-dark: rgba(242, 235, 228, .16);
  --dusk: #2b2c4a;

  /* Type */
  --f-display: "Instrument Serif", "Instrument Serif Fallback", Georgia, serif;
  --f-text: "Instrument Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --f-book: "EB Garamond", Garamond, "Times New Roman", serif;
  --t-xs: .8125rem;
  --t-s: .9375rem;
  --t-m: clamp(1.0625rem, 1rem + .25vw, 1.125rem);
  --t-l: clamp(1.75rem, 1.45rem + 1.1vw, 2.25rem);
  --t-xl: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem);
  --t-xxl: clamp(3.25rem, 1.9rem + 6vw, 7.5rem);

  /* Space (4px base) */
  --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: clamp(96px, 12vw, 192px);
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1280px;

  /* Motion */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-inout: cubic-bezier(.65, 0, .35, 1);
  --header-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (max-width: 759px) { html { scroll-padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); } }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 var(--t-m)/1.6 var(--f-text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-synthesis: none; text-rendering: optimizeLegibility;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; }
p, h1, h2, h3, blockquote, figure, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 400; letter-spacing: -.015em; text-wrap: balance; }
em, i { font-style: italic; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.label { font: 500 var(--t-xs)/1.4 var(--f-text); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.on-night .label, .on-night.label { color: var(--cream-muted); }
.caps { text-transform: uppercase; letter-spacing: .04em; }
.book-voice { font-family: var(--f-book); font-kerning: normal; font-variant-ligatures: common-ligatures; }
.muted { color: var(--muted); }
.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; }

/* Focus: ink + page halo on light, dawn on dark */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; box-shadow: 0 0 0 5px var(--page); border-radius: 2px; }
.on-night :focus-visible, [data-surface="night"] :focus-visible { outline-color: var(--dawn); box-shadow: none; }

/* Skip link */
.skip { position: fixed; left: 12px; top: -80px; z-index: 100; padding: 12px 16px; background: var(--ink); color: var(--paper); font: 500 var(--t-s)/1 var(--f-text); text-decoration: none; transition: top .2s var(--ease-out); }
.skip:focus { top: 12px; }

/* Buttons: 2px radius, 52px tall (48 on phones), solid primary, text-link secondary */
.btn {
  --btn-bg: var(--ink); --btn-fg: var(--paper);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 24px; border: 0; border-radius: 2px;
  background: var(--btn-bg); color: var(--btn-fg);
  font: 500 var(--t-s)/1 var(--f-text); letter-spacing: .02em; text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: background-color .2s var(--ease-out), color .2s var(--ease-out), transform .12s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: color-mix(in srgb, var(--btn-bg) 92%, var(--btn-fg)); }
.btn:active { transform: scale(.98); }
.btn--light { --btn-bg: var(--paper); --btn-fg: var(--night); }
.btn--small { min-height: 40px; padding: 0 16px; font-size: .875rem; }
.btn .arr { display: inline-block; transition: transform .3s var(--ease-out); }
.btn:hover .arr { transform: translateX(3px); }
.btn[aria-busy="true"] { cursor: progress; }
.btn .btn-label { display: inline-grid; }
.btn .btn-label > * { grid-area: 1 / 1; }
@media (max-width: 599px) { .btn { min-height: 48px; } }

/* Text link with a horizon underline drawn from the left */
.tlink {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  background: none; border: 0; padding: 0; cursor: pointer;
  font: 500 var(--t-s)/1.3 var(--f-text); letter-spacing: .01em; color: inherit; text-decoration: none;
}
.tlink::after { content: ""; position: absolute; left: 0; right: 0; bottom: 10px; height: 1px; background: currentColor; opacity: .45; transform-origin: left; transition: opacity .3s var(--ease-out); }
.tlink::before { content: ""; position: absolute; left: 0; right: 0; bottom: 10px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease-out); }
.tlink:hover::before, .tlink:focus-visible::before { transform: scaleX(1); }

/* Logo */
.logo { color: currentColor; height: auto; overflow: visible; }

/* Header */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 40; height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  color: var(--paper); transition: background-color .4s var(--ease-out), color .4s var(--ease-out), opacity .4s var(--ease-out), border-color .4s;
  border-bottom: 1px solid transparent;
}
.site-header .wrap { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: var(--s-5); }
.site-header .brand { display: inline-flex; align-items: center; min-height: 44px; color: inherit; }
.site-header .logo-compact { width: 132px; }
.site-header nav { display: flex; align-items: center; gap: var(--s-5); }
.site-header.is-day { background: var(--paper); color: var(--ink); border-bottom-color: var(--hair); }
.site-header.is-night { background: rgba(13, 16, 32, .9); border-bottom-color: var(--hair-dark); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.site-header.is-hidden { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity .4s var(--ease-out), visibility 0s linear .4s; }
.site-header:not(.is-day) :focus-visible { outline-color: var(--dawn); box-shadow: none; }
.site-header .head-buy { transition: opacity .3s var(--ease-out), visibility .3s; }
.site-header .head-buy.is-off { display: none; }
.site-header:not(.is-day) .head-buy .btn { --btn-bg: var(--paper); --btn-fg: var(--night); }
@media (max-width: 759px) { .site-header nav { display: none; } }

/* Mobile sticky bar */
.sticky-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; display: none;
  padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--paper); color: var(--ink); border-top: 1px solid var(--hair);
  transition: transform .45s var(--ease-out), visibility .45s, background-color .4s, color .4s;
  transform: translateY(110%); visibility: hidden;
}
.sticky-bar.is-shown { transform: none; visibility: visible; }
.sticky-bar[data-surface="night"] { background: var(--night); color: var(--paper); border-top-color: var(--hair-dark); }
.sticky-bar[data-surface="night"] .btn { --btn-bg: var(--paper); --btn-fg: var(--night); }
.sticky-bar .row { display: flex; align-items: center; gap: var(--s-3); }
.sticky-bar .btn { flex: 1 1 auto; min-height: 48px; }
.sticky-bar .tlink { flex: 0 0 auto; }
@media (max-width: 759px) { .sticky-bar { display: block; } }

/* Toast (checkout status outside the offer) */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 90; width: min(560px, calc(100% - 32px));
  transform: translate(-50%, 16px); opacity: 0; visibility: hidden; pointer-events: none;
  padding: 16px 20px; background: var(--ink); color: var(--paper); border-radius: 2px;
  font: 400 var(--t-s)/1.5 var(--f-text); box-shadow: 0 20px 50px -20px rgba(13, 16, 32, .5);
  transition: opacity .3s var(--ease-out), transform .3s var(--ease-out), visibility .3s;
}
.toast.is-shown { opacity: 1; visibility: visible; transform: translate(-50%, 0); pointer-events: auto; }
.toast a { color: inherit; }

/* Footer */
.site-footer { background: var(--paper-deep); color: var(--ink); position: relative; z-index: 1; overflow: hidden; }
.site-footer .wrap { display: grid; gap: var(--s-6); padding-block: var(--s-9) calc(var(--s-8) + env(safe-area-inset-bottom, 0px)); }
.site-footer .logo-footer { width: 240px; }
.site-footer .mor { max-width: 62ch; color: var(--muted); font-size: var(--t-s); }
.site-footer .links { display: flex; flex-wrap: wrap; gap: 0 var(--s-5); }
.site-footer .links a { font: 500 var(--t-s)/1 var(--f-text); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.site-footer .links a:hover { text-decoration: underline; }
.site-footer .fine { color: var(--muted); font-size: var(--t-xs); line-height: 1.6; max-width: 72ch; }
.site-footer .fine + .fine { margin-top: calc(var(--s-5) * -1); }
@media (max-width: 759px) { .site-footer .wrap { padding-bottom: calc(var(--s-8) + 72px + env(safe-area-inset-bottom, 0px)); } }

/* Legal / simple pages */
.page-simple { padding-top: calc(var(--header-h) + var(--s-9)); }
.page-simple .site-header { background: var(--paper); color: var(--ink); border-bottom-color: var(--hair); }
.prose { max-width: 68ch; padding-bottom: var(--section); }
.prose h1 { font-size: var(--t-xl); line-height: 1.02; margin-bottom: var(--s-5); }
.prose h2 { font-size: var(--t-l); line-height: 1.2; margin: var(--s-7) 0 var(--s-4); }
.prose p, .prose li { margin-bottom: var(--s-4); }
.prose ul { list-style: disc; padding-left: 1.2em; }
.prose .note { padding: var(--s-4) var(--s-5); background: var(--paper-deep); border-left: 2px solid var(--ink); font-size: var(--t-s); }
.prose mark { background: color-mix(in srgb, var(--dawn) 35%, transparent); padding: 0 .2em; }

@media (prefers-reduced-motion: reduce) {
  .btn, .tlink::before, .site-header, .sticky-bar, .toast { transition-duration: .2s; }
  .btn:active { transform: none; }
}

/* Forced colours (Windows High Contrast) */
@media (forced-colors: active) {
  .btn { border: 1px solid ButtonText; }
  a.btn { border-color: LinkText; }
  .tlink { text-decoration: underline; }
  .tlink::before, .tlink::after { display: none; }
}
