/* crumblylogic
 * One stylesheet. Read-only. Hand-tuned for warmth + restraint.
 *
 * Palette: "terracotta + petrol" (P2). Warm terracotta for "crumbly",
 * petrol for "logic", warm again for the trailing dot — so the warm/
 * cool brand metaphor lives at the word level.
 *
 * The cool ("logic") is a deep petrol on light surfaces and a lifted
 * sea-glass petrol on dark surfaces. Both read as the same identity;
 * the value shifts per surface so it stays legible on both backgrounds
 * (this is the standard dark-mode pattern — same idea, different hex).
 *
 * Premium feel comes from typography, spacing, and paper texture —
 * not from JavaScript. */

:root {
  --bg: #f0f3f7;
  --surface: #e3eaf1;
  --ink: #1a2331;
  --ink-soft: #5a6478;
  --accent: #d97f5a;
  --muted: #2e5a6a;
  --subtle: #d4dde5;
  --focus: #d97f5a;

  --font-display: "Fraunces", ui-serif, "Iowan Old Style", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --enter-duration: 1100ms;
  --enter-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="dark"] {
  --bg: #101926;
  --surface: #1a2434;
  --ink: #dde3ec;
  --ink-soft: #8493a8;
  --accent: #d97f5a;
  --muted: #7ab0bc;
  --subtle: #1e2a3e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  font-feature-settings: "ss01", "liga", "calt";
  font-size: clamp(16px, 1vw + 14px, 18px);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;

  /* Two soft tinted vignettes — warm amber at the top-left, cool slate
   * at the bottom-right — encode the brand metaphor (warm "crumbly" +
   * cool "logic") in the background itself. Plus a hand-set paper-fibre
   * noise overlay that keeps the surface from feeling printed-by-a-
   * laser-printer. */
  background-image:
    radial-gradient(70% 55% at 25% 12%, rgba(217, 127, 90, 0.07), transparent 70%),
    radial-gradient(60% 50% at 100% 100%, rgba(46, 90, 106, 0.06), transparent 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='280' height='280'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10 0 0 0 0 0.13 0 0 0 0 0.19 0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
}

:root[data-theme="dark"] body {
  background-image:
    radial-gradient(70% 55% at 25% 12%, rgba(217, 127, 90, 0.10), transparent 70%),
    radial-gradient(60% 50% at 100% 100%, rgba(122, 176, 188, 0.07), transparent 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='280' height='280'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.86 0 0 0 0 0.89 0 0 0 0 0.93 0 0 0 0.035 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

@media (prefers-reduced-data: reduce), print {
  body { background-image: none; }
}

::selection { background: var(--accent); color: var(--bg); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ---------- top bar (apex + sub-pages) ---------- */

.topbar {
  padding: clamp(1.25rem, 3vw, 2rem) clamp(1.5rem, 6vw, 4rem) 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;

  opacity: 0;
  animation: enter 800ms var(--enter-ease) 80ms forwards;
}

.mark {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 36, "SOFT" 100;
  font-size: clamp(1.15rem, 0.5vw + 1rem, 1.35rem);
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: baseline;
  transition: opacity 220ms var(--enter-ease);
}

.mark:hover,
.mark:focus-visible {
  opacity: 0.85;
}

.mark__crumbly { color: var(--accent); }
.mark__logic   { color: var(--muted); }
.mark__dot {
  color: var(--accent);
  margin-left: 0.01em;
  user-select: none;
}

.topnav {
  display: flex;
  gap: clamp(1rem, 3vw, 1.75rem);
}

.topnav a {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color 220ms var(--enter-ease), border-color 220ms var(--enter-ease);
}

.topnav a:hover,
.topnav a:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink-soft);
}

.topnav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--subtle);
}

/* ---------- apex hero ---------- */

.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 6vw, 5rem) clamp(1.5rem, 6vw, 4rem);
}

.hero__inner {
  max-width: min(38rem, 92vw);
  text-align: center;
}

.eyebrow {
  margin: 0 0 clamp(1.5rem, 4vw, 2.25rem);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);

  opacity: 0;
  animation: enter 900ms var(--enter-ease) 220ms forwards;
}

