/* ==========================================================================
   PPEBBL.com — Astronomer's Journal
   A forgotten journal of celestial observations on aged parchment
   ========================================================================== */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    --aged-parchment: #F5F0E3;
    --foxing-cream: #EDE4CC;
    --midnight-ink: #2C2A4A;
    --deep-parchment: #3D3552;
    --faded-notation: #8E86A4;
    --celestial-gold: #C8A96E;
    --pastel-lavender: #C6B8D9;
    --rose-nebula: #D9A8B4;
    --seafoam-cluster: #A8CCBE;
    --butter-moon: #E8D5A3;
}

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

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

body {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.3vw, 1.2rem);
    line-height: 1.85;
    letter-spacing: 0.005em;
    color: var(--deep-parchment);
    background-color: var(--aged-parchment);
    overflow-x: hidden;
    position: relative;
}

/* --- Paper Texture --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    /* Fiber lines: horizontal grain of handmade paper */
    background:
        repeating-linear-gradient(
            0deg,
            rgba(60, 50, 40, 0.02) 0px,
            rgba(60, 50, 40, 0.02) 1px,
            transparent 1px,
            transparent 3.5px
        );
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    filter: url(#paper-noise);
    opacity: 0.04;
    background: var(--aged-parchment);
}

/* --- Edge Vignette --- */
.edge-vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    background:
        linear-gradient(to right,
            rgba(200, 185, 155, 0.15) 0%,
            transparent 8%,
            transparent 92%,
            rgba(200, 185, 155, 0.15) 100%
        ),
        linear-gradient(to bottom,
            rgba(200, 185, 155, 0.1) 0%,
            transparent 5%,
            transparent 95%,
            rgba(200, 185, 155, 0.12) 100%
        );
}

/* --- Foxing Marks --- */
.foxing-marks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.foxing {
    position: absolute;
    left: var(--fx-x);
    top: var(--fx-y);
    width: var(--fx-size);
    height: var(--fx-size);
    border-radius: 50%;
    background: radial-gradient(circle, var(--foxing-cream) 0%, transparent 70%);
    opacity: var(--fx-opacity);
}

/* --- Star Navigation --- */
.star-nav {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.star-nav-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--pastel-lavender);
    opacity: 0.3;
    z-index: -1;
}

.star-nav-marker {
    background: none;
    border: none;
    color: var(--celestial-gold);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 12px 4px;
    opacity: 0.5;
    transition: opacity 0.6s ease, color 0.6s ease;
    line-height: 1;
}

.star-nav-marker:hover,
.star-nav-marker.active {
    opacity: 1;
    color: var(--celestial-gold);
}

/* --- Marginal Star Map --- */
.marginal-star-map {
    position: fixed;
    right: 60px;
    top: 0;
    width: 60px;
    height: 100vh;
    z-index: 5;
    opacity: 0.25;
    pointer-events: none;
    display: none;
}

@media (min-width: 1200px) {
    .marginal-star-map {
        display: block;
    }
}

.marginal-svg {
    width: 100%;
    height: 2400px;
    will-change: transform;
}

/* --- Main Parchment --- */
.parchment {
    position: relative;
    z-index: 2;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 24px;
}

/* --- Title Page --- */
.title-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 0;
    padding-bottom: 15vh;
}

.site-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(3.5rem, 10vw, 8rem);
    letter-spacing: -0.04em;
    color: var(--midnight-ink);
    text-align: center;
    line-height: 1;
    margin-bottom: 2rem;
}

.title-ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    margin-bottom: 1.5rem;
}

.ornament-star {
    color: var(--celestial-gold);
    font-size: 0.7rem;
    opacity: 0.7;
}

.site-subtitle {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--faded-notation);
    text-align: center;
    letter-spacing: 0.02em;
}

/* --- Entries --- */
.entry {
    position: relative;
    padding: 120px 0;
}

/* --- Section Dividers --- */
.section-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.divider-line {
    flex: 1;
    height: 0;
    border: none;
    border-top: 2px dotted var(--faded-notation);
    opacity: 0.4;
    /* Custom dotted pattern: 2px circles spaced 12px apart */
    background: none;
}

.divider-label {
    font-family: 'Cormorant SC', Georgia, serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--celestial-gold);
    white-space: nowrap;
}

/* --- Entry Labels --- */
.entry-label {
    display: block;
    font-family: 'Cormorant SC', Georgia, serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--celestial-gold);
    text-align: center;
    margin-bottom: 1rem;
}

/* --- Entry Headings --- */
.entry-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(2rem, 4vw, 3.5rem);
    letter-spacing: -0.04em;
    color: var(--midnight-ink);
    text-align: center;
    line-height: 1.2;
    margin-bottom: 3rem;
}

/* --- Entry Content --- */
.entry-content {
    max-width: 100%;
}

.entry-content p {
    margin-bottom: 1.5em;
    text-align: left;
    text-indent: 1.5em;
}

.entry-content p:first-child {
    text-indent: 0;
}

