/* =========================================================
   Tessera — Marketing Site
   Aesthetic: Blush & Vellum — warm ivory + dusty rose + antique gold
   Letterpress editorial, literary journal, hand-bound keepsake
   ========================================================= */

:root {
  /* Palette — Light (Blush & Vellum) */
  --canvas:      #FBF6EE;
  --canvas-tint: #F5EEE1;
  --surface:     #FFFCF5;
  --surface-2:   #FBF2E3;
  --ink:         #2A2420;
  --ink-soft:    #6B5F55;
  --ink-faint:   #A69A8E;
  --accent:      #C97A7A;
  --accent-soft: #F0D9D9;
  --accent-deep: #A65F5F;
  --gold:        #B8935C;
  --gold-soft:   #E7D3B1;
  --divider:     #EDE4D6;

  /* Mood colors (data, not chrome) */
  --mood-joyful:  #E8B96F;
  --mood-warm:    #D89776;
  --mood-neutral: #BDB5A8;
  --mood-heavy:   #8B9AA8;
  --mood-painful: #7A6B7E;

  /* Type */
  --display: 'Fraunces', 'New York', 'Hoefler Text', Georgia, serif;
  --body:    'EB Garamond', 'Hoefler Text', Georgia, serif;
  --ui:      'Jost', 'Helvetica Neue', system-ui, sans-serif;

  /* Geometry */
  --r-tile:   6px;
  --r-card:   14px;
  --r-sheet:  22px;
  --r-button: 10px;
  --hair:     1px;

  /* Spacing */
  --s1:  4px;
  --s2:  8px;
  --s3: 16px;
  --s4: 24px;
  --s5: 32px;
  --s6: 48px;
  --s7: 72px;
  --s8: 96px;
  --s9: 144px;

  --max-w: 1220px;
  --reading-w: 640px;

  --shadow-card: 0 2px 18px rgba(74, 48, 34, 0.06), 0 0 0 1px rgba(74, 48, 34, 0.03);
  --shadow-sheet: 0 10px 48px rgba(74, 48, 34, 0.08), 0 0 0 1px rgba(74, 48, 34, 0.03);
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas:      #1C1815;
    --canvas-tint: #221D19;
    --surface:     #2A2420;
    --surface-2:   #332B26;
    --ink:         #F4EEE4;
    --ink-soft:    #B8ADA0;
    --ink-faint:   #6B5F55;
    --accent:      #D89A9A;
    --accent-soft: #5C3A3A;
    --accent-deep: #E8B0B0;
    --gold:        #D4AF7A;
    --gold-soft:   #5A4A34;
    --divider:     #3A322C;

    --mood-joyful:  #EFC98B;
    --mood-warm:    #E5AD90;
    --mood-neutral: #8F8678;
    --mood-heavy:   #B0BECA;
    --mood-painful: #A89AAE;

    --shadow-card: 0 2px 22px rgba(0, 0, 0, 0.28);
    --shadow-sheet: 0 12px 48px rgba(0, 0, 0, 0.36);
  }
}

/* ========================= RESET ========================= */

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--canvas);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.05rem;
  line-height: 1.6;
  font-feature-settings: "liga" 1, "kern" 1, "onum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ======================== GRAIN & VIGNETTE ======================== */

.grain {
  position: fixed;
  inset: -2px;
  pointer-events: none;
  z-index: 2;
  opacity: 0.55;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.16  0 0 0 0 0.12  0 0 0 0 0.10  0 0 0 0.35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  .grain {
    opacity: 0.4;
    mix-blend-mode: screen;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.95  0 0 0 0 0.90  0 0 0 0 0.82  0 0 0 0.18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at 50% 0%, transparent 40%, rgba(74, 48, 34, 0.04) 100%),
    radial-gradient(ellipse at 50% 100%, transparent 40%, rgba(74, 48, 34, 0.06) 100%);
}

/* ====================== TYPOGRAPHY ATOMS ====================== */

.small-caps {
  font-family: var(--ui);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.tile-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--ink);
  vertical-align: middle;
  flex: 0 0 auto;
}
.tile-dot.gold { background: var(--gold); }
.tile-dot.filled { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }

.hairline {
  display: inline-block;
  height: var(--hair);
  background: var(--divider);
  flex: 1;
}

