/* ============================================
   blockchain.day -- Styles
   Grainy-textured scholarly dashboard
   ============================================ */

/* ---- CSS Custom Properties ---- */
:root {
    /* Palette from DESIGN.md */
    --aged-parchment: #F5EDE0;
    --foxed-paper: #EDE2D0;
    --cork-board: #D4A574;
    --espresso-brown: #3E2712;
    --deep-umber: #4A3728;
    --tobacco-brown: #6B5344;
    --burnt-sienna: #C4632A;
    --oxidized-copper: #8B6914;
    --terracotta-bloom: #D4845A;
    --printers-black: #1A1108;
    --pressed-sage: #7A8B5C;
    --dried-fern: #4A5A36;
    --cool-tint: #6B7B8C;

    /* Typography sizing */
    --heading-primary: clamp(1.8rem, 4vw, 3.2rem);
    --heading-secondary: clamp(1.2rem, 2.5vw, 2rem);
    --body-size: clamp(1rem, 1.2vw, 1.15rem);
    --caption-size: clamp(0.75rem, 0.9vw, 0.85rem);

    /* Scroll-responsive grain frequency (updated by JS) */
    --grain-frequency: 0.65;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--aged-parchment);
    color: var(--deep-umber);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: var(--body-size);
    line-height: 1.75;
    overflow-x: hidden;
}

/* ---- SVG Filters (Hidden) ---- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ============================================
   TITLE PAGE
   ============================================ */
#title-page {
    position: relative;
    width: 100vw;
    height: 100vh;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--aged-parchment);
    overflow: hidden;
}

/* Grain overlay on title page */
#title-page::before {
    content: '';
    position: absolute;
    inset: 0;
    filter: url(#grain-neutral);
    pointer-events: none;
    z-index: 1;
}

.title-page-inner {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    height: 100%;
    padding: 2rem;
}

/* Title Content */
.title-content {
    text-align: center;
    z-index: 3;
    flex-shrink: 0;
}

.title-main {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--espresso-brown);
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 0;
}

.title-day {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: var(--burnt-sienna);
    margin-top: 0.1em;
    margin-bottom: 1.5rem;
}

.title-rule {
    display: block;
    width: clamp(180px, 40vw, 300px);
    height: auto;
    margin: 0 auto 1.5rem;
}

.title-subtitle {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-weight: 400;
    font-size: var(--caption-size);
    color: var(--tobacco-brown);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* ---- Fern Fronds on Title Page ---- */
.title-fern {
    position: absolute;
    bottom: 0;
    width: clamp(60px, 8vw, 100px);
    height: 70vh;
    z-index: 2;
    opacity: 0.7;
}

.title-fern-left {
    left: clamp(2rem, 8vw, 10rem);
}

.title-fern-right {
    right: clamp(2rem, 8vw, 10rem);
}

.fern-svg {
    width: 100%;
    height: 100%;
}

/* Fern sway animation -- subtle oscillation */
@keyframes fernSway {
    0%, 100% { transform: rotate(-0.5deg); }
    50% { transform: rotate(0.5deg); }
}

.fern-sway {
    transform-origin: bottom center;
    animation: fernSway 8s ease-in-out infinite;
}

/* ---- Scroll Indicator ---- */
.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    opacity: 0.5;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(6px); }
}

.scroll-indicator {
    animation: scrollBounce 3s ease-in-out infinite;
}

/* ============================================
   HEADER
   ============================================ */
#site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--aged-parchment);
    z-index: 100;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
    border-bottom: 1px solid rgba(107, 83, 68, 0.15);
}

#site-header.visible {
    opacity: 1;
    pointer-events: auto;
}

.header-inner {
    padding: 0 2rem;
    display: flex;
    align-items: center;
}

.header-logo {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--espresso-brown);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.02em;
}

.header-sprig {
    flex-shrink: 0;
}

/* ============================================
   NAVIGATION NODES (Fixed Right Side)
   ============================================ */
#panel-nav {
    position: fixed;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

#panel-nav.visible {
    opacity: 1;
    pointer-events: auto;
}

.nav-node {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid var(--tobacco-brown);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.nav-node:hover {
    transform: scale(1.3);
    border-color: var(--burnt-sienna);
}

.nav-node.active {
    background-color: var(--burnt-sienna);
    border-color: var(--burnt-sienna);
}

/* ============================================
   DASHBOARD (Three-Panel Grid)
   ============================================ */
#dashboard {
    position: relative;
    min-height: 100vh;
    padding-top: 60px; /* header height */
    opacity: 0;
    transition: opacity 0.8s ease;
}

