/* =========================================================
   THE COOKIE JAR — shared design system
   warm analog editorial
   ========================================================= */

:root {
  /* paper & ink — luxury ivory base */
  --paper: #F5EFE2;
  --paper-deep: #ECE3CE;
  --paper-aged: #DDD0B5;
  --ink: #1A1210;
  --ink-soft: #2E2218;
  --ink-fade: #6B5840;

  /* accents — royal, maroon, olive, gold */
  --terracotta: #7A1535;       /* deep maroon — primary accent */
  --terracotta-deep: #560F25;  /* darker maroon */
  --olive: #4A5C30;            /* rich olive green */
  --plum: #1C3B74;             /* royal blue */
  --gold: #B8893A;             /* warm gold */

  /* type */
  --f-display: "Instrument Serif", "EB Garamond", Georgia, serif;
  --f-body: "Newsreader", "EB Garamond", Georgia, serif;
  --f-hand: "Caveat", "Bradley Hand", cursive;
  --f-mono: "JetBrains Mono", ui-monospace, monospace;

  /* density */
  --gutter: 4vw;
  --rule: 1px solid var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  font-family: var(--f-body);
  color: var(--ink);
  background: var(--paper);
  font-size: clamp(16px, 1vw + 0.65rem, 18px);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* paper texture — subtle SVG noise overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='5'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0 0.05  0 0 0 0.18 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* warm vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(60,40,20,0.18) 100%);
}

main, header, footer, nav, section { position: relative; z-index: 3; }

/* =========================================================
   Type
   ========================================================= */
h1, h2, h3, h4 {
  font-family: var(--f-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin: 0;
  text-wrap: balance;
  font-optical-sizing: auto;
}
/* Fluid headings — min size, viewport-relative preferred, max size */
h1 { font-size: clamp(48px, 9vw + 1rem, 200px); }
h2 { font-size: clamp(36px, 5vw + 0.5rem, 96px); }
h3 { font-size: clamp(24px, 2.5vw + 0.5rem, 44px); }

.italic { font-style: italic; }
.hand { font-family: var(--f-hand); font-weight: 500; }
.mono { font-family: var(--f-mono); font-size: clamp(10px, 0.7vw + 0.3rem, 13px); letter-spacing: 0.04em; text-transform: uppercase; }
.small-caps { text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.74em; }

p { text-wrap: pretty; margin: 0 0 1em; max-width: 62ch; line-height: 1.65; }
a { color: inherit; }
hr.rule {
  border: 0;
  border-top: var(--rule);
  margin: 2rem 0;
}

/* selection */
::selection { background: var(--terracotta); color: var(--paper); }

/* =========================================================
   Site chrome — top bar shared across pages
   ========================================================= */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--gutter);
  font-family: var(--f-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  background: linear-gradient(180deg, color-mix(in srgb, var(--paper) 95%, transparent) 60%, transparent);
  backdrop-filter: blur(8px);
}
.topbar .brand {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.01em;
  text-transform: none;
}
.topbar nav { display: flex; gap: 22px; }
.topbar nav a {
  text-decoration: none;
  color: var(--ink);
  position: relative;
  padding: 4px 0;
}
.topbar nav a:hover { color: var(--terracotta); }
.topbar nav a.active::after {
  content: "";
  position: absolute;
  left: -4px; right: -4px; bottom: -2px;
  height: 6px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 8' preserveAspectRatio='none'><path d='M2 5 Q 12 1 22 4 T 42 5 T 62 4 T 78 5' stroke='%23B7472A' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>") center/100% 100% no-repeat;
}

.topbar .meta {
  display: flex;
  gap: 22px;
  align-items: center;
}
.topbar .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--terracotta);
  display: inline-block;
  margin-right: 6px;
  animation: blink 2s infinite;
}
@keyframes blink { 0%,80%,100% { opacity: 1; } 90% { opacity: 0.2; } }

/* =========================================================
   Buttons & links
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--f-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
  border-radius: 999px;
}
.btn:hover { background: var(--ink); color: var(--paper); transform: translate(-1px,-1px); }
.btn.solid { background: var(--ink); color: var(--paper); }
.btn.solid:hover { background: var(--terracotta); border-color: var(--terracotta); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}
.link-arrow:hover { color: var(--terracotta); }

/* =========================================================
   Generic decoration
   ========================================================= */
