/* ============================================
   reiwa.bar — Light-Academia Muted Sanctum
   Morandi-inspired tonal restraint, HUD-overlay,
   morph transitions, hand-drawn warmth,
   candle-atmospheric study glow
   ============================================ */

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

:root {
    --muted-deep: #1A1810;
    --muted-warm: #4A4438;
    --muted-gold: #8A7A58;
    --muted-sage: #7A8868;
    --study-cream: #F8F4EE;
    --hud-surface: #FAF8F2;
    --candle-glow: rgba(190, 170, 130, 0.05);
    --compass-line: rgba(100, 90, 70, 0.15);
    --morph-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.85;
    color: var(--muted-warm);
    background-color: var(--study-cream);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Candle Atmospheric Glow --- */
.candle-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 50% 15%, rgba(190, 170, 130, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 30% 60%, rgba(190, 170, 130, 0.02) 0%, transparent 40%),
        radial-gradient(circle at 70% 80%, rgba(190, 170, 130, 0.02) 0%, transparent 35%);
    pointer-events: none;
    z-index: 100;
}

/* --- Hand-Drawn Sketchbook Background --- */
.sketch-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 2s ease;
}

.sketch-bg.visible {
    opacity: 1;
}

.sketch-line {
    fill: none;
    stroke: #8A7A58;
    stroke-width: 1;
    opacity: 0.08;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sketch-line-faint {
    opacity: 0.04;
}

.sketch-dot {
    fill: #8A7A58;
    opacity: 0.08;
}

/* --- HUD Frame --- */
.hud-frame {
    position: relative;
    max-width: 720px;
    margin: 0 auto;
    min-height: 100vh;
    border: 1px solid var(--compass-line);
    background-color: var(--hud-surface);
    z-index: 1;
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 1s var(--ease-out-smooth), transform 1s var(--ease-out-smooth);
}

.hud-frame.materialized {
    opacity: 1;
    transform: scale(1);
}

/* --- Compass Rose Corners --- */
.compass-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.6s ease 0.5s;
}

.hud-frame.materialized .compass-corner {
    opacity: 1;
}

.compass-corner line,
.compass-corner circle {
    stroke: var(--compass-line);
    stroke-width: 1;
    fill: none;
    transition: stroke 0.3s ease, fill-opacity 0.3s ease;
}

.compass-corner circle {
    fill: var(--muted-gold);
    fill-opacity: 0.3;
}

.compass-corner:hover line {
    stroke: rgba(100, 90, 70, 0.35);
}

.compass-corner:hover circle {
    fill-opacity: 0.7;
}

.compass-tl { top: -1px; left: -1px; }
.compass-tr { top: -1px; right: -1px; }
.compass-bl { bottom: -1px; left: -1px; }
.compass-br { bottom: -1px; right: -1px; }

/* --- Status Bars --- */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 22px;
    padding: 0 16px;
    background-color: var(--study-cream);
    border-bottom: 1px solid var(--compass-line);
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--muted-gold);
    text-transform: uppercase;
}

.status-bar-bottom {
    border-bottom: none;
    border-top: 1px solid var(--compass-line);
}

