/* =====================================================================
   a6c.boo — Memphis meets mindfulness
   Broken-grid, earth tones, elegant serif, noise texture,
   organic blobs, counter-animate, calm-serene tempo.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
    --warm-linen:      #F4EDE4;
    --damp-clay:       #D4C4AE;
    --umber-earth:     #3B2F24;
    --terracotta:      #C67D5A;
    --sage-moss:       #7A8F6D;
    --marigold:        #D4A843;
    --river-pebble:    #9C9183;
    --burnt-walnut:    #2A1F16;

    --font-display: "Cormorant Garamond", "Lora", Georgia, serif;
    --font-prose:   "Lora", Georgia, serif;
    --font-label:   "DM Sans", "Inter", system-ui, sans-serif;

    --max-w: 1320px;
    --ease-serene: cubic-bezier(.25,.46,.45,.94);
}

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

html, body { margin: 0; padding: 0; }

html {
    background-color: var(--warm-linen);
    color: var(--umber-earth);
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-prose);
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    color: var(--umber-earth);
    background-color: var(--warm-linen);
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* ---------- Noise Texture Overlay ---------- */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.23  0 0 0 0 0.18  0 0 0 0 0.14  0 0 0 0.9 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    opacity: 0.045;
    mix-blend-mode: multiply;
}

/* Soft radial blush behind hero */
body::before {
    content: "";
    position: fixed;
    top: -20vh;
    right: -20vw;
    width: 90vw;
    height: 90vh;
    background: radial-gradient(closest-side,
        rgba(198,125,90,0.22),
        rgba(244,237,228,0) 70%);
    pointer-events: none;
    z-index: 0;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--burnt-walnut);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0 0 0.4em 0;
    line-height: 1.08;
}

h2.display {
    font-size: clamp(2.4rem, 5vw, 4.4rem);
}

h3 {
    font-size: clamp(1.2rem, 1.8vw, 1.55rem);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

p {
    margin: 0 0 1.1em 0;
    color: var(--umber-earth);
    max-width: 56ch;
}

.eyebrow {
    font-family: var(--font-label);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--river-pebble);
    display: inline-block;
    padding-bottom: 0.5em;
    border-bottom: 1px solid rgba(156,145,131,0.35);
}

.hl {
    background-image: linear-gradient(transparent 62%, rgba(212,168,67,0.45) 62%, rgba(212,168,67,0.45) 92%, transparent 92%);
    padding: 0 0.1em;
}

a {
    color: var(--terracotta);
    text-decoration: none;
    transition: color .45s var(--ease-serene);
}
a:hover { color: var(--burnt-walnut); }

/* ---------- Navigation Pill ---------- */
.nav-pill {
    position: fixed;
    top: 1.4rem;
    left: 50%;
    transform: translate(-50%, -120%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.7rem 1.4rem;
    border-radius: 999px;
    background: rgba(198,125,90,0.78);
    backdrop-filter: blur(12px) saturate(130%);
    -webkit-backdrop-filter: blur(12px) saturate(130%);
    box-shadow: 0 8px 30px -10px rgba(43,31,22,0.25);
    transition: transform .9s var(--ease-serene), opacity .6s ease;
    opacity: 0;
    pointer-events: none;
}

.nav-pill.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
}

.nav-wordmark {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--warm-linen);
}
.nav-wordmark:hover { color: var(--marigold); }

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.4rem;
    margin: 0;
    padding: 0;
}
.nav-links a {
    font-family: var(--font-label);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--warm-linen);
    position: relative;
    padding-bottom: 2px;
}
.nav-links a::after {
    content: "";
    position: absolute;
    left: 0; right: 100%;
    bottom: -2px;
    height: 1px;
    background: var(--marigold);
    transition: right .6s var(--ease-serene);
}
.nav-links a:hover { color: var(--marigold); }
.nav-links a:hover::after { right: 0; }

@media (max-width: 640px) {
    .nav-pill { gap: 1rem; padding: 0.6rem 1rem; }
    .nav-links { gap: 0.9rem; }
    .nav-links a { font-size: 0.7rem; letter-spacing: 0.1em; }
}

