/* ============================================================
   addrenvoy.com — Styles
   Avant-garde zen / HUD-on-marble / Typewriter codex
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-marble: #f4f0e8;
    --surface-parchment: rgba(237, 230, 217, 0.7);
    --text-primary: #2c2416;
    --text-secondary: #6b5d4d;
    --hud-accent: #a89264;
    --hud-secondary: #8b7e6a;
    --hud-sage: #8b9178;
    --highlight-ochre: #c4943e;
    --marble-vein: #b8b5a8;
    --dark-walnut: #1a1610;
    --marble-warmth: 10deg;
    --codex-progress: 0;

    --font-headline: 'Jost', sans-serif;
    --font-body: 'Cormorant Garamond', serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --ease-dock: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-smooth: cubic-bezier(0.33, 1, 0.68, 1);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-marble);
    overflow-x: hidden;
    line-height: 1.75;
}

/* --- Marble Background --- */
#marble-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    filter: hue-rotate(var(--marble-warmth));
    background-color: var(--bg-marble);
    background-image:
        /* Primary veining */
        linear-gradient(25deg, transparent 40%, rgba(184, 181, 168, 0.2) 40.5%, rgba(184, 181, 168, 0.2) 41%, transparent 41.5%),
        linear-gradient(155deg, transparent 55%, rgba(184, 181, 168, 0.15) 55.5%, rgba(184, 181, 168, 0.15) 56%, transparent 56.5%),
        linear-gradient(80deg, transparent 30%, rgba(184, 181, 168, 0.12) 30.3%, rgba(184, 181, 168, 0.12) 30.6%, transparent 30.9%),
        /* Secondary veining */
        linear-gradient(140deg, transparent 65%, rgba(184, 181, 168, 0.18) 65.3%, rgba(184, 181, 168, 0.18) 65.5%, transparent 65.8%),
        linear-gradient(45deg, transparent 20%, rgba(184, 181, 168, 0.1) 20.2%, rgba(184, 181, 168, 0.1) 20.5%, transparent 20.7%),
        linear-gradient(100deg, transparent 75%, rgba(184, 181, 168, 0.25) 75.2%, rgba(184, 181, 168, 0.25) 75.5%, transparent 75.7%),
        /* Subtle warm undertone */
        radial-gradient(ellipse 800px 600px at 30% 40%, rgba(196, 148, 62, 0.04), transparent),
        radial-gradient(ellipse 600px 800px at 70% 60%, rgba(168, 146, 100, 0.03), transparent),
        /* Noise grain overlay */
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-attachment: fixed;
    background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 256px 256px;
}

/* --- Horizontal Guide Lines --- */
#main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 119px,
        rgba(184, 181, 168, 0.08) 119px,
        rgba(184, 181, 168, 0.08) 120px
    );
    background-attachment: fixed;
}

/* --- HUD Crosshair --- */
#hud-crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    z-index: 100;
    pointer-events: none;
    opacity: 0.25;
    animation: crosshairBreathing 4s ease-in-out infinite;
    transition: opacity 0.3s ease;
}

#hud-crosshair.hidden {
    opacity: 0;
}

.crosshair-line {
    position: absolute;
    background: var(--hud-accent);
}

.crosshair-top {
    width: 1px;
    height: 20px;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.crosshair-bottom {
    width: 1px;
    height: 20px;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.crosshair-left {
    width: 20px;
    height: 1px;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.crosshair-right {
    width: 20px;
    height: 1px;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

@keyframes crosshairBreathing {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.30; }
}

/* --- Sidebar Navigation --- */
#sidebar-nav {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    background: rgba(244, 240, 232, 0.6);
    backdrop-filter: blur(8px);
}

.nav-progress-track {
    width: 2px;
    height: 80px;
    background: rgba(168, 146, 100, 0.2);
    margin-bottom: 24px;
    position: relative;
}

.nav-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--highlight-ochre);
    transition: height 0.3s var(--ease-smooth);
}

.nav-codes {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    justify-content: center;
}

.nav-item {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.1em;
    color: var(--hud-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item .nav-label {
    display: none;
    opacity: 0;
    position: absolute;
    left: 100%;
    top: 0;
    writing-mode: horizontal-tb;
    padding-left: 8px;
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--hud-accent);
    white-space: nowrap;
}

.nav-item:hover .nav-label {
    display: block;
    opacity: 1;
    animation: slideLabel 0.3s var(--ease-dock) forwards;
}

@keyframes slideLabel {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.nav-item.active {
    color: var(--highlight-ochre);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    background: var(--highlight-ochre);
    border-radius: 50%;
}

/* --- Mobile Navigation --- */
#mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    z-index: 200;
    background: rgba(244, 240, 232, 0.85);
    backdrop-filter: blur(8px);
}

.mobile-nav-codes {
    list-style: none;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 24px;
}

.mobile-nav-item {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--hud-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
}

.mobile-nav-item.active {
    color: var(--highlight-ochre);
}

/* --- Main Content --- */
#main-content {
    padding-left: 48px;
    position: relative;
}

