/* =========================================
   riron.org — Urban Field Journal Styles
   ========================================= */

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

:root {
    --paper: #f5efe0;
    --ink: #1c1a17;
    --cyan: #4a90a4;
    --rust: #b5451b;
    --graphite: #6b6560;
    --amber: #e8a838;
    --asphalt: #1a1a1e;
    --tan: #b89868;
    --foxing: #c8b898;
    --scroll-y: 0;
    --bright-cyan: #5bb8d4;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    cursor: none;
}

/* --- Night Mode --- */
body.night-mode {
    --paper: #1a1a1e;
    --ink: #f5efe0;
    --cyan: #5bb8d4;
    --rust: #e8a838;
}

body.night-mode #layer-paper {
    background: var(--paper);
}

body.night-mode .foxing-spot {
    opacity: 0.02;
}

body.night-mode .coffee-ring {
    opacity: 0.02;
}

body.night-mode .blueprint-label {
    fill: var(--cyan);
}

body.night-mode .section-heading {
    color: var(--ink);
}

body.night-mode .section-body p {
    color: var(--ink);
}

body.night-mode .annotation-card {
    background: #2a2a2e;
    border-color: #3a3a3e;
    color: var(--ink);
}

body.night-mode .draw-path,
body.night-mode .ink-splatter circle {
    stroke: var(--ink);
    fill: var(--ink);
}

body.night-mode #compass-svg circle:first-child,
body.night-mode #compass-svg circle:nth-child(2),
body.night-mode #compass-svg line {
    stroke: var(--ink);
}

body.night-mode #compass-center {
    fill: var(--paper);
    stroke: var(--ink);
}

body.night-mode #compass-needle polygon:first-child {
    fill: var(--rust);
}

/* Night mode transition */
body.night-transitioning {
    clip-path: circle(0% at var(--clip-x, 90%) var(--clip-y, 5%));
    animation: nightExpand 0.8s ease-out forwards;
}

@keyframes nightExpand {
    from { clip-path: circle(0% at var(--clip-x, 90%) var(--clip-y, 5%)); }
    to { clip-path: circle(150% at var(--clip-x, 90%) var(--clip-y, 5%)); }
}

/* --- Layers --- */
.layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#layer-content {
    position: relative;
    pointer-events: auto;
}

#layer-annotations {
    z-index: 30;
    pointer-events: none;
}

#layer-paper {
    z-index: 0;
    background: var(--paper);
}

#layer-blueprint {
    z-index: 1;
    will-change: transform;
}

#layer-content {
    z-index: 10;
}

/* --- Paper Texture --- */
.foxing-spot {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--foxing) 0%, transparent 70%);
    opacity: 0.04;
}

.coffee-ring {
    position: absolute;
    top: 8%;
    right: 12%;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 12px solid var(--tan);
    opacity: 0.04;
}

.fold-crease {
    position: absolute;
    background: linear-gradient(to right, transparent, var(--foxing), transparent);
    opacity: 0.06;
}

.fold-crease-1 {
    top: 33%;
    left: 0;
    width: 100%;
    height: 1px;
    transform: rotate(0.5deg);
}

.fold-crease-2 {
    top: 0;
    left: 48%;
    width: 1px;
    height: 100%;
    transform: rotate(-0.3deg);
    background: linear-gradient(to bottom, transparent, var(--foxing), transparent);
}

/* --- Blueprint Grid --- */
#blueprint-grid {
    height: 300vh;
}

.blueprint-label {
    font-family: 'Caveat', cursive;
    font-size: 10px;
    fill: var(--cyan);
    opacity: 0.15;
}

/* --- Sections --- */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.content-section {
    padding: 8vh var(--margin-left, 12vw);
    padding-right: 10vw;
}

.content-section .section-body {
    max-width: 56ch;
    box-shadow: 8px 0 20px -10px rgba(28, 26, 23, 0.06);
    padding-right: 2rem;
}

/* --- Hero --- */
#hero {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.hero-inner {
    text-align: center;
}

.title-svg {
    width: clamp(250px, 40vw, 450px);
    height: auto;
    opacity: 0;
    animation: fadeInTitle 0.3s ease-out 0.5s forwards;
}

#riron-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawTitle 1.8s ease-in-out 0.5s forwards;
}

@keyframes drawTitle {
    to { stroke-dashoffset: 0; }
}

@keyframes fadeInTitle {
    to { opacity: 1; }
}

.subtitle {
    font-family: 'Caveat', cursive;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    color: var(--graphite);
    opacity: 0;
    animation: fadeIn 0.6s ease-out 2.7s forwards;
    margin-top: 0.5rem;
}

