/* ==========================================================================
   Karianne Mikalsen — base: tokens, typography, layout, header, footer, UI
   ========================================================================== */

:root {
  /* Palette — drawn from the two book covers */
  --midnight: #070c2e;
  --navy: #0e1650;
  --navy-2: #17246e;
  --ocean: #2753b3;
  --ocean-light: #6d93dc;
  --coral: #e5654f;
  --coral-deep: #c94c39;
  --sunset: #f2a06b;
  --sage: #a3c9a5;
  --sage-deep: #56875f;
  --sage-soft: #e8f2e7;
  --paper: #fbf9f5;
  --mist: #eef3fa;
  --white: #ffffff;
  --ink: #121838;
  --text: #3b4262;
  --muted: #6c7391;
  --line: rgba(18, 24, 56, 0.1);
  --line-light: rgba(255, 255, 255, 0.14);

  --serif: "Cormorant Garamond", "Cormorant", Georgia, "Times New Roman", serif;
  --sans: "Manrope", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;

  --container: 1240px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --section: clamp(3.25rem, 6.5vw, 5.5rem);
  --radius: 18px;
  --ease: cubic-bezier(0.2, 0.75, 0.2, 1);
  --shadow-soft: 0 24px 60px -28px rgba(7, 12, 46, 0.35);
  --shadow-book: 0 40px 70px -30px rgba(7, 12, 46, 0.65), 0 12px 24px -12px rgba(7, 12, 46, 0.4);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-family: var(--serif); font-weight: 500; line-height: 1.08; letter-spacing: -0.01em; }
p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }
ul { margin: 0; padding: 0; list-style: none; }
code { font-size: 0.85em; padding: 0.1em 0.4em; border-radius: 6px; background: rgba(229, 101, 79, 0.12); color: var(--coral-deep); }
::selection { background: var(--coral); color: #fff; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; border-radius: 4px; }
html.menu-open { overflow: hidden; }

.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; top: -60px; left: 1rem; z-index: 200; padding: 0.7rem 1.1rem; background: var(--coral); color: #fff; border-radius: 10px; transition: top 0.3s; }
.skip-link:focus { top: 1rem; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.container--narrow { max-width: 880px; }

/* ---------- Type ---------- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.8rem;
  margin: 0 0 1.4rem;
  font-family: var(--sans); font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.24em; text-transform: uppercase; color: var(--coral);
}
.eyebrow::before { content: ""; width: 34px; height: 1px; background: currentColor; opacity: 0.8; }
.eyebrow--sage { color: var(--sage); }
.eyebrow--ocean { color: var(--ocean); }
.eyebrow--center { justify-content: center; }
.eyebrow--center::after { content: ""; width: 34px; height: 1px; background: currentColor; opacity: 0.8; }

.h1 { font-size: clamp(3rem, 7.5vw, 6.6rem); font-weight: 500; line-height: 0.98; }
.h2 { font-size: clamp(2.3rem, 4.8vw, 3.9rem); }
.h3 { font-size: clamp(1.7rem, 2.6vw, 2.25rem); }
.h1 em, .h2 em, .h3 em { font-style: italic; color: var(--coral); }
.lead { font-size: clamp(1.1rem, 1.5vw, 1.25rem); line-height: 1.75; color: var(--text); max-width: 38em; }
.muted { color: var(--muted); }
.text-center { text-align: center; }
.text-center .lead { margin-left: auto; margin-right: auto; }

.on-dark { color: rgba(255, 255, 255, 0.78); }
.on-dark h1, .on-dark h2, .on-dark h3, .on-dark h4 { color: #fff; }
.on-dark .lead { color: rgba(255, 255, 255, 0.8); }
.on-dark .h1 em, .on-dark .h2 em, .on-dark .h3 em { color: var(--sunset); }

/* ---------- Buttons ---------- */
.btn {
  --bg: var(--navy); --fg: #fff; --bd: transparent;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.7rem;
  padding: 1rem 1.75rem; border-radius: 999px; border: 1px solid var(--bd);
  background: var(--bg); color: var(--fg);
  font-family: var(--sans); font-size: 0.9rem; font-weight: 600; letter-spacing: 0.03em; line-height: 1;
  white-space: nowrap; overflow: hidden; isolation: isolate;
  transition: transform 0.45s var(--ease), box-shadow 0.45s var(--ease), background-color 0.3s, color 0.3s, border-color 0.3s;
}
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.28) 50%, transparent 80%);
  transform: translateX(-120%); transition: transform 0.9s var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:hover::before { transform: translateX(120%); }