#dashboard.visible {
    opacity: 1;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-areas: "herbarium ledger fieldnotes";
    gap: 1.5rem;
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
    min-height: calc(100vh - 60px);
}

/* ---- Panel Shared Styles ---- */
.panel-herbarium,
.panel-ledger,
.panel-fieldnotes {
    position: relative;
    padding: 2rem;
}

/* Grain overlays per panel */
.panel-herbarium::before,
.panel-ledger::before,
.panel-fieldnotes::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    border-radius: 2px;
}

.panel-herbarium::before {
    filter: url(#grain-warm);
}

.panel-ledger::before {
    filter: url(#grain-neutral);
}

.panel-fieldnotes::before {
    filter: url(#grain-cool);
}

/* ---- Herbarium Panel (Left) ---- */
.panel-herbarium {
    grid-area: herbarium;
    background-color: var(--foxed-paper);
    overflow: hidden;
}

.herbarium-specimen {
    margin-bottom: 3rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.botanical-illustration {
    width: 100%;
    max-width: 160px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.specimen-caption {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-size: var(--caption-size);
    color: var(--tobacco-brown);
    margin-top: 1rem;
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

.caption-note {
    font-style: normal;
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-size: calc(var(--caption-size) * 0.9);
    color: var(--tobacco-brown);
    display: block;
    margin-top: 0.3rem;
    letter-spacing: 0.02em;
}

/* ---- SVG Botanical Growth Animation ---- */
.grow-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease-out;
}

.grow-leaf {
    opacity: 0;
    transition: opacity 0.5s ease-out 1.5s;
}

.herbarium-specimen.in-view .grow-path {
    stroke-dashoffset: 0;
}

.herbarium-specimen.in-view .grow-leaf {
    opacity: 1;
}

/* ---- Ledger Panel (Center) ---- */
.panel-ledger {
    grid-area: ledger;
    background-color: var(--aged-parchment);
    position: relative;
    z-index: 1;
}

.ledger-entry {
    margin-bottom: 3rem;
    position: relative;
    z-index: 1;
}

.entry-header {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-weight: 400;
    font-size: var(--caption-size);
    color: var(--tobacco-brown);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.entry-number {
    color: var(--tobacco-brown);
}

.entry-dash {
    color: var(--tobacco-brown);
    opacity: 0.5;
}

.entry-title-text {
    color: var(--tobacco-brown);
}

.entry-body {
    position: relative;
    z-index: 1;
}

.entry-body p {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: var(--body-size);
    color: var(--deep-umber);
    line-height: 1.75;
    max-width: 38em;
    margin-bottom: 1.5em;
}

/* First-line indent (not on first paragraph) */
.entry-body p + p {
    text-indent: 1.5em;
}

/* Ink density variation (set by JS) */
.entry-body p {
    opacity: var(--ink-density, 1);
}

/* ---- Section Divider (Dandelion Seed Head) ---- */
.entry-divider {
    display: flex;
    justify-content: center;
    margin: 2.5rem 0;
}

.divider-seedhead {
    width: 60px;
    height: 60px;
}

/* Seed drift animation */
@keyframes seedDrift1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(5px, -8px); }
}

@keyframes seedDrift2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-7px, -5px); }
}

@keyframes seedDrift3 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(4px, 6px); }
}

@keyframes seedDrift4 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-5px, 7px); }
}

@keyframes seedDrift5 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(8px, -3px); }
}

@keyframes seedDrift6 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-3px, -9px); }
}

@keyframes seedDrift7 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(6px, 4px); }
}

.seed-drift:nth-child(1) { animation: seedDrift1 12s ease-in-out infinite; }
.seed-drift:nth-child(2) { animation: seedDrift2 12s ease-in-out infinite 0.8s; }
.seed-drift:nth-child(3) { animation: seedDrift3 12s ease-in-out infinite 1.6s; }
.seed-drift:nth-child(4) { animation: seedDrift4 12s ease-in-out infinite 2.4s; }
.seed-drift:nth-child(5) { animation: seedDrift5 12s ease-in-out infinite 3.2s; }
.seed-drift:nth-child(6) { animation: seedDrift6 12s ease-in-out infinite 4.0s; }
.seed-drift:nth-child(7) { animation: seedDrift7 12s ease-in-out infinite 4.8s; }

/* ---- Ledger Colophon ---- */
.ledger-colophon {
    margin-top: 3rem;
    padding-top: 2rem;
    position: relative;
    z-index: 1;
}