/* --- Chambers --- */
.chamber {
    position: relative;
    min-height: 100vh;
    padding: 120px 60px;
}

/* --- Vestibule (Hero) --- */
#vestibule {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding-left: 12%;
}

.vestibule-content {
    position: relative;
}

/* Typewriter Sequence */
.typewriter-sequence {
    margin-bottom: 60px;
}

.typewriter-line {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--hud-accent);
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    height: 1.8em;
    opacity: 0;
}

.typewriter-line .typewriter-text {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
}

.typewriter-line .typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--hud-accent);
    margin-left: 2px;
    animation: cursorBlink 1s step-end infinite;
    opacity: 0;
}

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

.typewriter-line.typing {
    opacity: 1;
}

.typewriter-line.typing .typewriter-cursor {
    opacity: 1;
}

.typewriter-line.done {
    opacity: 0.4;
}

.typewriter-line.done .typewriter-cursor {
    opacity: 0;
}

/* Hero Headline */
.hero-headline {
    opacity: 0;
    transition: opacity 1.5s var(--ease-smooth);
}

.hero-headline.visible {
    opacity: 1;
}

.hero-headline h1 {
    font-family: var(--font-headline);
    font-weight: 500;
    font-size: clamp(4rem, 8vw, 7rem);
    font-variant: all-small-caps;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    line-height: 1.1;
}

.hero-headline h1 span {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s var(--ease-dock), transform 0.5s var(--ease-dock);
}

.hero-headline h1 span.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Hero Subtitle */
.hero-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: var(--text-secondary);
    margin-top: 24px;
    max-width: 540px;
    opacity: 0;
    transition: opacity 1s var(--ease-smooth);
}

.hero-subtitle.visible {
    opacity: 1;
}

/* --- Chamber Dividers --- */
.chamber-divider {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 60px;
}

.divider-line {
    width: 0;
    height: 1px;
    background: var(--hud-accent);
    transition: width 0.6s var(--ease-dock);
}

.divider-line.expanded {
    width: 240px;
}

.divider-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.2em;
    color: var(--hud-accent);
    font-variant: all-small-caps;
    margin-bottom: 12px;
    opacity: 0;
    transition: opacity 0.5s var(--ease-smooth) 0.2s;
}

.divider-label.visible {
    opacity: 1;
}

/* --- Panels --- */
.panel {
    position: relative;
    background: var(--surface-parchment);
    backdrop-filter: blur(6px) saturate(1.1);
    border: 1px solid rgba(168, 146, 100, 0.3);
    padding: 48px 40px;
    margin-bottom: 60px;
    max-width: 640px;
    transition: background 0.6s ease, border-color 0.6s ease;
}

.panel-left {
    margin-left: 8%;
    margin-right: auto;
}

.panel-right {
    margin-left: auto;
    margin-right: 8%;
}

.panel-wide {
    max-width: 780px;
    margin-left: 8%;
    margin-right: auto;
}

/* Panel Corner Tick Marks */
.panel-corner {
    position: absolute;
    width: 12px;
    height: 12px;
}

.panel-corner::before,
.panel-corner::after {
    content: '';
    position: absolute;
    background: var(--hud-accent);
}

.panel-corner.tl {
    top: -1px;
    left: -1px;
}
.panel-corner.tl::before { width: 12px; height: 1px; top: 0; left: 0; }
.panel-corner.tl::after { width: 1px; height: 12px; top: 0; left: 0; }

.panel-corner.tr {
    top: -1px;
    right: -1px;
}
.panel-corner.tr::before { width: 12px; height: 1px; top: 0; right: 0; }
.panel-corner.tr::after { width: 1px; height: 12px; top: 0; right: 0; }

.panel-corner.bl {
    bottom: -1px;
    left: -1px;
}
.panel-corner.bl::before { width: 12px; height: 1px; bottom: 0; left: 0; }
.panel-corner.bl::after { width: 1px; height: 12px; bottom: 0; left: 0; }

.panel-corner.br {
    bottom: -1px;
    right: -1px;
}
.panel-corner.br::before { width: 12px; height: 1px; bottom: 0; right: 0; }
.panel-corner.br::after { width: 1px; height: 12px; bottom: 0; right: 0; }

/* Foliation Numbers */
.foliation-number {
    position: absolute;
    top: 12px;
    right: 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--hud-secondary);
    letter-spacing: 0.05em;
}

/* Panel Docking Animation */
.dock-left {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.8s var(--ease-dock), transform 0.8s var(--ease-dock);
}

.dock-right {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.8s var(--ease-dock), transform 0.8s var(--ease-dock);
}

.dock-left.docked,
.dock-right.docked {
    opacity: 1;
    transform: translateX(0);
}