.status-item {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.hud-frame.materialized .status-item {
    opacity: 1;
}

.hud-frame.materialized .status-bar-top .status-item:nth-child(1) { transition-delay: 0.7s; }
.hud-frame.materialized .status-bar-top .status-item:nth-child(2) { transition-delay: 0.9s; }
.hud-frame.materialized .status-bar-top .status-item:nth-child(3) { transition-delay: 1.1s; }
.hud-frame.materialized .status-bar-bottom .status-item:nth-child(1) { transition-delay: 0.8s; }
.hud-frame.materialized .status-bar-bottom .status-item:nth-child(2) { transition-delay: 1.0s; }
.hud-frame.materialized .status-bar-bottom .status-item:nth-child(3) { transition-delay: 1.2s; }

/* --- Content Area --- */
.content-area {
    padding: 60px 40px;
}

/* --- Hero Section --- */
.hero-section {
    text-align: center;
    padding: 80px 0 60px;
    min-height: calc(100vh - 44px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.hero-title-container {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 1.2s ease 0.4s, transform 1.2s var(--ease-out-smooth) 0.4s;
}

.hud-frame.materialized .hero-title-container {
    opacity: 1;
    transform: translateY(0);
}

.hero-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    color: var(--muted-deep);
    letter-spacing: 0.15em;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: var(--muted-gold);
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

.hero-divider {
    margin: 30px auto;
    width: 200px;
}

.divider-svg {
    width: 100%;
    height: 20px;
}

.divider-svg line {
    stroke: var(--compass-line);
    stroke-width: 1;
}

.divider-svg circle {
    fill: var(--muted-gold);
    fill-opacity: 0.4;
}

.hero-instrument-readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    opacity: 0;
    transition: opacity 0.8s ease 1.4s;
}

.hud-frame.materialized .hero-instrument-readout {
    opacity: 1;
}

/* --- Scroll Hint --- */
.hero-scroll-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 1s ease 2s;
}

.hud-frame.materialized .hero-scroll-hint {
    opacity: 0.4;
}

.hero-scroll-hint.hidden {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.scroll-hint-svg {
    width: 18px;
    height: 30px;
}

.scroll-hint-track {
    fill: none;
    stroke: var(--muted-gold);
    stroke-width: 1.5;
    opacity: 0.6;
}

.scroll-hint-dot {
    fill: var(--muted-gold);
    opacity: 0.6;
}

@keyframes scrollHintBounce {
    0%, 100% { cy: 12; }
    50% { cy: 22; }
}

.scroll-hint-dot {
    animation: scrollHintBounce 2s ease-in-out infinite;
}

/* --- Readout Styles --- */
.readout-label {
    font-family: 'Fira Code', monospace;
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--muted-gold);
    text-transform: uppercase;
}

.readout-value {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    letter-spacing: 0.1em;
    color: var(--muted-sage);
}

/* --- Section Headers --- */
.section-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 30px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--compass-line);
}

.section-number {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    color: var(--muted-gold);
    letter-spacing: 0.1em;
}

.section-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    color: var(--muted-deep);
    letter-spacing: 0.05em;
}

/* --- Morph Cards --- */
.morph-card {
    transition: all 0.5s var(--morph-ease);
    border: 1px solid var(--compass-line);
    border-radius: 2px;
    background-color: var(--hud-surface);
}

.morph-card:hover {
    border-color: rgba(100, 90, 70, 0.25);
    box-shadow: 0 4px 24px rgba(26, 24, 16, 0.04);
}

/* --- Manifesto Section --- */
.manifesto-section {
    padding: 60px 0;
}

.manifesto-content {
    padding: 36px;
}

.manifesto-content p {
    margin-bottom: 18px;
    font-weight: 300;
}

.manifesto-content p:last-child {
    margin-bottom: 0;
}

.manifesto-signature {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.signature-dash {
    color: var(--muted-gold);
    font-weight: 300;
}

.signature-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--muted-gold);
}

/* --- Observations Section --- */
.observations-section {
    padding: 60px 0;
}

.observation-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.observation-card {
    padding: 28px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.observation-card::after {
    content: '';
    position: absolute;
    bottom: 14px;
    right: 16px;
    width: 16px;
    height: 16px;
    border-right: 1.5px solid var(--muted-gold);
    border-bottom: 1.5px solid var(--muted-gold);
    transform: rotate(45deg);
    opacity: 0.3;
    transition: transform 0.5s var(--morph-ease), opacity 0.3s ease;
}

.observation-card[data-state="expanded"]::after {
    transform: rotate(-135deg);
    opacity: 0.5;
}

.observation-card[data-state="expanded"] {
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(26, 24, 16, 0.06);
}

.observation-card[data-state="expanded"] .obs-text {
    max-height: 200px;
    opacity: 1;
    margin-top: 12px;
}

.observation-card[data-state="expanded"] .obs-readout {
    max-height: 40px;
    opacity: 1;
    margin-top: 16px;
}

.obs-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
}

