/* ============================================
   namu.biz — Coastal Field Notebook
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --driftwood-fog: #e8e4de;
    --storm-slate: #2b3a3f;
    --root-dark: #1a2422;
    --lichen-cream: #d4cfc6;
    --tidal-teal: #3d8b7a;
    --ring-amber: #c4863a;
    --salt-cyan: #5eb8a9;
    --fog-line: #b8b0a4;
    --deep-kelp: #1a3330;
    --coastal-dawn: #7abfb0;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--driftwood-fog);
    color: var(--root-dark);
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.75;
    letter-spacing: 0.03em;
    overflow-x: hidden;
    position: relative;
}

/* --- Field Grid Overlay --- */
#field-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(107,142,135,0.08) 0px,
            rgba(107,142,135,0.08) 1px,
            transparent 1px,
            transparent calc(100% / 16)
        );
}

/* --- Cursor Spotlight --- */
#spotlight {
    position: fixed;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(94,184,169,0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 100;
    transform: translate(-100px, -100px);
    will-change: transform;
}

/* --- Depth Indicator --- */
#depth-indicator {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--tidal-teal);
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.depth-label {
    opacity: 0.6;
}

.cursor-blink {
    animation: blink 1s step-end infinite;
}

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

/* --- Left Margin Annotations --- */
#margin-annotations {
    position: absolute;
    left: 0;
    top: 0;
    width: calc(100% / 8);
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.margin-note {
    position: absolute;
    left: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fog-line);
    opacity: 0.5;
    line-height: 1.5;
}

/* --- Section Styles --- */
.field-section {
    min-height: 100vh;
    width: 100%;
    position: relative;
    padding: 6vh 8vw 6vh calc(100% / 8 + 2vw);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.field-section.dark-section {
    background-color: var(--storm-slate);
    color: var(--lichen-cream);
}

.section-timestamp {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--tidal-teal);
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms cubic-bezier(0.25,0.46,0.45,0.94), transform 800ms cubic-bezier(0.25,0.46,0.45,0.94);
}

.section-timestamp.light {
    color: var(--salt-cyan);
}

.section-header {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    color: var(--root-dark);
    margin-bottom: 0.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms cubic-bezier(0.25,0.46,0.45,0.94) 100ms, transform 800ms cubic-bezier(0.25,0.46,0.45,0.94) 100ms;
}

.section-header.light {
    color: var(--lichen-cream);
}

.section-note {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--tidal-teal);
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms cubic-bezier(0.25,0.46,0.45,0.94) 200ms, transform 800ms cubic-bezier(0.25,0.46,0.45,0.94) 200ms;
}

.section-note.light {
    color: var(--coastal-dawn);
}

/* Visible state */
.field-section.visible .section-timestamp,
.field-section.visible .section-header,
.field-section.visible .section-note {
    opacity: 1;
    transform: translateY(0);
}

/* --- Section 0: Specimen Cover --- */
#section-cover {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-left: 8vw;
    min-height: 100vh;
}

.cover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

#growth-ring-container {
    position: relative;
    width: clamp(250px, 40vw, 450px);
    height: clamp(250px, 40vw, 450px);
}

#growth-ring-svg {
    width: 100%;
    height: 100%;
    animation: rotate-ring 120s linear infinite;
    will-change: transform;
}

@keyframes rotate-ring {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#ring-annotations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.ring-annotation {
    position: absolute;
    font-family: 'Caveat', cursive;
    font-size: 0.8rem;
    color: var(--ring-amber);
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--root-dark);
    line-height: 1;
}

.hero-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--tidal-teal);
}

/* --- Section Dividers --- */
.section-divider {
    width: 100%;
    padding: 1rem 0;
    position: relative;
    z-index: 5;
}

.divider-line {
    width: 100%;
    height: 30px;
    display: block;
}

.divider-motif {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* --- Root Network --- */
#root-network {
    width: 100%;
    max-width: 1000px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms cubic-bezier(0.25,0.46,0.45,0.94) 300ms, transform 800ms cubic-bezier(0.25,0.46,0.45,0.94) 300ms;
}

.field-section.visible #root-network {
    opacity: 1;
    transform: translateY(0);
}

#root-svg {
    width: 100%;
    height: auto;
}

.root-path {
    fill: none;
    stroke: var(--tidal-teal);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s cubic-bezier(0.25,0.46,0.45,0.94);
}

.field-section.visible .root-path {
    stroke-dashoffset: 0;
}

.root-node {
    fill: var(--driftwood-fog);
    stroke: var(--tidal-teal);
    stroke-width: 1.5;
    transition: fill 0.3s;
    cursor: pointer;
}

.root-node:hover {
    fill: var(--salt-cyan);
}

.root-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 9px;
    fill: var(--root-dark);
    letter-spacing: 0.08em;
}