.btn:active { transform: translateY(0); }
.btn__icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.4s var(--ease); }
.btn:hover .btn__icon { transform: translateX(4px); }

.btn--coral { --bg: var(--coral); box-shadow: 0 14px 30px -14px rgba(229, 101, 79, 0.75); }
.btn--coral:hover { --bg: var(--coral-deep); box-shadow: 0 20px 38px -16px rgba(229, 101, 79, 0.85); }
.btn--navy { --bg: var(--navy); box-shadow: 0 14px 30px -16px rgba(14, 22, 80, 0.7); }
.btn--navy:hover { --bg: var(--navy-2); }
.btn--ghost { --bg: transparent; --fg: var(--navy); --bd: rgba(14, 22, 80, 0.28); }
.btn--ghost:hover { --bg: var(--navy); --fg: #fff; --bd: var(--navy); }
.btn--ghost-light { --bg: rgba(255, 255, 255, 0.04); --fg: #fff; --bd: rgba(255, 255, 255, 0.4); backdrop-filter: blur(6px); }
.btn--ghost-light:hover { --bg: #fff; --fg: var(--navy); --bd: #fff; }
.btn--sm { padding: 0.75rem 1.25rem; font-size: 0.82rem; }
.btn.is-loading { pointer-events: none; opacity: 0.75; }

.link-arrow {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-weight: 600; font-size: 0.92rem; color: var(--navy);
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  padding-bottom: 3px; transition: background-size 0.45s var(--ease), color 0.3s;
}
.link-arrow::after { content: "→"; transition: transform 0.4s var(--ease); }
.link-arrow:hover { background-size: 100% 1px; color: var(--coral-deep); }
.link-arrow:hover::after { transform: translateX(4px); }
.on-dark .link-arrow { color: #fff; }
.on-dark .link-arrow:hover { color: var(--sunset); }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: center; }
.purchase-note { margin: 0.9rem 0 0; font-size: 0.78rem; color: var(--muted); }
.on-dark .purchase-note { color: rgba(255, 255, 255, 0.55); }
.on-dark .purchase-note code { background: rgba(242, 160, 107, 0.16); color: var(--sunset); }

/* Theme chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.95rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em;
  background: var(--sage-soft); color: var(--sage-deep); border: 1px solid rgba(86, 135, 95, 0.18);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.on-dark .chip { background: rgba(163, 201, 165, 0.1); color: var(--sage); border-color: rgba(163, 201, 165, 0.22); }

/* ---------- Scroll progress ---------- */
.scroll-progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 120; pointer-events: none; }
.scroll-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--coral), var(--sunset)); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 100;
  color: #fff;
  transition: background-color 0.45s var(--ease), box-shadow 0.45s var(--ease), color 0.3s;
}
.site-header__inner { display: flex; align-items: center; justify-content: space-between; height: 88px; transition: height 0.45s var(--ease); }
.site-header.is-scrolled {
  color: var(--ink);
  background: rgba(251, 249, 245, 0.9);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: 0 1px 0 var(--line), 0 18px 40px -30px rgba(7, 12, 46, 0.4);
}
.site-header.is-scrolled .site-header__inner { height: 70px; }

.brand { display: inline-flex; flex-direction: column; line-height: 1; gap: 0.3rem; }
.brand__name { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; letter-spacing: 0.01em; }
.brand__role { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.42em; text-transform: uppercase; color: var(--sage); }
.site-header.is-scrolled .brand__role { color: var(--sage-deep); }

