/* ------------------------------------------------------------------
   Ceyda — base: tokens, type, paper primitives, reveal, red string
   ------------------------------------------------------------------ */
:root {
  --sky-top: #8ec5ff;
  --sky-mid: #bfe0ff;
  --sky-haze: #eaf4ff;
  --paper: #fbf6ea;
  --paper-2: #f3ecd9;
  --paper-3: #ebe2cb;
  --ink: #1f2a3a;
  --ink-2: #5b6676;
  --ink-3: #8c95a3;
  --string: #d7263d;
  --string-light: #ff8a96;
  --string-dark: #7a1020;
  --gold: #e0b457;
  --lis: #35c4f2;
  --night: #06091a;
  --nebula: #2b1a4a;
  --her: #dff1ff;
  --his: #ffe7ea;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --font-body: "Source Serif 4", "Iowan Old Style", Georgia, serif;

  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --measure: 36ch;
  --gutter: 20px;
}

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

html {
  background: var(--sky-top);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;
  overflow-x: hidden;                  /* no sideways panning on phones */
}
html[data-theme="night"] { background: #000; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.22rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  position: relative;
  touch-action: pan-y pinch-zoom;      /* vertical panning only, like an app */
  -webkit-tap-highlight-color: transparent;
}
body.is-locked { overflow: hidden; height: 100dvh; }

img, picture, svg, canvas { display: block; max-width: 100%; }
img { height: auto; }
figure { margin: 0; }
p { margin: 0 0 1em; }
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: inherit; }
button, input { font: inherit; }

::selection { background: rgba(215, 38, 61, 0.18); }

/* ---------- type helpers ---------- */
.display, h1, h2, h3 {
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-optical-sizing: auto;
  letter-spacing: -0.012em;
  line-height: 1.05;
}
.hand, .note, figcaption, .kicker {
  font-family: var(--font-hand);
  font-weight: 500;
  line-height: 1.15;
}
.kicker { font-size: 1.35rem; color: var(--string); letter-spacing: 0.01em; margin: 0 0 0.35em; }
.note { font-size: 1.4rem; color: var(--ink-2); }
.note--red { color: var(--string); }
h2 { font-size: clamp(2.3rem, 1.5rem + 3.4vw, 4.2rem); margin: 0 0 0.5em; }
h3 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem); margin: 0 0 0.5em; }
.prose { max-width: var(--measure); }
.prose p + p { margin-top: 0.2em; }
.prose em { font-style: italic; }
.prose strong { font-weight: 600; }
.quiet { color: var(--ink-2); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.wrap { width: min(100% - 2 * var(--gutter), 1040px); margin-inline: auto; }
.wrap--narrow { width: min(100% - 2 * var(--gutter), 720px); margin-inline: auto; }
.sec { position: relative; padding-block: clamp(72px, 12vh, 140px); overflow-x: clip; }   /* glows, orbits, tilted photos never widen the page */
.sec--paper { background: var(--paper); }
.sec--paper-2 { background: var(--paper-2); }

/* ---------- paper grain (a tiny generated noise tile, see main.js) ---------- */
.grain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  pointer-events: none;
  opacity: 0.07;
  z-index: 40;
  background-repeat: repeat;
  background-size: 160px 160px;
}

/* ---------- torn paper edges ---------- */
.torn-top, .torn-bottom { position: relative; }
.torn-top::before, .torn-bottom::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 26px;
  background: inherit;
  pointer-events: none;
}
.torn-top::before {
  top: -25px;
  clip-path: polygon(0 100%, 0 62%, 3% 48%, 5% 70%, 8% 40%, 11% 66%, 14% 52%, 17% 74%, 20% 44%, 23% 60%, 26% 36%, 29% 68%, 33% 50%, 36% 72%, 39% 42%, 42% 64%, 45% 54%, 48% 76%, 51% 40%, 54% 58%, 57% 34%, 60% 66%, 64% 48%, 67% 70%, 70% 44%, 73% 62%, 76% 52%, 79% 74%, 82% 38%, 85% 60%, 88% 46%, 91% 68%, 94% 42%, 97% 64%, 100% 50%, 100% 100%);
}
.torn-bottom::after {
  bottom: -25px;
  clip-path: polygon(0 0, 100% 0, 100% 40%, 97% 56%, 94% 30%, 91% 62%, 88% 44%, 85% 66%, 82% 36%, 79% 58%, 76% 28%, 73% 60%, 70% 46%, 67% 68%, 64% 34%, 60% 56%, 57% 42%, 54% 70%, 51% 32%, 48% 58%, 45% 26%, 42% 62%, 39% 48%, 36% 66%, 33% 38%, 29% 60%, 26% 30%, 23% 64%, 20% 44%, 17% 68%, 14% 36%, 11% 58%, 8% 28%, 5% 62%, 3% 46%, 0 56%);
}