/* --- Ring Archive --- */
#ring-archive {
    width: 100%;
    overflow: visible;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms cubic-bezier(0.25,0.46,0.45,0.94) 300ms, transform 800ms cubic-bezier(0.25,0.46,0.45,0.94) 300ms;
}

.field-section.visible #ring-archive {
    opacity: 1;
    transform: translateY(0);
}

#ring-archive-svg {
    width: 100%;
    height: auto;
}

/* --- Tidal Log --- */
#tidal-table {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    width: 100%;
    max-width: 900px;
}

.tidal-row {
    display: grid;
    grid-template-columns: 120px 80px 100px 80px 1fr;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(184,176,164,0.15);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 400ms cubic-bezier(0.25,0.46,0.45,0.94), transform 400ms cubic-bezier(0.25,0.46,0.45,0.94);
}

.field-section.visible .tidal-row {
    opacity: 1;
    transform: translateY(0);
}

.tidal-header {
    color: var(--salt-cyan);
    font-weight: 400;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--fog-line);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.tidal-wave-divider {
    grid-column: 1 / -1;
    height: 20px;
    position: relative;
}

.tidal-wave-divider svg {
    width: 100%;
    height: 100%;
}

/* Tidal Waves */
#tidal-waves {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20%;
    pointer-events: none;
    overflow: hidden;
}

.wave {
    position: absolute;
    bottom: 0;
    left: -5%;
    width: 110%;
    height: 100%;
}

.wave-1 {
    background: var(--salt-cyan);
    opacity: 0.3;
    animation: wave-move 8s ease-in-out infinite alternate;
    clip-path: polygon(0% 70%, 5% 65%, 10% 60%, 15% 58%, 20% 60%, 25% 65%, 30% 68%, 35% 65%, 40% 60%, 45% 55%, 50% 58%, 55% 63%, 60% 68%, 65% 65%, 70% 60%, 75% 58%, 80% 62%, 85% 67%, 90% 65%, 95% 60%, 100% 63%, 100% 100%, 0% 100%);
}

.wave-2 {
    background: var(--tidal-teal);
    opacity: 0.2;
    animation: wave-move 12s ease-in-out infinite alternate-reverse;
    clip-path: polygon(0% 75%, 5% 70%, 10% 65%, 15% 68%, 20% 72%, 25% 68%, 30% 63%, 35% 60%, 40% 63%, 45% 68%, 50% 72%, 55% 68%, 60% 63%, 65% 60%, 70% 63%, 75% 68%, 80% 72%, 85% 68%, 90% 63%, 95% 68%, 100% 72%, 100% 100%, 0% 100%);
}

.wave-3 {
    background: var(--coastal-dawn);
    opacity: 0.1;
    animation: wave-move 18s ease-in-out infinite alternate;
    clip-path: polygon(0% 80%, 5% 75%, 10% 72%, 15% 75%, 20% 78%, 25% 75%, 30% 70%, 35% 68%, 40% 72%, 45% 76%, 50% 78%, 55% 75%, 60% 70%, 65% 68%, 70% 72%, 75% 76%, 80% 78%, 85% 75%, 90% 70%, 95% 74%, 100% 78%, 100% 100%, 0% 100%);
}

@keyframes wave-move {
    0% { transform: translateX(0); }
    100% { transform: translateX(-3%); }
}

/* --- Specimen Index --- */
#specimen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 2rem;
    width: 100%;
    max-width: 1100px;
}

.specimen-card {
    border: 1px solid var(--fog-line);
    padding: 1.5rem;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms cubic-bezier(0.25,0.46,0.45,0.94), transform 600ms cubic-bezier(0.25,0.46,0.45,0.94);
}

.field-section.visible .specimen-card {
    opacity: 1;
    transform: translateY(0);
}

.specimen-id {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: var(--tidal-teal);
    margin-bottom: 0.5rem;
}

.specimen-name {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--root-dark);
    margin-bottom: 0.3rem;
}

.specimen-latin {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--tidal-teal);
    margin-bottom: 0.8rem;
}

.specimen-data {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--fog-line);
    line-height: 1.8;
    font-variant-numeric: tabular-nums;
}

.specimen-sketch {
    margin-top: 1rem;
}

.specimen-sketch svg {
    width: 100%;
    height: 60px;
}

/* --- Ink Trail --- */
#ink-trail-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99;
}

.ink-dot {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: rgba(61,139,122,0.4);
    opacity: 1;
    transition: opacity 1.5s ease-out;
    pointer-events: none;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #margin-annotations {
        display: none;
    }

    .field-section {
        padding: 4vh 5vw;
    }

    #section-cover {
        padding-left: 5vw;
    }

    #depth-indicator {
        writing-mode: horizontal-tb;
        top: auto;
        bottom: 10px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    .tidal-row {
        grid-template-columns: 1fr 1fr;
        font-size: 0.7rem;
    }

    #spotlight {
        display: none;
    }
}
