/* ============================================================
   daitoua.quest — Cinematic Nocturne Stylesheet
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --abyssal-night: #080C18;
    --pacific-depths: #0D1B2A;
    --twilight-stratum: #1B2D4A;
    --chart-blue: #2A4A7A;
    --deep-fog: #5A7A94;
    --steel-mist: #94A8B8;
    --pale-celestial: #C8D8E8;
    --signal-amber: #E8A84C;
    --flare-red: #C75038;
    --brass-patina: #7A6248;
    --star-blue: #4A6FA5;
    --muted-sky: #8AACCC;
    --grid-base: #1B2840;

    --font-heading: 'Cormorant Garamond', 'Georgia', serif;
    --font-heading-jp: 'Shippori Mincho', serif;
    --font-body: 'Source Sans 3', 'Helvetica Neue', sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --content-max: 760px;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: var(--abyssal-night);
    color: var(--steel-mist);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.15vw, 1.1rem);
    line-height: 1.9;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Depth Layer Base --- */
.depth-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* --- Layer 0: Star Field --- */
#star-field {
    z-index: 1;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#star-field.visible {
    opacity: 1;
}

.star {
    position: absolute;
    border-radius: 50%;
    background: var(--star-blue);
}

.star.amber {
    background: var(--signal-amber);
}

.star.pulse {
    animation: starPulse var(--pulse-duration, 12s) ease-in-out infinite;
    animation-delay: var(--pulse-delay, 0s);
}

@keyframes starPulse {
    0%, 100% { opacity: var(--star-opacity-min, 0.3); }
    50% { opacity: var(--star-opacity-max, 0.7); }
}

/* --- Layer 1: Navigation Grid --- */
#nav-grid {
    z-index: 2;
    opacity: 0;
    transition: opacity 0.8s ease;
    will-change: transform;
}

#nav-grid.visible {
    opacity: 1;
}

.grid-inner {
    position: absolute;
    top: -50%;
    left: 0;
    width: 100%;
    height: 200%;
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(27, 40, 64, 0.18) 0px,
            rgba(27, 40, 64, 0.18) 1px,
            transparent 1px,
            transparent calc(100% / 12)
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(27, 40, 64, 0.18) 0px,
            rgba(27, 40, 64, 0.18) 1px,
            transparent 1px,
            transparent 200px
        );
    animation: gridPulse 12s ease-in-out infinite;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.83; }
    50% { opacity: 1.17; }
}

/* Grid intersection markers via pseudo-element pattern */
.grid-inner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle 2px at center, rgba(42, 74, 122, 0.25) 0%, transparent 100%);
    background-size: calc(100% / 12) 200px;
    background-position: calc(100% / 24) 100px;
}

/* --- Layer 2: Atmospheric Haze --- */
#atmo-haze {
    z-index: 3;
    will-change: transform;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 35%,
        rgba(13, 27, 42, 0.0) 40%,
        rgba(27, 45, 74, 0.08) 48%,
        rgba(27, 45, 74, 0.08) 52%,
        rgba(13, 27, 42, 0.0) 60%,
        transparent 65%,
        transparent 100%
    );
}

/* --- Layer 4: Vignette Overlay --- */
#vignette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(8, 12, 24, 0.4) 100%
    );
    transition: background 2s ease;
}

#vignette-overlay.flare {
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(8, 12, 24, 0.35) 70%,
        rgba(38, 20, 18, 0.45) 100%
    );
}

/* Extra vignette intensity at top/bottom */
#vignette-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(8, 12, 24, 0.55) 0%,
        transparent 15%,
        transparent 85%,
        rgba(8, 12, 24, 0.55) 100%
    );
}

/* --- Layer 3: Content --- */
#content-layer {
    position: relative;
    z-index: 50;
}