.hairline-short {
  display: inline-block;
  width: 32px;
  height: var(--hair);
  background: var(--divider);
  vertical-align: middle;
}

.ornament {
  display: flex;
  align-items: center;
  gap: var(--s3);
  max-width: 180px;
  margin: 0 auto var(--s5);
}

/* ====================== NAV ====================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px) saturate(1.08);
  -webkit-backdrop-filter: blur(18px) saturate(1.08);
  background: color-mix(in srgb, var(--canvas) 80%, transparent);
  border-bottom: var(--hair) solid color-mix(in srgb, var(--divider) 70%, transparent);
}

.site-nav {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s3) var(--s4);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s4);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: var(--s5);
}

.nav-links a {
  font-family: var(--ui);
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  position: relative;
  padding: 4px 2px;
  transition: color .3s ease;
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .35s cubic-bezier(.3,.7,.3,1);
}

.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::after { transform: scaleX(1); }

.nav-cta {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--ui);
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--accent-deep);
  padding: 8px 14px;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-soft) 35%, transparent);
  letter-spacing: 0.03em;
  transition: background .3s ease, border-color .3s ease, transform .3s ease;
}
.nav-cta:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.nav-cta .nav-arrow {
  display: inline-block;
  transition: transform .35s cubic-bezier(.3,.7,.3,1);
}
.nav-cta:hover .nav-arrow { transform: translate(2px, -2px); }

@media (max-width: 760px) {
  .nav-links { display: none; }
  .site-nav { grid-template-columns: auto auto; justify-content: space-between; }
}

/* ====================== HERO ====================== */

.hero {
  position: relative;
  padding: var(--s8) var(--s4) var(--s7);
  z-index: 3;
}

.hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: var(--s6);
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--s4);
}

.hero-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.2rem, 7.8vw, 6.6rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--ink);
  font-variation-settings: "opsz" 144, "SOFT" 50;
  margin-bottom: var(--s5);
}

.hero-title .line {
  display: block;
  opacity: 0;
  transform: translateY(24px);
  animation: line-rise 1.1s cubic-bezier(.2,.7,.2,1) var(--d, 0s) forwards;
}

.hero-title em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent-deep);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

@keyframes line-rise {
  to { opacity: 1; transform: translateY(0); }
}

.hero-sub {
  font-family: var(--body);
  font-size: 1.22rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 36ch;
  margin-bottom: var(--s5);
  font-style: italic;
  font-weight: 400;
}

.hero-cta {
  display: flex;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s5);
}

.hero-meta {
  display: flex;
  gap: var(--s3);
  align-items: center;
  flex-wrap: wrap;
}

.hero-meta .sep {
  color: var(--ink-faint);
}

/* Mosaic */

.hero-mosaic {
  position: relative;
  padding: var(--s3);
}

.mosaic-frame {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-sheet);
  padding: var(--s5) var(--s4) var(--s4);
  box-shadow: var(--shadow-sheet);
  transform: rotate(1.2deg);
}

@media (prefers-color-scheme: light) {
  .mosaic-frame::before {
    content: '';
    position: absolute;
    inset: -6px -6px -12px -6px;
    background: linear-gradient(180deg, var(--canvas-tint) 0%, rgba(0,0,0,0) 60%);
    border-radius: calc(var(--r-sheet) + 4px);
    z-index: -1;
  }
}

.mosaic-binding {
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  height: 2px;
  margin: 0 var(--s5);
  background: repeating-linear-gradient(
    90deg,
    var(--divider) 0 6px,
    transparent 6px 12px
  );
  opacity: 0.6;
}

.mosaic-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  aspect-ratio: 1 / 1;
}

.mosaic-tile {
  border-radius: 3px;
  background: var(--accent-soft);
  opacity: 0;
  transform: scale(.4);
  animation: tile-settle .9s cubic-bezier(.2,.8,.3,1) var(--delay, 0s) forwards,
             tile-breathe 6s ease-in-out var(--delay, 0s) infinite;
}

@keyframes tile-settle {
  from { opacity: 0; transform: scale(.3); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes tile-breathe {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.05); }
}

.mosaic-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  margin-top: var(--s4);
  font-family: var(--display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-variation-settings: "opsz" 14;
}