.primary-nav { display: flex; align-items: center; gap: 2.4rem; }
.primary-nav__list { display: flex; gap: 2.1rem; }
.primary-nav__link { position: relative; font-size: 0.9rem; font-weight: 500; letter-spacing: 0.03em; padding: 0.4rem 0; opacity: 0.88; transition: opacity 0.3s; }
.primary-nav__link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1.5px;
  background: var(--coral); transform: scaleX(0); transform-origin: right; transition: transform 0.45s var(--ease);
}
.primary-nav__link:hover, .primary-nav__link.is-active { opacity: 1; }
.primary-nav__link:hover::after, .primary-nav__link.is-active::after { transform: scaleX(1); transform-origin: left; }

.menu-toggle { display: none; position: relative; width: 46px; height: 46px; border: 1px solid currentColor; border-radius: 50%; background: transparent; color: inherit; z-index: 102; }
.menu-toggle__bar { position: absolute; left: 13px; right: 13px; height: 1.5px; background: currentColor; transition: transform 0.45s var(--ease), top 0.45s var(--ease); }
.menu-toggle__bar:nth-of-type(2) { top: 19px; }
.menu-toggle__bar:nth-of-type(3) { top: 26px; }
.menu-open .menu-toggle { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.menu-open .menu-toggle__bar:nth-of-type(2) { top: 22px; transform: rotate(45deg); }
.menu-open .menu-toggle__bar:nth-of-type(3) { top: 22px; transform: rotate(-45deg); }
.menu-open .site-header { background: transparent; box-shadow: none; color: #fff; }
.menu-open .site-header .brand__role { color: var(--sage); }

/* ---------- Mobile menu ---------- */
.mobile-menu {
  position: fixed; inset: 0; z-index: 99; overflow-y: auto;
  background: radial-gradient(120% 70% at 100% 100%, rgba(229, 101, 79, 0.28), transparent 60%),
              linear-gradient(170deg, var(--midnight), var(--navy) 70%);
  color: #fff;
  clip-path: circle(0% at calc(100% - 45px) 44px);
  transition: clip-path 0.6s var(--ease);
}
.mobile-menu.is-open { clip-path: circle(150% at calc(100% - 45px) 44px); }
.mobile-menu__inner { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 110px var(--gutter) 3rem; gap: 2.4rem; }
.mobile-menu__list li { opacity: 0; transform: translateY(18px); transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); transition-delay: calc(0.12s + var(--i) * 0.06s); }
.mobile-menu.is-open .mobile-menu__list li { opacity: 1; transform: none; }
.mobile-menu__list a { display: block; padding: 0.35rem 0; font-family: var(--serif); font-size: clamp(2.4rem, 10vw, 3.4rem); line-height: 1.1; }
.mobile-menu__list a[aria-current="page"] { font-style: italic; color: var(--sunset); }
.mobile-menu__books { display: grid; gap: 0.8rem; padding-top: 1.6rem; border-top: 1px solid var(--line-light); }
.mobile-menu__book { display: flex; align-items: center; gap: 1rem; font-family: var(--serif); font-size: 1.25rem; }
.mobile-menu__book img { width: 44px; height: auto; border-radius: 2px; box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.6); }
.mobile-menu__book small { display: block; font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255, 255, 255, 0.55); }
.mobile-menu__cta { align-self: flex-start; }

@media (max-width: 960px) {
  .primary-nav { display: none; }
  .menu-toggle { display: block; }
  .site-header__inner { height: 76px; }
}