.obs-icon-circle {
    fill: none;
    stroke: var(--muted-gold);
    stroke-width: 1;
    opacity: 0.5;
}

.obs-icon-cross {
    fill: none;
    stroke: var(--muted-sage);
    stroke-width: 1.5;
    opacity: 0.6;
}

.obs-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--muted-deep);
}

.obs-text {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.5s var(--morph-ease), opacity 0.4s ease, margin-top 0.4s ease;
    font-weight: 300;
    font-size: 0.95rem;
    line-height: 1.8;
}

.obs-readout {
    display: flex;
    gap: 12px;
    align-items: center;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.5s var(--morph-ease), opacity 0.4s ease, margin-top 0.4s ease;
}

/* --- Readings Section --- */
.readings-section {
    padding: 60px 0;
}

.readings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.reading-instrument {
    padding: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.reading-dial {
    width: 100px;
    height: 100px;
    margin-bottom: 16px;
}

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

.dial-track {
    fill: none;
    stroke: var(--compass-line);
    stroke-width: 2;
}

.dial-progress {
    fill: none;
    stroke: var(--muted-sage);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 264;
    stroke-dashoffset: 264;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 1.8s var(--ease-out-smooth);
}

.dial-text {
    font-family: 'Fira Code', monospace;
    font-size: 18px;
    fill: var(--muted-deep);
    text-anchor: middle;
    dominant-baseline: middle;
}

.reading-label {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--muted-deep);
    display: block;
    margin-bottom: 4px;
}

.reading-unit {
    font-family: 'Fira Code', monospace;
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--muted-gold);
    text-transform: uppercase;
}

/* --- Archive Section --- */
.archive-section {
    padding: 60px 0;
}

.archive-entries {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.archive-entry {
    padding: 28px;
    display: grid;
    grid-template-columns: 80px 1fr 120px;
    gap: 24px;
    align-items: start;
}

.entry-date {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.entry-year {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--muted-deep);
    line-height: 1.2;
}

.entry-month {
    font-family: 'Fira Code', monospace;
    font-size: 9px;
    letter-spacing: 0.1em;
    color: var(--muted-gold);
}

.entry-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--muted-deep);
    margin-bottom: 8px;
}

.entry-excerpt {
    font-weight: 300;
    font-size: 0.9rem;
    line-height: 1.75;
}

.entry-instrument {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
}

.entry-bar {
    width: 100%;
    height: 3px;
    background-color: var(--compass-line);
    border-radius: 2px;
    overflow: hidden;
}

.entry-bar-fill {
    height: 100%;
    background-color: var(--muted-sage);
    border-radius: 2px;
    width: 0%;
    transition: width 1.4s var(--ease-out-smooth);
}

/* --- Coordinates Section --- */
.coordinates-section {
    padding: 60px 0;
}

.coord-display {
    padding: 32px;
}

.coord-map {
    margin-bottom: 24px;
}

.coord-svg {
    width: 100%;
    height: auto;
}

.grid-line {
    stroke: var(--compass-line);
    stroke-width: 0.5;
    stroke-dasharray: 4 4;
}

.grid-label {
    font-family: 'Fira Code', monospace;
    font-size: 7px;
    fill: var(--muted-gold);
    opacity: 0.5;
}

.coord-marker {
    fill: var(--muted-sage);
    fill-opacity: 0.6;
}

.coord-marker-ring {
    fill: none;
    stroke: var(--muted-sage);
    stroke-width: 1;
    opacity: 0.4;
}

.coord-marker-outer {
    opacity: 0.2;
    stroke-dasharray: 3 3;
}

.coord-path {
    fill: none;
    stroke: var(--muted-gold);
    stroke-width: 1;
    stroke-dasharray: 4 2;
    opacity: 0.5;
}

.coord-path-dot {
    fill: var(--muted-gold);
    opacity: 0.4;
}

.coord-label {
    font-family: 'Fira Code', monospace;
    font-size: 9px;
    fill: var(--muted-gold);
    letter-spacing: 0.15em;
}

.coord-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.coord-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.coord-key {
    font-family: 'Fira Code', monospace;
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--muted-gold);
    text-transform: uppercase;
}