@media (max-width: 880px) {
  .hero-inner { grid-template-columns: 1fr; gap: var(--s6); }
  .hero { padding-top: var(--s7); }
  .mosaic-frame { transform: rotate(0.5deg); }
  .hero-sub { max-width: none; }
}

/* ====================== BUTTONS ====================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 26px;
  border-radius: var(--r-button);
  font-family: var(--ui);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.015em;
  transition: background .3s ease, color .3s ease, transform .35s cubic-bezier(.2,.7,.3,1), box-shadow .3s ease;
  position: relative;
  overflow: hidden;
}

.btn.primary {
  background: var(--accent);
  color: var(--surface);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent-deep) 40%, transparent);
}

.btn.primary:hover {
  background: var(--accent-deep);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent-deep) 28%, transparent);
}

.btn.primary .arrow { transition: transform .35s cubic-bezier(.2,.7,.3,1); }
.btn.primary:hover .arrow { transform: translateX(4px); }

.btn.ghost {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--divider);
}

.btn.ghost:hover {
  background: var(--surface);
  border-color: var(--ink-faint);
}

/* ====================== MANIFESTO ====================== */

.manifesto {
  max-width: 720px;
  margin: var(--s6) auto;
  padding: var(--s6) var(--s4);
  text-align: center;
  position: relative;
  z-index: 3;
}

.manifesto-body {
  font-family: var(--body);
  font-size: 1.55rem;
  line-height: 1.55;
  color: var(--ink);
  max-width: 30ch;
  margin: 0 auto var(--s5);
  text-align: left;
}

.manifesto-body em {
  font-style: italic;
  color: var(--ink-soft);
  font-weight: 500;
}

.dropcap {
  float: left;
  font-family: var(--display);
  font-size: 4.8rem;
  line-height: 0.85;
  padding: 8px 14px 0 0;
  color: var(--accent-deep);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

.signed {
  text-align: center;
  margin-top: var(--s5);
  letter-spacing: 0.28em;
}

/* ====================== SECTION HEADS ====================== */

.section-head {
  max-width: 820px;
  margin: 0 auto var(--s7);
  padding: 0 var(--s4);
}

.section-head.center { text-align: center; }

.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--s3);
}

.section-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 4.5vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variation-settings: "opsz" 72, "SOFT" 60;
}

.section-title.center { text-align: center; }

.section-title em {
  font-style: italic;
  color: var(--accent-deep);
  font-weight: 300;
  font-variation-settings: "opsz" 72, "SOFT" 100;
}

.section-sub {
  font-family: var(--body);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin-top: var(--s3);
  max-width: 52ch;
}
.section-head.center .section-sub { margin-left: auto; margin-right: auto; }

/* ====================== FEATURES (CHAPTERS) ====================== */

.features {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s8) var(--s4);
  position: relative;
  z-index: 3;
}

.chapter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s7);
  align-items: center;
  padding: var(--s7) 0;
  border-top: var(--hair) solid var(--divider);
  position: relative;
}

.chapter:first-of-type { border-top: none; padding-top: var(--s5); }

.chapter-ii, .chapter-iv {
  direction: rtl;
}
.chapter-ii > *, .chapter-iv > * { direction: ltr; }

.chapter-copy { max-width: 48ch; }

.chapter-number {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  margin-bottom: var(--s3);
  padding-bottom: var(--s2);
  border-bottom: var(--hair) solid var(--divider);
  width: fit-content;
}

.numeral {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: 1.4rem;
  color: var(--gold);
  font-variation-settings: "opsz" 24;
}

.chapter-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: var(--s4);
  font-variation-settings: "opsz" 72, "SOFT" 60;
}

.chapter-title em {
  font-style: italic;
  color: var(--accent-deep);
  font-weight: 300;
  font-variation-settings: "opsz" 72, "SOFT" 100;
}

.chapter-lede {
  font-family: var(--body);
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--ink-soft);
  margin-bottom: var(--s4);
}