/* --- Panel Typography --- */
.panel h2 {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    font-variant: all-small-caps;
    letter-spacing: 0.04em;
    color: var(--text-primary);
    margin-bottom: 24px;
    line-height: 1.2;
}

.panel p {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 16px;
}

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

/* Marginal Glosses */
.marginal-gloss {
    font-family: var(--font-body) !important;
    font-style: italic !important;
    font-size: 0.85rem !important;
    color: var(--text-secondary) !important;
    padding-left: 20px;
    border-left: 1px solid rgba(168, 146, 100, 0.3);
    margin-top: 20px !important;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.6s var(--ease-dock), transform 0.6s var(--ease-dock);
}

.marginal-gloss.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Pull Quote */
.pull-quote {
    border-left: 2px solid var(--highlight-ochre);
    padding: 12px 0 12px 24px;
    margin: 32px 0;
}

.pull-quote p {
    font-family: var(--font-body) !important;
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1.4rem, 2.8vw, 2.2rem) !important;
    line-height: 1.5 !important;
    color: var(--text-secondary) !important;
}

/* --- Codex Chamber (Dark Inversion) --- */
#codex-chamber {
    position: relative;
}

.codex-transition-overlay {
    position: absolute;
    top: 0;
    left: -48px;
    right: 0;
    bottom: 0;
    background: var(--dark-walnut);
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.05s linear;
}

#codex-chamber.inverted .panel {
    background: rgba(44, 36, 22, 0.7);
    border-color: rgba(168, 146, 100, 0.2);
}

#codex-chamber.inverted .panel h2 {
    color: var(--bg-marble);
}

#codex-chamber.inverted .panel p {
    color: rgba(244, 240, 232, 0.85);
}

#codex-chamber.inverted .pull-quote p {
    color: var(--hud-accent) !important;
}

#codex-chamber.inverted .foliation-number {
    color: var(--hud-accent);
}

#codex-chamber.inverted .panel-corner::before,
#codex-chamber.inverted .panel-corner::after {
    background: var(--highlight-ochre);
}

#codex-chamber.inverted .marginal-gloss {
    color: rgba(184, 181, 168, 0.7) !important;
    border-left-color: rgba(168, 146, 100, 0.25);
}

/* --- Compass Rose (Cartography) --- */
#cartography-chamber {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 40px;
    padding-top: 60px;
}

.compass-rose {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    opacity: 0.12;
    pointer-events: none;
}

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

.compass-circle {
    fill: none;
    stroke: var(--hud-accent);
    stroke-width: 0.5;
    opacity: 0.6;
}

.compass-line {
    stroke: var(--hud-accent);
    stroke-width: 0.5;
    opacity: 0.4;
}

.compass-line.cardinal {
    stroke-width: 0.8;
    opacity: 0.6;
}

.compass-line.diagonal {
    stroke-width: 0.5;
    opacity: 0.3;
    stroke: #8b9178;
}

.compass-degree {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--hud-accent);
    opacity: 0.7;
}

.compass-center {
    fill: var(--highlight-ochre);
}

.cartography-panel {
    z-index: 1;
}

/* --- Colophon --- */
#colophon-chamber {
    padding-bottom: 160px;
}

.colophon-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 32px;
    margin: 32px 0;
    padding: 24px;
    border: 1px solid rgba(168, 146, 100, 0.2);
}

.colophon-entry {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.colophon-key {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--hud-secondary);
}

.colophon-value {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-primary);
}

.colophon-endnote {
    font-family: var(--font-mono) !important;
    font-size: 11px !important;
    color: var(--hud-secondary) !important;
    letter-spacing: 0.05em;
    margin-top: 32px !important;
    text-align: center;
}

/* --- Section Marks / Pilcrows --- */
.chamber-divider::before {
    content: '§';
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: var(--hud-accent);
    opacity: 0.4;
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

/* --- Responsive (< 768px) --- */
@media (max-width: 768px) {
    #sidebar-nav {
        display: none;
    }

    #mobile-nav {
        display: block;
    }

    #main-content {
        padding-left: 0;
    }

    .chamber {
        padding: 80px 24px;
    }

    #vestibule {
        padding-left: 24px;
    }

    .panel {
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .panel-wide {
        max-width: 100%;
    }

    .dock-left {
        transform: translateY(40px);
    }

    .dock-right {
        transform: translateY(40px);
    }

    .dock-left.docked,
    .dock-right.docked {
        transform: translateY(0);
    }

    #hud-crosshair {
        display: none;
    }

    .compass-rose {
        width: 250px;
        height: 250px;
    }

    .hero-headline h1 {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }

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

    .codex-transition-overlay {
        left: 0;
    }

    .chamber-divider {
        padding: 40px 24px;
    }

    #cartography-chamber {
        flex-direction: column;
        align-items: stretch;
    }
}

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg-marble);
}

::-webkit-scrollbar-thumb {
    background: var(--hud-accent);
    border-radius: 2px;
}