.coord-val {
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    color: var(--muted-deep);
    letter-spacing: 0.05em;
}

/* --- Colophon Section --- */
.colophon-section {
    padding: 60px 0 30px;
}

.colophon-content {
    padding: 28px 36px;
}

.colophon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.colophon-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.colophon-key {
    font-family: 'Fira Code', monospace;
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--muted-gold);
    text-transform: uppercase;
}

.colophon-val {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: 0.88rem;
    color: var(--muted-warm);
    line-height: 1.6;
}

.colophon-swatches {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 2px;
}

/* --- Scroll Reveal Animations --- */
.manifesto-section,
.observations-section,
.readings-section,
.archive-section,
.coordinates-section,
.colophon-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s var(--ease-out-smooth);
}

.manifesto-section.revealed,
.observations-section.revealed,
.readings-section.revealed,
.archive-section.revealed,
.coordinates-section.revealed,
.colophon-section.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Coordinate Marker Pulse --- */
@keyframes markerPulse {
    0%, 100% { r: 12; opacity: 0.4; }
    50% { r: 16; opacity: 0.2; }
}

.coord-marker-ring:not(.coord-marker-outer) {
    animation: markerPulse 3s ease-in-out infinite;
}

@keyframes outerPulse {
    0%, 100% { r: 20; opacity: 0.2; }
    50% { r: 26; opacity: 0.1; }
}

.coord-marker-outer {
    animation: outerPulse 3s ease-in-out infinite 0.3s;
}

/* --- Candle Flicker --- */
@keyframes candleFlicker {
    0%, 100% { opacity: 1; }
    15% { opacity: 0.96; }
    30% { opacity: 1; }
    45% { opacity: 0.98; }
    60% { opacity: 1; }
    75% { opacity: 0.97; }
    90% { opacity: 1; }
}

.candle-glow {
    animation: candleFlicker 6s ease-in-out infinite;
}

/* --- Sketch Draw-in Animation --- */
@keyframes sketchDraw {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.sketch-bg.visible .sketch-line {
    stroke-dasharray: 1000;
    animation: sketchDraw 4s ease forwards;
}

/* --- Dial Hover Glow --- */
.reading-instrument:hover .dial-progress {
    stroke: var(--muted-gold);
    filter: drop-shadow(0 0 3px rgba(138, 122, 88, 0.2));
}

.reading-instrument:hover .dial-track {
    stroke: rgba(100, 90, 70, 0.25);
}

/* --- Archive Entry Hover --- */
.archive-entry:hover .entry-bar-fill {
    background-color: var(--muted-gold);
}

/* --- Coord Path Drawing --- */
@keyframes pathDraw {
    from { stroke-dashoffset: 600; }
    to { stroke-dashoffset: 0; }
}

.coordinates-section.revealed .coord-path {
    stroke-dasharray: 600;
    animation: pathDraw 2s var(--ease-out-smooth) forwards;
}

/* --- Selection Color --- */
::selection {
    background-color: rgba(138, 122, 88, 0.15);
    color: var(--muted-deep);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .content-area {
        padding: 40px 24px;
    }

    .hero-section {
        padding: 40px 0;
    }

    .readings-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .archive-entry {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .entry-instrument {
        padding-top: 0;
    }

    .coord-info {
        grid-template-columns: 1fr;
    }

    .colophon-grid {
        grid-template-columns: 1fr;
    }

    .status-bar {
        font-size: 8px;
        padding: 0 10px;
    }

    .observation-card::after {
        display: none;
    }
}

@media (max-width: 480px) {
    .content-area {
        padding: 30px 16px;
    }

    .observation-grid {
        gap: 12px;
    }

    .observation-card {
        padding: 20px;
    }

    .manifesto-content {
        padding: 24px;
    }

    .colophon-content {
        padding: 20px;
    }

    .archive-entry {
        padding: 20px;
    }

    .hero-title {
        letter-spacing: 0.08em;
    }

    .hero-subtitle {
        letter-spacing: 0.12em;
    }
}