.chapter-lede code {
  font-family: var(--ui);
  font-weight: 400;
  font-size: 0.88rem;
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.chapter-lede em {
  font-style: italic;
  color: var(--ink);
  font-weight: 500;
}

.chapter-quote {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
  padding-left: var(--s4);
  border-left: 2px solid var(--accent-soft);
  font-variation-settings: "opsz" 24;
}

.chapter-quote .quote-mark {
  color: var(--accent);
  font-style: normal;
  font-size: 1.2em;
  line-height: 0;
  position: relative;
  top: 0.1em;
  margin: 0 2px;
}

@media (max-width: 880px) {
  .chapter { grid-template-columns: 1fr; gap: var(--s5); padding: var(--s6) 0; }
  .chapter-ii, .chapter-iv { direction: ltr; }
}

/* ----------- Chapter visuals ----------- */

.chapter-visual {
  position: relative;
}

/* Capture device frame */
.device-frame {
  background: var(--surface);
  border-radius: 28px;
  padding: var(--s4);
  box-shadow: var(--shadow-sheet);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  border: 1px solid var(--divider);
}

.device-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  padding: 0 var(--s2) var(--s3);
}

.device-bar-dots { display: flex; gap: 4px; }
.device-bar-dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-faint); }

.sheet {
  background: var(--canvas-tint);
  border-radius: 18px;
  padding: var(--s4);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.sheet-placeholder {
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--ink-faint);
  font-weight: 400;
  margin-bottom: var(--s3);
}

.sheet-rule {
  width: 32px;
  height: 1px;
  background: var(--divider);
  margin-bottom: var(--s3);
}

.sheet-body {
  font-family: var(--body);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink);
  flex: 1;
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: var(--accent);
  vertical-align: baseline;
  margin-left: 2px;
  animation: blink 1.1s steps(2) infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--divider);
}

.small-caps.muted { color: var(--ink-faint); }

.btn-mini {
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 12px;
  background: var(--accent);
  color: var(--surface);
  border-radius: 8px;
  letter-spacing: 0.02em;
}

/* Era list card */

.paper-card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: var(--s4);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--divider);
  max-width: 440px;
}

.paper-label {
  letter-spacing: 0.28em;
  margin-bottom: var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--divider);
}

.era-list {
  display: flex;
  flex-direction: column;
}

.era-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  grid-template-areas: "chev name count" "chev bar bar";
  gap: 4px 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--divider);
  align-items: center;
}

.era-row:last-child { border-bottom: none; }

.era-chev {
  grid-area: chev;
  color: var(--ink-faint);
  font-size: 0.7rem;
  line-height: 1;
}

.era-name {
  grid-area: name;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.1rem;
  color: var(--ink);
  font-variation-settings: "opsz" 18;
}

.era-name em {
  font-style: italic;
  color: var(--ink-soft);
}

.era-count {
  grid-area: count;
  font-family: var(--ui);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.mood-bar {
  grid-area: bar;
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 2px;
}

.mood-bar > span { height: 100%; }
.m-joyful  { background: var(--mood-joyful); }
.m-warm    { background: var(--mood-warm); }
.m-neutral { background: var(--mood-neutral); }
.m-heavy   { background: var(--mood-heavy); }
.m-painful { background: var(--mood-painful); }

.era-row.sub     { padding-left: 18px; }
.era-row.sub-2   { padding-left: 36px; }
.era-row.sub .era-name,
.era-row.sub-2 .era-name { font-size: 1rem; }

/* Apparatus (chapter III) */

.apparatus {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: var(--s3);
  max-width: 520px;
  margin-left: auto;
}

.appa-card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: var(--s4);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--divider);
}

.appa-tags { grid-column: 1 / -1; }
.card-label {
  letter-spacing: 0.28em;
  margin-bottom: var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--divider);
}

.chip-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.chip.selected {
  background: var(--accent);
  color: var(--surface);
}

.chip.more {
  background: transparent;
  border: 1px dashed var(--ink-faint);
  color: var(--ink-soft);
  font-style: italic;
}

.chip.sm { font-size: 0.72rem; padding: 4px 9px; }

.mood-picker {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding: var(--s2) 0;
}

.mood-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px;
  border-radius: 10px;
}

.mood-opt .dot {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 0 0 0 transparent;
  transition: box-shadow .3s ease;
}