.eyebrow__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(217, 127, 90, 0.4);
  animation: pulse 2.6s ease-in-out infinite 2000ms;
}

.hero-line {
  margin: 0 0 clamp(1rem, 2vw, 1.5rem);
  font-weight: 600;
  font-variation-settings: "opsz" 144, "SOFT" 100;
  font-size: clamp(2.2rem, 6vw + 0.5rem, 4.25rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-wrap: balance;

  opacity: 0;
  transform: translateY(8px);
  animation: enter var(--enter-duration) var(--enter-ease) 500ms forwards;
}

.hero-line em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100;
  color: inherit;
}

.hero-sub {
  margin: 0 auto;
  font-weight: 500;
  font-variation-settings: "opsz" 36, "SOFT" 80;
  font-size: clamp(1.1rem, 1vw + 0.75rem, 1.4rem);
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 30rem;
  text-wrap: pretty;

  opacity: 0;
  transform: translateY(6px);
  animation: enter 900ms var(--enter-ease) 900ms forwards;
}

/* ---------- baseline footer (apex + sub-pages) ---------- */

.baseline {
  padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1.5rem, 6vw, 4rem);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex-wrap: wrap;

  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);

  opacity: 0;
  animation: enter 1000ms var(--enter-ease) 1400ms forwards;
}

.baseline__link {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--subtle);
  padding-bottom: 1px;
  transition: color 220ms var(--enter-ease), border-color 220ms var(--enter-ease);
}

.baseline__link:hover,
.baseline__link:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

/* sub-page baseline lands a beat sooner than the apex (no eyebrow/hero cascade) */
.page-home .baseline,
.page-404 .baseline {
  animation-delay: 600ms;
}

/* home now uses the prose shell (merged about page) — vertically centre
 * the prose since there is no page-title anchoring it at the top. */
.page-home .prose-wrap {
  align-items: center;
}

/* ---------- shared keyframes ---------- */

@keyframes enter {
  to { opacity: 1; transform: none; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 127, 90, 0.35); }
  50%      { box-shadow: 0 0 0 7px rgba(217, 127, 90, 0); }
}

/* (former pulse-dark removed — both themes now share one accent rgba) */

/* ---------- sub-pages: prose stage ---------- */

.prose-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1.5rem, 6vw, 4rem) clamp(2rem, 6vw, 4rem);
}

.prose {
  text-align: left;
  max-width: min(34rem, 92vw);
  margin: 0;

  opacity: 0;
  animation: enter 1000ms var(--enter-ease) 260ms forwards;
}

.page-title {
  margin: 0 0 clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 600;
  font-variation-settings: "opsz" 96, "SOFT" 100;
  font-size: clamp(2rem, 5vw + 0.5rem, 3.25rem);
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.prose p {
  margin: 0 0 1.1em;
  font-weight: 500;
  font-variation-settings: "opsz" 36, "SOFT" 80;
  font-size: clamp(1.12rem, 0.55vw + 1rem, 1.28rem);
  line-height: 1.6;
  color: var(--ink);
  text-wrap: pretty;
}

.prose p strong {
  font-weight: 600;
  color: var(--ink);
}

.prose .word {
  font-style: italic;
  font-variation-settings: "opsz" 36, "SOFT" 100;
}

/* brand-name wordmark when it appears inside prose (mirrors topbar treatment) */
.prose .brand__crumbly { color: var(--accent); }
.prose .brand__logic   { color: var(--muted); }
.prose .brand__dot {
  color: var(--accent);
  margin-left: 0.01em;
}

/* single-colour accent echo (e.g. the 404 "crumbled" verb wordplay) */
.prose .word--crumbly { color: var(--accent); }

.prose__quiet {
  margin-top: clamp(2rem, 5vw, 2.75rem) !important;
  color: var(--ink-soft) !important;
  font-style: italic;
  font-variation-settings: "opsz" 36, "SOFT" 100 !important;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .topbar,
  .mark,
  .eyebrow,
  .hero-line,
  .hero-sub,
  .baseline,
  .prose {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
  .eyebrow__dot { animation: none !important; }
}