/* --- Hero Section --- */
.hero-section {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.compass-rose-container {
    width: clamp(250px, 40vw, 400px);
    height: clamp(250px, 40vw, 400px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.compass-rose {
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease;
}

.compass-rose.visible {
    opacity: 1;
}

.compass-rose .compass-group line,
.compass-rose .compass-group circle,
.compass-rose .compass-group polygon {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s cubic-bezier(0.42, 0, 0.58, 1);
}

.compass-rose.drawing .compass-group line,
.compass-rose.drawing .compass-group circle,
.compass-rose.drawing .compass-group polygon {
    stroke-dashoffset: 0;
}

.compass-rose.drawing {
    opacity: 1;
}

.hero-text {
    text-align: center;
    z-index: 10;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 5vw, 4rem);
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--chart-blue);
    line-height: 1.05;
    opacity: 0;
    transition: opacity 1.5s ease, color 1.5s ease;
}

.hero-title.visible {
    opacity: 1;
    color: var(--pale-celestial);
}

.hero-subtitle {
    font-family: var(--font-heading-jp);
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    font-weight: 400;
    color: var(--deep-fog);
    letter-spacing: 0.08em;
    margin-top: 0.8rem;
    opacity: 0;
    transition: opacity 1s ease;
}

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

.scroll-chevron {
    position: absolute;
    bottom: 3rem;
    opacity: 0;
    transition: opacity 0.8s ease;
    animation: chevronPulse 2.5s ease-in-out infinite;
}

.scroll-chevron.visible {
    opacity: 1;
}

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

/* --- Transit Zones --- */
.transit-zone {
    position: relative;
    height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.transit-compass {
    width: clamp(200px, 30vw, 350px);
    height: clamp(200px, 30vw, 350px);
    opacity: 0.15;
    animation: compassRotate 90s linear infinite;
    transition: opacity 0.3s ease;
}

.transit-compass:hover {
    animation-duration: 20s;
}

.transit-compass.rotated-90 {
    transform: rotate(90deg);
}

.transit-compass.rotated-180 {
    transform: rotate(180deg);
}

.transit-compass.rotated-270 {
    transform: rotate(270deg);
}

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

.transit-compass.rotated-90 {
    animation-name: compassRotate90;
}

@keyframes compassRotate90 {
    from { transform: rotate(90deg); }
    to { transform: rotate(450deg); }
}

.transit-compass.rotated-180 {
    animation-name: compassRotate180;
}

@keyframes compassRotate180 {
    from { transform: rotate(180deg); }
    to { transform: rotate(540deg); }
}

.transit-compass.rotated-270 {
    animation-name: compassRotate270;
}

@keyframes compassRotate270 {
    from { transform: rotate(270deg); }
    to { transform: rotate(630deg); }
}

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

/* --- Radio Arcs --- */
.radio-arcs {
    position: relative;
    width: 300px;
    height: 300px;
}

.radio-arc {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1px solid var(--signal-amber);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

.radio-arc.arc-1 {
    width: 80px;
    height: 80px;
    opacity: 0.3;
}

.radio-arc.arc-2 {
    width: 140px;
    height: 140px;
    opacity: 0.2;
}

.radio-arc.arc-3 {
    width: 200px;
    height: 200px;
    opacity: 0.12;
}

.radio-arc.arc-4 {
    width: 260px;
    height: 260px;
    opacity: 0.06;
}

.radio-arc.animate {
    animation: radioExpand 2s ease-out forwards;
}

.radio-arc.arc-1.animate { animation-delay: 0s; }
.radio-arc.arc-2.animate { animation-delay: 0.2s; }
.radio-arc.arc-3.animate { animation-delay: 0.4s; }
.radio-arc.arc-4.animate { animation-delay: 0.6s; }

@keyframes radioExpand {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    50% {
        opacity: var(--arc-opacity, 0.3);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: var(--arc-opacity, 0.3);
    }
}

.radio-origin {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: var(--signal-amber);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.5;
}

/* --- Route Lines --- */
.route-line-svg {
    width: 100%;
    height: 200px;
    opacity: 0.35;
}

.route-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 2.5s ease-out;
}

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

.route-line-svg:hover .route-path {
    opacity: 0.6;
}

/* --- Content Sections --- */
.content-section {
    position: relative;
    padding: 0;
}

/* --- Epoch Markers --- */
.epoch-marker {
    position: relative;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    opacity: 0;
    transition: opacity 0.6s var(--ease-smooth);
}

.epoch-marker.visible {
    opacity: 1;
}

.epoch-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--chart-blue);
    transform: translateY(-50%);
    transition: width 0.8s var(--ease-smooth);
}