.mood-opt.active .dot {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.dot.m-joyful  { background: var(--mood-joyful); }
.dot.m-warm    { background: var(--mood-warm); }
.dot.m-neutral { background: var(--mood-neutral); }
.dot.m-heavy   { background: var(--mood-heavy); }
.dot.m-painful { background: var(--mood-painful); }

.dot-label {
  font-family: var(--ui);
  font-size: 0.7rem;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
}

.flag-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flag {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
}

.flag .tile-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: transparent;
  border: 1.5px solid var(--ink-faint);
}

.flag.on .tile-dot {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.flag-name {
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--ink);
}

.flag-note {
  font-family: var(--body);
  font-size: 0.88rem;
  color: var(--ink-faint);
}

@media (max-width: 560px) {
  .apparatus { grid-template-columns: 1fr; }
  .appa-tags { grid-column: 1; }
}

/* Date modes (chapter IV) */

.dates { max-width: 440px; }

.date-modes {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: var(--s3) var(--s4);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--divider);
}

.date-mode {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: var(--s3);
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px dashed var(--divider);
}

.date-mode:last-child { border-bottom: none; }

.mode-label { letter-spacing: 0.22em; color: var(--gold); }
.mode-value {
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--ink);
}
.mode-value em { font-style: italic; color: var(--ink-soft); }
.mode-note {
  font-family: var(--body);
  font-size: 0.86rem;
  color: var(--ink-faint);
  text-align: right;
}

@media (max-width: 540px) {
  .date-mode { grid-template-columns: 100px 1fr; }
  .mode-note { grid-column: 1 / -1; text-align: left; }
}

/* ====================== PORTRAIT SECTION ====================== */

.portrait-section {
  background: var(--canvas-tint);
  padding: var(--s8) var(--s4);
  position: relative;
  z-index: 3;
  border-top: var(--hair) solid var(--divider);
  border-bottom: var(--hair) solid var(--divider);
}

.portrait-section::before,
.portrait-section::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  background:
    linear-gradient(to right, transparent 48%, var(--gold) 48% 52%, transparent 52%),
    linear-gradient(to bottom, transparent 48%, var(--gold) 48% 52%, transparent 52%);
  opacity: 0.18;
}
.portrait-section::before { top: -20px; }
.portrait-section::after  { bottom: -20px; }

.portrait-grid {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--s3);
}

.portrait-card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: var(--s4);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--divider);
  grid-column: span 3;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.portrait-card.wide { grid-column: span 6; }
.portrait-card.mood-card { grid-column: span 6; min-height: 320px; }
.portrait-card.words-cloud { grid-column: span 8; min-height: 280px; }
.portrait-card.cooccur-card { grid-column: span 4; }

.portrait-card .card-label {
  letter-spacing: 0.28em;
  margin-bottom: var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--divider);
}

.stat .stat-number {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(2.4rem, 4.6vw, 3.4rem);
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: auto 0;
  font-variation-settings: "opsz" 144, "SOFT" 40;
}

.stat .stat-number.serif em {
  font-style: italic;
  color: var(--accent-deep);
  font-weight: 300;
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

.stat .stat-caption {
  font-family: var(--body);
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: auto;
}

/* Era chart card */

.era-chart {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--s2) 0;
}

.era-chart li {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  align-items: center;
  gap: 14px;
}

.era-chart-name {
  font-family: var(--display);
  font-size: 1rem;
  color: var(--ink);
}

.era-chart-bar {
  height: 10px;
  background: var(--canvas-tint);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.era-chart-bar .fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  border-radius: 5px;
  animation: bar-fill 1.4s cubic-bezier(.3,.7,.3,1) forwards;
  animation-delay: 0.3s;
}

@keyframes bar-fill {
  to { width: var(--w); }
}

.era-chart-num {
  font-family: var(--ui);
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* Mood donut */

.donut-wrap {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--s5);
  align-items: center;
  padding: var(--s3) 0;
}

.donut {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: conic-gradient(
    var(--mood-warm) 0deg 137deg,
    var(--mood-joyful) 137deg 223deg,
    var(--mood-neutral) 223deg 288deg,
    var(--mood-heavy) 288deg 331deg,
    var(--mood-painful) 331deg 360deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--divider);
}