.tape {
  position: absolute;
  width: 110px; height: 26px;
  background: rgba(184,137,60,0.42);
  border-left: 1px dashed rgba(0,0,0,0.18);
  border-right: 1px dashed rgba(0,0,0,0.18);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.stamp {
  display: inline-block;
  border: 2px solid var(--terracotta);
  color: var(--terracotta);
  padding: 4px 10px;
  font-family: var(--f-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  transform: rotate(-4deg);
  border-radius: 3px;
}
.scribble-underline {
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 8' preserveAspectRatio='none'><path d='M2 5 Q 16 1 30 4 T 60 5 T 98 4' stroke='%23B7472A' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>") 0 100%/100% 6px no-repeat;
  padding-bottom: 8px;
}

/* =========================================================
   Marquee
   ========================================================= */
.marquee {
  overflow: hidden;
  white-space: nowrap;
  border-top: var(--rule);
  border-bottom: var(--rule);
  padding: 14px 0;
  font-family: var(--f-display);
  font-style: italic;
  font-size: clamp(32px, 5vw, 64px);
}
.marquee-track {
  display: inline-block;
  animation: marquee 38s linear infinite;
  padding-left: 100%;
}
.marquee-track span { padding: 0 28px; }
.marquee-track .dot-sep {
  color: var(--terracotta);
  font-size: 0.8em;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

/* =========================================================
   Reveal-on-scroll
   ========================================================= */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(.2,.8,.2,1);
}
.reveal.in { opacity: 1; transform: translateY(0); }
.reveal.delay-1 { transition-delay: 0.1s; }
.reveal.delay-2 { transition-delay: 0.2s; }
.reveal.delay-3 { transition-delay: 0.3s; }
.reveal.delay-4 { transition-delay: 0.4s; }

/* =========================================================
   Cursor
   ========================================================= */
.cursor-dot {
  position: fixed;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--terracotta);
  pointer-events: none;
  z-index: 999;
  transform: translate(-50%, -50%);
  mix-blend-mode: multiply;
  transition: width 0.15s ease, height 0.15s ease, background 0.15s ease;
}
.cursor-ring {
  position: fixed;
  width: 36px; height: 36px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  pointer-events: none;
  z-index: 999;
  transform: translate(-50%, -50%);
  transition: transform 0.18s ease, width 0.18s ease, height 0.18s ease;
  mix-blend-mode: multiply;
}
@media (hover: none) { .cursor-dot, .cursor-ring { display: none; } }

/* =========================================================
   Footer
   ========================================================= */
.site-foot {
  margin-top: 8rem;
  padding: 3rem var(--gutter) 2rem;
  border-top: var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  flex-wrap: wrap;
  font-family: var(--f-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.site-foot .big {
  font-family: var(--f-display);
  font-style: italic;
  font-size: clamp(40px, 7vw, 110px);
  text-transform: none;
  letter-spacing: -0.01em;
  line-height: 0.95;
}

/* =========================================================
   Page hero shared
   ========================================================= */
.page-hero {
  padding: 22vh var(--gutter) 8vh;
  border-bottom: var(--rule);
  position: relative;
}
.page-hero .eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink-fade);
  margin-bottom: 1rem;
}
.page-hero h1 {
  font-style: italic;
}
.page-hero .lede {
  margin-top: 1.5rem;
  font-size: clamp(18px, 1.4vw, 22px);
  max-width: 56ch;
  color: var(--ink-soft);
}

/* =========================================================
   Density modifier (set by Tweaks)
   ========================================================= */
body[data-density="cozy"] { --gutter: 6vw; font-size: 19px; }
body[data-density="dense"] { --gutter: 3vw; font-size: 16px; }

body[data-palette="ink"] {
  --paper: #0E0A07;
  --paper-deep: #191410;
  --paper-aged: #24190F;
  --ink: #EEE5D4;
  --ink-soft: #D0C4A8;
  --ink-fade: #8A7860;
  --terracotta: #D44A6A;   /* lighter maroon on dark bg */
  --olive: #7A9450;        /* lighter olive on dark bg */
  --plum: #4A72C0;         /* lighter royal blue on dark bg */
  --gold: #E0B558;
}
body[data-palette="ink"]::before { mix-blend-mode: screen; opacity: 0.18; }
body[data-palette="ink"]::after { background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.5) 100%); }


body[data-font="serif"] {
  --f-display: "DM Serif Display", Georgia, serif;
}
body[data-font="garamond"] {
  --f-display: "EB Garamond", Georgia, serif;
}

/* =========================================================
   Back to top
   ========================================================= */
#btt {
  position: fixed;
  bottom: clamp(20px, 3vw, 32px);
  right: var(--gutter, 4vw);
  z-index: 200;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid transparent;
  cursor: pointer;
  display: grid; place-items: center;
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.35s ease, transform 0.35s ease,
              background 0.22s ease, border-color 0.22s ease;
  pointer-events: none;
}
#btt.vis { opacity: 1; transform: none; pointer-events: all; }
#btt:hover { background: var(--terracotta); border-color: var(--terracotta); }
#btt svg { width: 14px; height: 14px; flex-shrink: 0; }

/* =========================================================
   Loading splash (page-enter)
   ========================================================= */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
main { animation: pageIn 0.6s ease both; }