.scroll-arrow {
    margin-top: 3rem;
    opacity: 0;
    animation: fadeIn 0.6s ease-out 3.2s forwards, pulse 2s ease-in-out 3.8s infinite;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(8px); opacity: 1; }
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.5rem);
    text-transform: lowercase;
    letter-spacing: 0.04em;
    color: var(--ink);
    margin-bottom: 2rem;
}

/* --- Section Body --- */
.section-body p {
    color: var(--ink);
    margin-bottom: 1.5rem;
}

.section-body p:last-child {
    margin-bottom: 0;
}

/* --- Ink Splatters --- */
.ink-splatter {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
}

/* --- Section Dividers --- */
.section-divider {
    width: 100%;
    padding: 2rem 0;
    overflow: hidden;
}

.divider-svg {
    width: 100%;
    height: auto;
    display: block;
}

.draw-path {
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
    transition: stroke-dashoffset 2s ease-in-out;
}

.draw-path.drawn {
    stroke-dashoffset: 0;
}

/* --- Cross-Section --- */
.cross-section-container {
    padding: 4vh 5vw;
    min-height: 150vh;
}

.cross-section-viewport {
    width: 100%;
    max-width: 900px;
    margin: 2rem auto;
    position: sticky;
    top: 10vh;
}

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

.cross-label {
    font-family: 'Caveat', cursive;
    font-size: 14px;
    fill: var(--graphite);
}

.cross-layer {
    transition: opacity 0.8s ease-out;
}

/* --- Annotation Cards --- */
.annotation-card {
    position: absolute;
    width: 200px;
    padding: 1rem 1.2rem;
    background: var(--paper);
    border: 1px solid var(--foxing);
    border-radius: 2px;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1.5vw, 1.05rem);
    color: var(--ink);
    transform: rotate(var(--tilt, 0deg)) translateX(40px);
    opacity: 0;
    transition: transform 0.6s ease-out, opacity 0.6s ease-out, box-shadow 0.3s ease;
    box-shadow: 2px 3px 8px rgba(28, 26, 23, 0.08);
    pointer-events: auto;
    line-height: 1.5;
}

.annotation-card.visible {
    opacity: 1;
    transform: rotate(var(--tilt, 0deg)) translateX(0);
}

.annotation-card:hover {
    transform: rotate(var(--tilt, 0deg)) translateY(-4px);
    box-shadow: 3px 6px 16px rgba(28, 26, 23, 0.14);
}

.annotation-arrow {
    width: 30px;
    height: 30px;
    position: absolute;
    bottom: -25px;
    left: 10px;
}

/* --- Compass Rose --- */
#compass-rose {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    width: 56px;
    height: 56px;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 2.5s forwards;
    cursor: pointer;
    pointer-events: auto;
}

#compass-rose:hover {
    opacity: 1 !important;
}

#compass-svg {
    width: 100%;
    height: 100%;
}

#compass-needle {
    transition: transform 0.5s ease-out;
    transform-origin: 50px 50px;
}

/* Compass Navigation */
#compass-nav {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
}

.compass-nav-hidden .compass-link {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
    pointer-events: none;
}

.compass-nav-open .compass-link {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.compass-link {
    position: absolute;
    font-family: 'Caveat', cursive;
    font-size: 0.9rem;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.4s ease-out, color 0.2s ease;
    padding: 2px 6px;
    border-radius: 2px;
}

.compass-link:hover {
    color: var(--amber);
}

.compass-link.active {
    color: var(--amber);
}

/* Radial positions for compass links */
.compass-link:nth-child(1) { left: 0; top: -55px; }
.compass-link:nth-child(2) { left: 50px; top: -30px; }
.compass-link:nth-child(3) { left: 55px; top: 20px; }
.compass-link:nth-child(4) { left: 0; top: 50px; }
.compass-link:nth-child(5) { left: -55px; top: 20px; }
.compass-link:nth-child(6) { left: -50px; top: -30px; }

/* --- Custom Cursor --- */
#custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    pointer-events: none;
    transition: transform 0.05s linear;
    mix-blend-mode: difference;
    display: none;
}

@media (pointer: fine) {
    #custom-cursor {
        display: block;
    }
}

/* --- Closing --- */
.closing-sketch {
    margin-top: 3rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.closing-arrow-svg {
    width: 120px;
    height: auto;
}

.closing-note {
    font-family: 'Caveat', cursive;
    font-size: 1.3rem;
    color: var(--graphite);
    font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .content-section {
        padding-left: 6vw !important;
        padding-right: 6vw !important;
    }

    .annotation-card {
        display: none;
    }

    #compass-rose {
        width: 44px;
        height: 44px;
        top: 1rem;
        right: 1rem;
    }

    body {
        cursor: auto;
    }

    #custom-cursor {
        display: none;
    }
}