/* ---------- Main scaffold ---------- */
main {
    position: relative;
    z-index: 1;
    max-width: 100%;
    overflow: hidden;
}

.chapter {
    position: relative;
    min-height: 90vh;
    padding: 10vh clamp(1.25rem, 5vw, 5rem);
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.interstitial {
    position: relative;
    height: 40vh;
    min-height: 280px;
    overflow: hidden;
    pointer-events: none;
}

/* ---------- Broken grid (12 columns) ---------- */
.broken-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(40px, auto);
    gap: clamp(0.5rem, 1vw, 1.1rem);
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
}

/* Generic grid-item */
.gi { position: relative; }

/* ----- Chapter 2 layout (label + headline left, prose and decor staggered) ----- */
.chapter-notes .gi-label     { grid-column: 2 / span 4; grid-row: 1; margin-top: 2vh; }
.chapter-notes .gi-headline  { grid-column: 2 / span 8; grid-row: 2; margin-top: 1vh; }
.chapter-notes .gi-prose     { grid-column: 3 / span 5; grid-row: 3; margin-top: 2vh; }
.chapter-notes .gi-decor-a   { grid-column: 9 / span 3; grid-row: 2 / span 2; transform: translateY(-6%); }
.chapter-notes .gi-decor-b   { grid-column: 8 / span 4; grid-row: 4; transform: translate(-8%, -18%); }

/* ----- Chapter 3 (palette) ----- */
.chapter-palette .gi-label-r    { grid-column: 7 / span 5; grid-row: 1; margin-top: 2vh; }
.chapter-palette .gi-headline-r { grid-column: 4 / span 8; grid-row: 2; margin-top: 1vh; text-align: right; }
.chapter-palette .gi-prose-r    { grid-column: 7 / span 5; grid-row: 3; text-align: right; justify-self: end; }
.chapter-palette .gi-prose-r p  { margin-left: auto; }
.chapter-palette .gi-palette    { grid-column: 2 / span 8; grid-row: 4; margin-top: 2vh; }
.chapter-palette .gi-decor-c    { grid-column: 10 / span 3; grid-row: 3 / span 2; transform: translateY(10%); align-self: center; }

/* ----- Chapter 4 (practice / counters) ----- */
.chapter-practice .gi-label     { grid-column: 2 / span 4; grid-row: 1; margin-top: 2vh; }
.chapter-practice .gi-headline  { grid-column: 2 / span 7; grid-row: 2; margin-top: 1vh; }
.chapter-practice .gi-prose     { grid-column: 3 / span 5; grid-row: 3; margin-top: 1vh; }
.chapter-practice .gi-counters  { grid-column: 1 / span 12; grid-row: 4; margin-top: 3vh; }

/* ----- Chapter 5 (motifs) ----- */
.chapter-motifs .gi-label-r    { grid-column: 8 / span 4; grid-row: 1; margin-top: 2vh; text-align: right; }
.chapter-motifs .gi-headline-r { grid-column: 4 / span 8; grid-row: 2; text-align: right; }
.chapter-motifs .gi-motifs     { grid-column: 2 / span 10; grid-row: 3; margin-top: 3vh; }

/* ----- Chapter 6 (archive) ----- */
.chapter-archive .gi-label         { grid-column: 2 / span 4; grid-row: 1; margin-top: 2vh; }
.chapter-archive .gi-headline      { grid-column: 2 / span 8; grid-row: 2; margin-top: 1vh; }
.chapter-archive .gi-archive-prose { grid-column: 3 / span 6; grid-row: 3; margin-top: 1vh; }
.chapter-archive .gi-archive-decor {
    grid-column: 9 / span 4;
    grid-row: 2 / span 2;
    position: relative;
    transform: translateY(6%);
}

.chapter-archive .gi-archive-decor .blob-inline {
    width: 100%;
    max-width: 320px;
}