/* ---------- Sections ---------- */
.section { position: relative; padding: var(--section) 0; }
.section--paper { background: var(--paper); }
.section--white { background: var(--white); }
.section--mist { background: linear-gradient(180deg, var(--mist), #f6f8fc); }
.section--dark { background: var(--midnight); color: rgba(255, 255, 255, 0.78); }
.section--navy { background: linear-gradient(160deg, var(--navy) 0%, var(--midnight) 100%); color: rgba(255, 255, 255, 0.78); }
.section-head { max-width: 760px; margin-bottom: clamp(2rem, 4vw, 3.2rem); }
.section-head.text-center { margin-left: auto; margin-right: auto; }
.section-head .lead { margin-top: 1.4rem; }

/* Decorative horizon line */
.horizon-rule { width: 120px; height: 2px; margin: 2rem 0; border: 0; background: linear-gradient(90deg, var(--coral), var(--sunset) 60%, transparent); }
.text-center .horizon-rule { margin-left: auto; margin-right: auto; background: linear-gradient(90deg, transparent, var(--coral), var(--sunset), transparent); }

/* ---------- 3D book mockup ---------- */
.book3d-wrap { --w: 300px; position: relative; width: var(--w); perspective: 1800px; }
.book3d {
  --t: calc(var(--w) * 0.075);
  --ry: -22deg; --rx: 0deg;
  position: relative; width: 100%; aspect-ratio: 753 / 1147;
  transform-style: preserve-3d;
  transform: rotateY(var(--ry)) rotateX(var(--rx));
  transition: transform 0.9s var(--ease);
}
.book3d__cover, .book3d__back { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 2px 5px 5px 2px; }
.book3d__cover { object-fit: cover; transform: translateZ(calc(var(--t) / 2)); box-shadow: var(--shadow-book); }
.book3d__cover-shine {
  position: absolute; inset: 0; pointer-events: none; border-radius: 2px 5px 5px 2px;
  transform: translateZ(calc(var(--t) / 2 + 0.5px));
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.28) 0, rgba(255, 255, 255, 0.18) 1.6%, rgba(0, 0, 0, 0.12) 3.2%, transparent 6%),
              linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.1) 55%, transparent 70%);
}
.book3d__back { background: var(--midnight); transform: translateZ(calc(var(--t) / -2)); box-shadow: -18px 30px 50px -20px rgba(7, 12, 46, 0.55); }
.book3d__pages {
  position: absolute; top: 1.2%; bottom: 1.2%; right: calc(var(--t) / -2 + 3px); width: var(--t);
  transform: rotateY(90deg);
  background: repeating-linear-gradient(90deg, #fbfaf6 0 2px, #e4e0d6 2px 3px);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.12);
}
.book3d-wrap::after {
  content: ""; position: absolute; left: 8%; right: -6%; bottom: -26px; height: 36px; z-index: -1;
  background: radial-gradient(50% 50% at 50% 50%, rgba(7, 12, 46, 0.45), transparent 70%);
  filter: blur(6px); transition: transform 0.9s var(--ease);
}
.on-dark .book3d-wrap::after { background: radial-gradient(50% 50% at 50% 50%, rgba(0, 0, 0, 0.7), transparent 70%); }
[data-tilt]:hover .book3d { transition-duration: 0.25s; }
.book3d--float { animation: book-float 7s ease-in-out infinite; }
@keyframes book-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -12px; }
}

/* Flat cover */
.cover-flat { position: relative; border-radius: 3px 6px 6px 3px; overflow: hidden; box-shadow: var(--shadow-book); }
.cover-flat::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0, 0.25), rgba(255, 255, 255, 0.14) 2%, transparent 5%); }