.donut-hole {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.donut-hole-label {
  font-family: var(--display);
  font-weight: 300;
  font-size: 2.4rem;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "opsz" 72;
}

.donut-hole-sub {
  letter-spacing: 0.24em;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.donut-legend li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  font-family: var(--body);
  font-size: 0.98rem;
  color: var(--ink);
  padding: 4px 0;
  border-bottom: 1px dashed var(--divider);
}

.donut-legend li:last-child { border-bottom: none; }

.donut-legend .dot {
  width: 10px; height: 10px; border-radius: 50%;
}

.donut-legend .pct {
  font-family: var(--ui);
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
}

/* Heatmap */

.heatmap {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 3px;
  flex: 1;
  padding: var(--s2) 0;
}

.heatmap .cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--canvas-tint);
}

.heatmap .cell.l1 { background: color-mix(in srgb, var(--accent-soft) 70%, var(--canvas)); }
.heatmap .cell.l2 { background: var(--accent-soft); }
.heatmap .cell.l3 { background: color-mix(in srgb, var(--accent) 50%, var(--accent-soft)); }
.heatmap .cell.l4 { background: var(--accent); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: var(--s3);
}

.legend-bar { display: inline-flex; gap: 2px; }
.legend-bar span {
  width: 14px; height: 10px; border-radius: 2px;
}
.legend-bar .l0 { background: var(--canvas-tint); }
.legend-bar .l1 { background: color-mix(in srgb, var(--accent-soft) 70%, var(--canvas)); }
.legend-bar .l2 { background: var(--accent-soft); }
.legend-bar .l3 { background: color-mix(in srgb, var(--accent) 50%, var(--accent-soft)); }
.legend-bar .l4 { background: var(--accent); }

/* Word cloud */

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--s3);
  padding: var(--s3) 0;
  line-height: 1.8;
  justify-content: center;
}

.cw {
  font-family: var(--display);
  font-size: calc(var(--s) * 1rem);
  color: var(--ink);
  letter-spacing: -0.02em;
  font-weight: 400;
  transition: color .3s ease;
  font-variation-settings: "opsz" calc(var(--s) * 20), "SOFT" 40;
}

.cw.alt {
  font-style: italic;
  color: var(--ink-soft);
  font-variation-settings: "opsz" calc(var(--s) * 20), "SOFT" 100;
}

.cw:hover { color: var(--accent-deep); }

/* Co-occurrence */

.pair-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--s2) 0;
}

.pair-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--divider);
}

.pair-list li:last-child { border-bottom: none; }

.pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.plus {
  font-family: var(--display);
  font-style: italic;
  color: var(--gold);
  font-size: 0.95rem;
}

.pair-n {
  font-family: var(--ui);
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.portrait-footnote {
  max-width: 560px;
  margin: var(--s6) auto 0;
  text-align: center;
  font-family: var(--body);
  font-size: 1.02rem;
  color: var(--ink-soft);
  line-height: 1.6;
  padding: 0 var(--s4);
}

@media (max-width: 1020px) {
  .portrait-card { grid-column: span 6; }
  .portrait-card.wide,
  .portrait-card.mood-card,
  .portrait-card.words-cloud,
  .portrait-card.cooccur-card { grid-column: span 12; }
}

@media (max-width: 560px) {
  .portrait-card { grid-column: span 12 !important; }
}

/* ====================== PRIVACY ====================== */

.privacy {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--s8) var(--s4);
  text-align: center;
  position: relative;
  z-index: 3;
}

.privacy-lede {
  font-family: var(--body);
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 48ch;
  margin: var(--s4) auto 0;
  font-style: italic;
}

.privacy-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s4);
  max-width: 720px;
  margin: var(--s6) auto 0;
  text-align: left;
}

.privacy-list li {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--s3);
  background: var(--surface);
  border-radius: var(--r-card);
  border: 1px solid var(--divider);
}

.pl-label {
  letter-spacing: 0.24em;
  color: var(--gold);
}

.pl-text {
  font-family: var(--body);
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.55;
}
.pl-text em { color: var(--accent-deep); font-style: italic; }

@media (max-width: 640px) {
  .privacy-list { grid-template-columns: 1fr; }
}

/* ====================== CLOSING ====================== */

.closing {
  padding: var(--s8) var(--s4);
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 40%, var(--accent-soft) 0%, transparent 60%),
    var(--canvas);
  position: relative;
  z-index: 3;
  border-top: var(--hair) solid var(--divider);
}