.chapter-archive .gi-archive-decor .squiggle-vertical {
    position: absolute;
    top: 10%;
    right: -10%;
    width: 60px;
    height: 300px;
}

/* ---------- Mobile collapse of broken-grid ---------- */
@media (max-width: 820px) {
    .broken-grid > * {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
        transform: none !important;
        text-align: left !important;
    }
    .chapter-palette .gi-prose-r p { margin-left: 0; }
    .chapter { padding: 8vh 1.25rem; }
}

/* ======================================================================
   CHAPTER 1 — Hero
   ====================================================================== */
.chapter-hero {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 8vh 1.25rem;
}

.hero-canvas {
    position: relative;
    width: 100%;
    max-width: var(--max-w);
    height: 70vh;
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(3.2rem, 12vw, 9rem);
    color: var(--burnt-walnut);
    letter-spacing: -0.03em;
    line-height: 1;
    display: flex;
    gap: 0.02em;
    margin: 0;
    position: relative;
    z-index: 2;
}

.wm-letter,
.wm-dot {
    display: inline-block;
    transform: translateY(calc((var(--i) % 3 - 1) * 0.18em));
    opacity: 0;
    animation: wmIn 1.1s var(--ease-serene) forwards;
    animation-delay: calc(160ms * var(--i));
}

.wm-dot {
    color: var(--terracotta);
}

.wm-letter:nth-child(2) { color: var(--terracotta); } /* the "6" */
.wm-letter:nth-child(5) { color: var(--sage-moss); }  /* first b */

@keyframes wmIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(calc((var(--i) % 3 - 1) * 0.18em)); }
}

.hero-sub {
    font-family: var(--font-prose);
    font-style: italic;
    color: var(--river-pebble);
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    margin-top: 2rem;
    text-align: center;
    max-width: 36ch;
    position: relative;
    z-index: 2;
    opacity: 0;
    animation: subIn 1.6s 1.6s var(--ease-serene) forwards;
}

@keyframes subIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Blobs ---------- */
.blob {
    position: absolute;
    pointer-events: none;
    will-change: transform;
}

.blob-hero { width: 46vw; max-width: 640px; height: auto; z-index: 1; }
.blob-hero.blob-a { top: -6%; left: 6%;  animation: blob-drift-a 28s var(--ease-serene) infinite; }
.blob-hero.blob-b { bottom: -10%; right: 2%; animation: blob-drift-b 32s var(--ease-serene) infinite; }
.blob-hero.blob-c { top: 20%; right: 20%; width: 28vw; max-width: 360px; opacity: 0.8; animation: blob-drift-c 26s var(--ease-serene) infinite; }

@keyframes blob-drift-a {
    0%, 100% { transform: translate(0,0) scale(1) rotate(0deg); }
    33%      { transform: translate(22px,-24px) scale(1.03) rotate(3deg); }
    66%      { transform: translate(-14px,18px) scale(0.97) rotate(-2deg); }
}
@keyframes blob-drift-b {
    0%, 100% { transform: translate(0,0) scale(1) rotate(0deg); }
    33%      { transform: translate(-20px,16px) scale(1.04) rotate(-3deg); }
    66%      { transform: translate(14px,-10px) scale(0.98) rotate(2deg); }
}
@keyframes blob-drift-c {
    0%, 100% { transform: translate(0,0) scale(1) rotate(0deg); }
    33%      { transform: translate(16px,14px) scale(1.05) rotate(1deg); }
    66%      { transform: translate(-18px,-6px) scale(0.96) rotate(-2deg); }
}

.blob-interstitial {
    position: absolute;
    width: 220px;
    height: auto;
    top: 10%;
    left: 14%;
    animation: blob-drift-a 30s var(--ease-serene) infinite;
    opacity: 0.85;
}
.blob-interstitial.blob-alt {
    left: auto;
    right: 12%;
    top: 20%;
    width: 180px;
    animation: blob-drift-b 34s var(--ease-serene) infinite;
}

.blob-inline {
    width: 90%;
    height: auto;
    max-width: 320px;
    animation: blob-drift-c 30s var(--ease-serene) infinite;
}