/* ---------- Reveal animations ---------- */
.js .reveal { opacity: 0; transform: translate3d(0, 34px, 0); transition: opacity 1s var(--ease), transform 1.1s var(--ease); transition-delay: var(--d, 0ms); }
.js .reveal--left { transform: translate3d(-40px, 0, 0); }
.js .reveal--right { transform: translate3d(40px, 0, 0); }
.js .reveal--scale { transform: scale(0.94); }
.js .reveal.is-visible { opacity: 1; transform: none; }
.js .reveal-stagger > * { opacity: 0; transform: translate3d(0, 24px, 0); transition: opacity 0.8s var(--ease), transform 0.9s var(--ease); }
.js .reveal-stagger.is-visible > * { opacity: 1; transform: none; }
.reveal-stagger > *:nth-child(2) { transition-delay: 0.08s; }
.reveal-stagger > *:nth-child(3) { transition-delay: 0.16s; }
.reveal-stagger > *:nth-child(4) { transition-delay: 0.24s; }
.reveal-stagger > *:nth-child(5) { transition-delay: 0.32s; }
.reveal-stagger > *:nth-child(6) { transition-delay: 0.4s; }
.reveal-stagger > *:nth-child(7) { transition-delay: 0.48s; }

.split-word { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.12em; margin-bottom: -0.12em; }
.split-word > span { display: inline-block; }
.js [data-split] .split-word > span { transform: translate3d(0, 110%, 0); transition: transform 1.1s var(--ease); transition-delay: calc(var(--w) * 75ms + var(--d, 0ms)); }
.js [data-split].is-visible .split-word > span { transform: none; }

/* ---------- Footer ---------- */
.site-footer { position: relative; overflow: hidden; background: var(--midnight); color: rgba(255, 255, 255, 0.66); font-size: 0.95rem; }
.site-footer__glow { position: absolute; inset: -40% -10% auto; height: 520px; pointer-events: none; background: radial-gradient(40% 60% at 20% 60%, rgba(39, 83, 179, 0.35), transparent 70%), radial-gradient(35% 50% at 85% 70%, rgba(229, 101, 79, 0.18), transparent 70%); }
.site-footer .container { position: relative; }
.site-footer__cta { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 2rem; padding: clamp(2.75rem, 5vw, 4rem) 0 clamp(2.25rem, 4vw, 3rem); border-bottom: 1px solid var(--line-light); }
.site-footer__cta .eyebrow { margin-bottom: 1rem; }
.site-footer__cta-title { font-size: clamp(2.4rem, 5vw, 4rem); color: #fff; font-style: italic; }
.site-footer__cta-actions { display: flex; flex-wrap: wrap; gap: 0.9rem; }
.site-footer__grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 2.5rem; padding: 2.75rem 0 2.5rem; }
.site-footer__brand .brand { color: #fff; }
.site-footer__tagline { margin-top: 1.2rem; max-width: 22em; font-family: var(--serif); font-size: 1.25rem; font-style: italic; line-height: 1.4; color: rgba(255, 255, 255, 0.72); }
.site-footer__heading { margin-bottom: 1.1rem; font-family: var(--sans); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: var(--sage); }
.site-footer__col li + li { margin-top: 0.55rem; }
.site-footer__col a { transition: color 0.3s; }
.site-footer__col a:hover { color: #fff; }
.site-footer__muted { color: rgba(255, 255, 255, 0.45); font-size: 0.88rem; }
.site-footer__bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; padding: 1.3rem 0 1.5rem; border-top: 1px solid var(--line-light); font-size: 0.82rem; color: rgba(255, 255, 255, 0.45); }
.site-footer__bottom p { margin: 0; }
.back-to-top { transition: color 0.3s; }
.back-to-top:hover { color: var(--sunset); }
@media (max-width: 860px) {
  .site-footer__grid { grid-template-columns: 1fr 1fr; }
  .site-footer__brand { grid-column: 1 / -1; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 150;
  width: min(92vw, 460px); padding: 1rem 1.3rem; border-radius: 14px;
  background: var(--navy); color: rgba(255, 255, 255, 0.85); font-size: 0.9rem; line-height: 1.55;
  border-left: 3px solid var(--coral); box-shadow: 0 24px 50px -20px rgba(7, 12, 46, 0.6);
  transform: translate(-50%, 30px); opacity: 0; transition: transform 0.45s var(--ease), opacity 0.45s var(--ease);
}
.toast strong { color: #fff; }
.toast code { background: rgba(255, 255, 255, 0.1); color: var(--sunset); }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

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