/* --- Animations for content reveal --- */
.animate-in {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.animate-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.entry-heading {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

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

.entry-label {
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

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

/* --- Marginal Annotations --- */
.annotation {
    position: absolute;
    width: 160px;
    top: var(--ann-top, 30%);
}

.annotation-right {
    right: -200px;
}

.annotation-left {
    left: -200px;
}

.annotation p {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--faded-notation);
    text-indent: 0;
}

/* Hide annotations on narrow viewports */
@media (max-width: 1100px) {
    .annotation {
        display: none;
    }
}

/* --- Constellation Diagrams --- */
.constellation-diagram {
    max-width: 400px;
    margin: 3rem auto;
    padding: 2rem 0;
}

.constellation-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

/* Star dots */
.star-dot {
    fill: var(--celestial-gold);
    opacity: 0;
    transition: opacity 1.5s ease-out;
    filter: drop-shadow(0 0 4px rgba(200, 169, 110, 0.3));
}

.star-dot.visible {
    opacity: 1;
}

/* Constellation lines */
.constellation-line {
    stroke: var(--pastel-lavender);
    stroke-width: 1;
    opacity: 0.5;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s ease-in-out;
    fill: none;
}

.constellation-line.drawn {
    stroke-dashoffset: 0;
}

/* Chart labels */
.chart-label {
    font-family: 'Cormorant SC', Georgia, serif;
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.15em;
    fill: var(--celestial-gold);
    text-anchor: middle;
    opacity: 0;
    transition: opacity 1s ease-out 2s;
}

.chart-label.visible {
    opacity: 0.7;
}

/* --- Full Bleed Star Chart --- */
.entry-fullbleed .star-chart {
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    width: 100vw;
    padding: 3rem 2rem;
    background: linear-gradient(
        180deg,
        var(--aged-parchment) 0%,
        var(--foxing-cream) 15%,
        var(--foxing-cream) 85%,
        var(--aged-parchment) 100%
    );
    margin-top: 2rem;
    margin-bottom: 3rem;
    overflow: hidden;
}

.star-chart-svg {
    width: 100%;
    height: auto;
    max-height: 500px;
}

/* --- Moon Phases --- */
.moon-phases {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 4rem 0;
    padding: 2rem 0;
}

.moon-phase {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.moon-phase.visible {
    opacity: 1;
}

/* New Moon */
.moon-phase[data-phase="new"] {
    background: var(--foxing-cream);
    border: 1px solid var(--faded-notation);
    border-color: rgba(142, 134, 164, 0.3);
}

/* Full Moon */
.moon-phase[data-phase="full"] {
    background: var(--butter-moon);
}

/* Waxing Crescent */
.moon-phase[data-phase="waxing-crescent"] {
    background: var(--foxing-cream);
    border: 1px solid rgba(142, 134, 164, 0.3);
}
.moon-phase[data-phase="waxing-crescent"]::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--butter-moon);
    clip-path: inset(0 0 0 65%);
}

/* First Quarter */
.moon-phase[data-phase="first-quarter"] {
    background: var(--foxing-cream);
    border: 1px solid rgba(142, 134, 164, 0.3);
}
.moon-phase[data-phase="first-quarter"]::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--butter-moon);
    clip-path: inset(0 0 0 50%);
}

/* Waxing Gibbous */
.moon-phase[data-phase="waxing-gibbous"] {
    background: var(--butter-moon);
}
.moon-phase[data-phase="waxing-gibbous"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--foxing-cream);
    clip-path: inset(0 70% 0 0);
}

/* Waning Gibbous */
.moon-phase[data-phase="waning-gibbous"] {
    background: var(--butter-moon);
}
.moon-phase[data-phase="waning-gibbous"]::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--foxing-cream);
    clip-path: inset(0 0 0 70%);
}

/* Last Quarter */
.moon-phase[data-phase="last-quarter"] {
    background: var(--foxing-cream);
    border: 1px solid rgba(142, 134, 164, 0.3);
}
.moon-phase[data-phase="last-quarter"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--butter-moon);
    clip-path: inset(0 50% 0 0);
}

/* Waning Crescent */
.moon-phase[data-phase="waning-crescent"] {
    background: var(--foxing-cream);
    border: 1px solid rgba(142, 134, 164, 0.3);
}
.moon-phase[data-phase="waning-crescent"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--butter-moon);
    clip-path: inset(0 65% 0 0);
}

/* --- Closing Section --- */
.closing {
    padding: 120px 0 200px;
    text-align: center;
}

.closing-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 1rem;
    color: var(--faded-notation);
    margin-top: 2rem;
    letter-spacing: 0.05em;
}

.closing-year {
    font-family: 'Cormorant SC', Georgia, serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--celestial-gold);
    margin-top: 1.5rem;
    opacity: 0.6;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .parchment {
        padding: 0 20px;
    }

    .entry {
        padding: 80px 0;
    }

    .star-nav {
        right: 10px;
    }

    .star-nav-marker {
        padding: 8px 4px;
        font-size: 0.6rem;
    }

    .moon-phases {
        gap: 0.6rem;
    }

    .moon-phase {
        width: 16px;
        height: 16px;
    }

    .entry-fullbleed .star-chart {
        padding: 2rem 1rem;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }

    .entry-heading {
        font-size: clamp(1.6rem, 5vw, 2.2rem);
    }

    .entry {
        padding: 60px 0;
    }

    .constellation-diagram {
        max-width: 300px;
    }
}

/* --- Selection Color --- */
::selection {
    background: var(--pastel-lavender);
    color: var(--midnight-ink);
}

/* --- Scrollbar Styling (subtle) --- */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--pastel-lavender);
    border-radius: 3px;
    opacity: 0.5;
}