/* ---------- Small decorative fragments ---------- */
.frag { position: absolute; pointer-events: none; z-index: 2; }

.frag-hero-tl {
    top: 6%;
    left: 6%;
    width: 120px;
    height: 30px;
    opacity: 0.7;
    animation: frag-float 9s ease-in-out infinite;
}
.frag-hero-br {
    bottom: 8%;
    right: 8%;
    width: 160px;
    height: 80px;
    opacity: 0.9;
}
.frag-closing {
    top: 20%;
    left: 8%;
    width: 100px;
    height: 25px;
    opacity: 0.6;
    animation: frag-float 11s ease-in-out infinite;
}

@keyframes frag-float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-6px) rotate(-2deg); }
}

/* ---------- Squiggles ---------- */
.squiggle {
    position: absolute;
    width: 80%;
    height: 80px;
    left: 10%;
    top: 40%;
}

.squiggle path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.6s var(--ease-serene);
}
.squiggle.drawn path { stroke-dashoffset: 0; }

.squiggle-vertical path {
    stroke-dasharray: 900;
    stroke-dashoffset: 900;
    transition: stroke-dashoffset 1.8s var(--ease-serene);
}
.reveal.in-view .squiggle-vertical path { stroke-dashoffset: 0; }

/* ======================================================================
   CHAPTER 3 — Palette list
   ====================================================================== */
.palette-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.1rem;
}

.swatch {
    background: var(--warm-linen);
    border: 1px solid rgba(156,145,131,0.3);
    border-radius: 10px;
    padding: 0.9rem 0.9rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    position: relative;
    overflow: hidden;
    transition: transform .6s var(--ease-serene), box-shadow .6s var(--ease-serene);
}

.swatch::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(135deg,
        rgba(59,47,36,0.05) 0 6px,
        transparent 6px 14px);
    opacity: 0;
    transition: opacity .6s var(--ease-serene);
    pointer-events: none;
}

.swatch:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px -14px rgba(43,31,22,0.25);
}
.swatch:hover::before { opacity: 1; }

.swatch .sw {
    display: block;
    height: 46px;
    border-radius: 6px;
    background: var(--swatch);
    border: 1px solid rgba(43,31,22,0.08);
}

.swatch .sw-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--burnt-walnut);
    letter-spacing: -0.01em;
}

.swatch .sw-hex {
    font-family: var(--font-label);
    font-size: 0.72rem;
    color: var(--river-pebble);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ======================================================================
   CHAPTER 4 — Counters
   ====================================================================== */
.gi-counters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: clamp(1rem, 3vw, 2.5rem);
    justify-items: center;
}

.counter-cell {
    position: relative;
    width: 180px;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.counter-ring {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 140px;
    animation: ring-wobble 10s ease-in-out infinite;
}

.counter-cell:nth-child(2) .counter-ring { animation-duration: 11s; animation-direction: reverse; }
.counter-cell:nth-child(3) .counter-ring { animation-duration: 13s; }
.counter-cell:nth-child(4) .counter-ring { animation-duration: 12s; animation-direction: reverse; }

@keyframes ring-wobble {
    0%, 100% { transform: translateX(-50%) rotate(0deg); }
    50%      { transform: translateX(-50%) rotate(2deg); }
}

.counter-value {
    position: relative;
    z-index: 1;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 4vw, 3.2rem);
    color: var(--burnt-walnut);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-top: 14px;
}

.counter-label {
    font-family: var(--font-label);
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--river-pebble);
    margin-top: 18px;
    max-width: 14ch;
    line-height: 1.4;
}

/* ======================================================================
   CHAPTER 5 — Motif cards
   ====================================================================== */
.gi-motifs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: clamp(1rem, 2vw, 1.8rem);
}

.motif-card {
    background: var(--damp-clay);
    border-radius: 12px;
    padding: 1.4rem 1.2rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform .8s var(--ease-serene), box-shadow .8s var(--ease-serene);
}