.closing-inner {
  max-width: 720px;
  margin: 0 auto;
}

.closing-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--s4);
}

.closing-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: var(--s6);
  font-variation-settings: "opsz" 144, "SOFT" 60;
}

.closing-title em {
  font-style: italic;
  color: var(--accent-deep);
  font-weight: 300;
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

.closing-title .line { display: block; }

.closing-coda {
  font-family: var(--body);
  font-size: 1.05rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.closing-coda em { color: var(--accent-deep); font-style: italic; }

/* ====================== FOOTER ====================== */

.site-footer {
  background: var(--canvas-tint);
  border-top: var(--hair) solid var(--divider);
  padding: var(--s7) var(--s4) var(--s5);
  position: relative;
  z-index: 3;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: var(--s5);
  align-items: start;
}

.foot-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--ink);
  margin-bottom: var(--s3);
}

.foot-tag {
  font-family: var(--body);
  font-style: italic;
  color: var(--ink-soft);
  max-width: 28ch;
  line-height: 1.5;
}

.foot-label {
  letter-spacing: 0.28em;
  margin-bottom: var(--s3);
  display: block;
}

.foot-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.foot-links a {
  font-family: var(--body);
  font-size: 0.98rem;
  color: var(--ink-soft);
  transition: color .3s ease;
}

.foot-links a:hover {
  color: var(--accent-deep);
}

.foot-legal-name {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
  margin-bottom: var(--s2);
}

.foot-legal-copy {
  color: var(--ink-faint);
  letter-spacing: 0.22em;
}

@media (max-width: 820px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .footer-inner { grid-template-columns: 1fr; gap: var(--s4); }
}

/* ====================== REVEAL ANIMATIONS ====================== */

.reveal {
  transition: opacity 1s cubic-bezier(.2,.7,.2,1),
              transform 1s cubic-bezier(.2,.7,.2,1);
}

.js .reveal:not(.is-visible) {
  opacity: 0;
  transform: translateY(20px);
}

/* Hero is immediately visible (line-rise handles the staggered reveal) */
.hero {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    transition-duration: 0.001s !important;
  }
  .reveal { opacity: 1; transform: none; }
  .hero-title .line { opacity: 1; transform: none; }
  .mosaic-tile { opacity: 1; transform: none; animation: none; }
  .era-chart-bar .fill { width: var(--w); animation: none; }
}

/* ====================== GALLERY ====================== */

.gallery {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s8) var(--s4) var(--s7);
}

.gallery-grid {
  margin-top: var(--s6);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s5) var(--s4);
}

@media (max-width: 960px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .gallery-grid { grid-template-columns: 1fr; gap: var(--s5); }
}

.gallery .shot {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
}

.gallery .shot img {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
  border-radius: 32px;
  box-shadow:
    0 18px 48px rgba(74, 48, 34, 0.12),
    0 2px 8px rgba(74, 48, 34, 0.06),
    0 0 0 1px rgba(74, 48, 34, 0.04);
  background: var(--surface);
}

.gallery .shot figcaption {
  text-align: center;
  font-family: var(--body);
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}

.gallery .shot figcaption .small-caps {
  color: var(--ink);
  letter-spacing: 0.14em;
  font-size: 0.78rem;
}

.gallery .shot figcaption em {
  font-size: 0.92rem;
  color: var(--ink-faint);
}

/* ====================== LEGAL / FAQ BODY ====================== */
/* Used on privacy.html + support.html for long-form editorial copy. */

.legal-body {
  max-width: 64ch;
  margin: var(--s7) auto 0;
  font-family: var(--body);
  color: var(--ink);
  font-size: 1.06rem;
  line-height: 1.72;
}

.legal-body h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.55rem;
  margin: var(--s6) 0 var(--s3);
  color: var(--ink);
  letter-spacing: -0.01em;
}

.legal-body h2:first-child { margin-top: 0; }

.legal-body h3 {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.15rem;
  margin: var(--s5) 0 var(--s2);
  color: var(--ink);
}

.legal-body p {
  margin: 0 0 var(--s3);
  color: var(--ink-soft);
}

.legal-body a {
  color: var(--accent-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.legal-body a:hover { color: var(--accent); }

/* ====================== SELECTION ====================== */

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