.epoch-marker.visible .epoch-line {
    width: 100%;
}

.epoch-diamond {
    position: relative;
    z-index: 2;
    width: 10px;
    height: 10px;
    background: var(--abyssal-night);
    border: 1px solid var(--chart-blue);
    transform: rotate(45deg);
    flex-shrink: 0;
}

.epoch-label {
    position: absolute;
    left: max(1rem, calc((100% - var(--content-max)) / 2 - 120px));
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.85vw, 0.8rem);
    font-weight: 300;
    color: var(--deep-fog);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* --- Section Content --- */
.section-content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 2rem 6rem;
}

.coordinate-stamp {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 0.9vw, 0.85rem);
    font-weight: 300;
    color: var(--deep-fog);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid rgba(42, 74, 122, 0.2);
    display: inline-block;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-smooth), transform 0.6s var(--ease-smooth), box-shadow 0.3s ease;
}

.coordinate-stamp.visible {
    opacity: 1;
    transform: translateY(0);
}

.coordinate-stamp:hover {
    box-shadow: 0 0 20px rgba(232, 168, 76, 0.15);
}

.section-heading {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 5vw, 4rem);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pale-celestial);
    line-height: 1.05;
    margin-bottom: 0.6rem;
    overflow: hidden;
}

.section-heading .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.4s var(--ease-smooth), transform 0.4s var(--ease-smooth);
}

.section-heading .char.space {
    width: 0.3em;
}

.section-heading .char.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-heading-jp {
    font-family: var(--font-heading-jp);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 400;
    color: var(--muted-sky);
    letter-spacing: 0.04em;
    line-height: 1.3;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-smooth), transform 0.6s var(--ease-smooth);
}

.section-heading-jp.visible {
    opacity: 1;
    transform: translateY(0);
}

.body-text {
    color: var(--steel-mist);
    font-weight: 300;
    line-height: 1.9;
    max-width: 62ch;
    margin-bottom: 1.8rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-smooth), transform 0.6s var(--ease-smooth);
}

.body-text.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Light Leaks --- */
.light-leak {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 168, 76, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}

.light-leak-1 {
    width: 400px;
    height: 400px;
    top: 15%;
    right: -5%;
}

.light-leak-2 {
    width: 350px;
    height: 350px;
    top: 35%;
    left: -8%;
}

.light-leak-3 {
    width: 500px;
    height: 500px;
    top: 55%;
    right: -3%;
}

.light-leak-4 {
    width: 300px;
    height: 300px;
    top: 72%;
    left: -6%;
}

.light-leak-5 {
    width: 450px;
    height: 450px;
    top: 88%;
    right: -4%;
}

/* --- Final Transit Zone --- */
.transit-final {
    flex-direction: column;
    padding-bottom: 6rem;
}

.final-coordinates {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-smooth), transform 0.6s var(--ease-smooth);
}

.final-coordinates.visible {
    opacity: 1;
    transform: translateY(0);
}

.coord-text {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 0.9vw, 0.85rem);
    font-weight: 300;
    color: var(--deep-fog);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.coord-label {
    font-family: var(--font-heading);
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    font-weight: 400;
    color: var(--chart-blue);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .epoch-label {
        left: 1rem;
        top: -1.5rem;
        transform: none;
    }

    .section-content {
        padding: 0 1.5rem 4rem;
    }

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

    .transit-compass {
        width: 200px;
        height: 200px;
    }
}

@media (max-width: 480px) {
    .section-content {
        padding: 0 1rem 3rem;
    }

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

/* --- Selection style --- */
::selection {
    background: rgba(232, 168, 76, 0.2);
    color: var(--pale-celestial);
}

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

::-webkit-scrollbar-track {
    background: var(--abyssal-night);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--deep-fog);
}