.motif-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: repeating-linear-gradient(135deg,
        var(--umber-earth) 0 6px,
        var(--damp-clay)   6px 12px);
    opacity: 0.6;
}

.motif-card:nth-child(1)::before { background: repeating-linear-gradient(135deg, var(--terracotta) 0 6px, var(--damp-clay) 6px 12px); }
.motif-card:nth-child(2)::before { background: repeating-linear-gradient(135deg, var(--sage-moss) 0 6px, var(--damp-clay) 6px 12px); }
.motif-card:nth-child(3)::before { background: repeating-linear-gradient(135deg, var(--umber-earth) 0 6px, var(--damp-clay) 6px 12px); }
.motif-card:nth-child(4)::before { background: repeating-linear-gradient(135deg, var(--marigold) 0 6px, var(--damp-clay) 6px 12px); }

.motif-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px -16px rgba(43,31,22,0.28);
}

.motif-ill {
    width: 80px;
    height: 80px;
    display: block;
    margin-bottom: 0.8rem;
}

.motif-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--burnt-walnut);
    margin: 0 0 0.4em 0;
}

.motif-desc {
    font-size: 0.95rem;
    color: var(--umber-earth);
    line-height: 1.6;
    margin: 0;
    max-width: none;
}

/* Small shapes in-grid (triangle, terrazzo) */
.shape-triangle,
.shape-terrazzo {
    width: 100%;
    height: auto;
    max-width: 240px;
    filter: drop-shadow(0 12px 24px rgba(43,31,22,0.08));
}

/* ======================================================================
   CHAPTER 7 — Closing
   ====================================================================== */
.chapter-closing {
    min-height: 100vh;
    text-align: center;
}

.closing-canvas {
    height: 80vh;
}

.closing-blob {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70vw;
    max-width: 720px;
    opacity: 0.6;
    animation: blob-drift-a 36s var(--ease-serene) infinite;
}

.closing-copy {
    position: relative;
    z-index: 2;
}

.closing-eyebrow {
    font-family: var(--font-label);
    font-size: 0.78rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--river-pebble);
    margin-bottom: 1.2rem;
}

.closing-mark {
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 7vw, 5.2rem);
    font-weight: 600;
    color: var(--burnt-walnut);
    letter-spacing: -0.02em;
    margin: 0 0 0.6rem 0;
}

.closing-note {
    font-style: italic;
    color: var(--river-pebble);
    font-size: clamp(0.95rem, 1.3vw, 1.1rem);
    max-width: 32ch;
    margin: 0 auto;
}

/* ======================================================================
   Reveal animations (scroll-triggered)
   ====================================================================== */
.reveal .reveal-child {
    opacity: 0;
    transform: translateY(30px);
    transition:
        opacity 800ms var(--ease-serene),
        transform 800ms var(--ease-serene);
    transition-delay: var(--d, 0ms);
}

.reveal.in-view .reveal-child {
    opacity: 1;
    transform: translateY(0);
}

/* ======================================================================
   Footer
   ====================================================================== */
.footer {
    position: relative;
    padding: 4rem clamp(1.25rem, 5vw, 5rem) 3rem;
    color: var(--river-pebble);
    border-top: 1px solid rgba(156,145,131,0.25);
    background: linear-gradient(to bottom, transparent, rgba(212,196,174,0.35));
}

.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem 2rem;
    font-family: var(--font-label);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.footer-mark {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--burnt-walnut);
    letter-spacing: -0.01em;
    text-transform: none;
}

.footer-tag,
.footer-colophon { color: var(--river-pebble); }

@media (max-width: 640px) {
    .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* ======================================================================
   Reduced motion — keep calm even calmer
   ====================================================================== */
@media (prefers-reduced-motion: reduce) {
    .blob,
    .blob-hero,
    .blob-interstitial,
    .blob-inline,
    .closing-blob,
    .counter-ring,
    .frag { animation: none !important; }

    .reveal .reveal-child {
        transition: opacity 400ms linear;
        transform: none;
    }
    .reveal.in-view .reveal-child { transform: none; }
    html { scroll-behavior: auto; }
}