/* ---------- polaroids & tape ---------- */
.slot { position: relative; }           /* un-transformed anchor for the string */
.polaroid {
  --tilt: 0deg;
  position: relative;
  background: #fff;
  padding: 10px 10px 12px;
  box-shadow:
    0 1px 1px rgba(20, 30, 50, 0.06),
    0 2px 6px rgba(20, 30, 50, 0.08),
    0 18px 36px -16px rgba(20, 30, 50, 0.38);
  border-radius: 2px;
}
.polaroid:not([data-reveal]) { transform: rotate(var(--tilt)); }
.polaroid > picture, .polaroid > img, .polaroid > .ph { background: var(--paper-3); }
.polaroid img { width: 100%; height: auto; }
.polaroid--square img { aspect-ratio: 1; object-fit: cover; }
.polaroid figcaption {
  margin: 12px 2px 2px;
  min-height: 1.15em;
  font-size: 1.25rem;
  color: var(--ink-2);
  text-align: center;
  line-height: 1.1;
}
.polaroid--dark { background: #1a1f2b; }
.polaroid--dark figcaption { color: #cfd6e2; }
.polaroid--gold { background: linear-gradient(160deg, #fff7df, #f4e3b3); box-shadow: 0 2px 6px rgba(120, 90, 20, 0.15), 0 18px 36px -16px rgba(120, 90, 20, 0.45); }
.polaroid--gold figcaption { color: #8a6a1c; }

.tape {
  position: absolute;
  top: -13px;
  left: 50%;
  width: 96px;
  height: 28px;
  margin-left: -48px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.55) 0 6px, rgba(255, 255, 255, 0.3) 6px 12px),
    rgba(255, 232, 160, 0.62);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transform: rotate(var(--tape-rot, -4deg));
  opacity: 0.95;
  pointer-events: none;
}
.tape--left { left: 18px; margin-left: 0; }
.tape--right { left: auto; right: 18px; margin-left: 0; }
.tape--blue { background: repeating-linear-gradient(45deg, rgba(255,255,255,.5) 0 6px, rgba(255,255,255,.25) 6px 12px), rgba(160, 210, 255, 0.6); }
.tape--pink { background: repeating-linear-gradient(45deg, rgba(255,255,255,.5) 0 6px, rgba(255,255,255,.25) 6px 12px), rgba(255, 170, 185, 0.6); }

/* a pinned note / card */
.card {
  position: relative;
  background: var(--paper);
  padding: 24px 26px;
  box-shadow: 0 2px 6px rgba(20, 30, 50, 0.08), 0 18px 36px -18px rgba(20, 30, 50, 0.4);
  border-radius: 3px;
}

/* ---------- reveal ---------- */
[data-reveal] {
  --i: 0;
  opacity: 0;
  transform: translateY(26px) rotate(calc(var(--tilt, 0deg) + 1.4deg));
  transition:
    opacity 0.7s ease,
    transform 1s var(--ease-out);
  transition-delay: calc(var(--i) * 90ms);
}
[data-reveal].is-in {
  opacity: 1;
  transform: translateY(0) rotate(var(--tilt, 0deg));
}
[data-reveal="fade"] { transform: none; }
[data-reveal="fade"].is-in { transform: none; }
[data-reveal="left"] { transform: translateX(-28px) rotate(var(--tilt, 0deg)); }
[data-reveal="right"] { transform: translateX(28px) rotate(var(--tilt, 0deg)); }
[data-reveal="left"].is-in, [data-reveal="right"].is-in { transform: translateX(0) rotate(var(--tilt, 0deg)); }

/* hand-drawn underline that draws itself when its ancestor .is-in */
.u { position: relative; white-space: nowrap; }
.u svg {
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: -0.18em;
  width: 104%;
  height: 0.5em;
  overflow: visible;
  pointer-events: none;
}
.u svg path {
  fill: none;
  stroke: var(--string);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.9s var(--ease-soft) 0.35s;
}
.is-in .u svg path, .is-in.u svg path { stroke-dashoffset: 0; }
.u--gold svg path { stroke: var(--gold); }
.u--blue svg path { stroke: var(--lis); }

/* ---------- the red string ---------- */
.string {
  position: absolute;                  /* in page coordinates: scrolls with the content, never redrawn per frame */
  top: 0;
  left: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
}
.knot { display: block; width: 1px; height: 1px; }
.knot--band { height: 136px; }         /* whitespace the curl can sit in (≈ 2 × 2.4 × radius) */
.knot--big { height: 330px; }

/* ---------- small doodles ---------- */
.doodle { position: absolute; pointer-events: none; color: var(--string); }
.doodle svg { width: 100%; height: 100%; overflow: visible; }
.doodle path, .doodle circle { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- reduced motion ---------- */
.nowrap { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  [data-reveal] { opacity: 1; transform: rotate(var(--tilt, 0deg)); }
}