.colophon-rule {
    display: block;
    width: 100%;
    max-width: 300px;
    height: auto;
    margin: 0 auto 1.5rem;
}

.colophon-text {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-size: var(--caption-size);
    color: var(--tobacco-brown);
    text-align: center;
    letter-spacing: 0.03em;
    max-width: 40em;
    margin: 0 auto;
    line-height: 1.6;
}

/* ---- Field Notes Panel (Right) ---- */
.panel-fieldnotes {
    grid-area: fieldnotes;
    background-color: var(--foxed-paper);
    position: relative;
    overflow: hidden;
    border-top: 1px solid #6B7B8C;
}

/* Graph paper background */
.panel-fieldnotes::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, rgba(212, 165, 116, 0.15) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(212, 165, 116, 0.15) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 0;
}

.fieldnote {
    position: relative;
    z-index: 1;
    margin-bottom: 2.5rem;
    padding: 1rem 1rem 1rem 1.5rem;
}

.fieldnote-pin {
    position: absolute;
    top: 0;
    left: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--burnt-sienna);
    box-shadow: 0 1px 3px rgba(62, 39, 18, 0.2);
    transition: transform 0.3s ease;
}

.fieldnote:hover .fieldnote-pin {
    transform: rotate(5deg);
}

.fieldnote-label {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-weight: 400;
    font-size: var(--caption-size);
    color: var(--tobacco-brown);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.fieldnote-content {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: calc(var(--body-size) * 0.9);
    color: var(--deep-umber);
    line-height: 1.65;
}

.fieldnote-content em {
    font-style: italic;
    color: var(--espresso-brown);
}

.fieldnote-quote {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: calc(var(--body-size) * 0.9);
    color: var(--espresso-brown);
    line-height: 1.65;
    margin: 0.5rem 0;
    padding-left: 1rem;
    border-left: 2px solid var(--burnt-sienna);
}

.fieldnote-ref {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-size: calc(var(--caption-size) * 0.9);
    color: var(--tobacco-brown);
    margin-top: 0.5rem;
    letter-spacing: 0.03em;
}

.fieldnote-data {
    margin-top: 0.5rem;
}

.fieldnote-data p {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-size: var(--caption-size);
    color: var(--deep-umber);
    line-height: 1.8;
    letter-spacing: 0.02em;
}

.data-key {
    color: var(--tobacco-brown);
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* ============================================
   LINKS
   ============================================ */
a {
    color: var(--burnt-sienna);
    text-decoration: none;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--burnt-sienna);
    transition: width 0.4s ease;
}

a:hover::after {
    width: 100%;
}

a:hover {
    color: var(--oxidized-copper);
}

/* ============================================
   LARGE SCREEN ENHANCEMENTS (1440px+)
   ============================================ */
@media (min-width: 1440px) {
    .dashboard-grid {
        gap: 3rem;
    }

    .panel-herbarium,
    .panel-ledger,
    .panel-fieldnotes {
        box-shadow: 0 2px 8px rgba(62, 39, 18, 0.12);
        border-radius: 2px;
    }
}

/* ============================================
   RESPONSIVE: COLLAPSE TO SINGLE COLUMN
   ============================================ */
@media (max-width: 1023px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "ledger";
        gap: 0;
    }

    .panel-herbarium {
        display: none;
    }

    .panel-fieldnotes {
        display: none;
    }

    /* Show field notes inline below each entry on mobile */
    .panel-ledger {
        padding: 1.5rem 1rem;
    }

    #panel-nav {
        display: none;
    }

    .title-fern {
        opacity: 0.4;
        width: 50px;
    }

    .title-fern-left {
        left: 1rem;
    }

    .title-fern-right {
        right: 1rem;
    }

    .entry-body p {
        max-width: 100%;
    }
}

/* Medium screens: two columns */
@media (min-width: 1024px) and (max-width: 1279px) {
    .dashboard-grid {
        grid-template-columns: 1.2fr 2fr;
        grid-template-areas:
            "herbarium ledger";
    }

    .panel-fieldnotes {
        display: none;
    }
}

/* ============================================
   SELECTION STYLES
   ============================================ */
::selection {
    background-color: rgba(196, 99, 42, 0.2);
    color: var(--espresso-brown);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--aged-parchment);
}

::-webkit-scrollbar-thumb {
    background-color: var(--tobacco-brown);
    border-radius: 4px;
    border: 2px solid var(--aged-parchment);
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--burnt-sienna);
}
