/* ==========================================================================
   naru.day — Dark-Academia / Dopamine-Neon Journal
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
    --library-dark: #1A1418;
    --neon-amber: #E8A030;
    --neon-rose: #E84878;
    --page-cream: #E8DCC8;
    --grain-warm: #3A3028;
    --margin-gray: #7A7068;
    --ink-deep: #0A0808;

    --font-headline: 'Jost', sans-serif;
    --font-body: 'Lora', serif;

    --content-width: 600px;
    --entry-spacing: 80px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--library-dark);
    color: var(--page-cream);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(16px, 1.1vw, 18px);
    line-height: 1.95;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- SVG Filters (hidden) --- */
#svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Grain Overlay --- */
#grain-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.15;
    background-image: 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.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    mix-blend-mode: overlay;
    animation: grain-drift 8s steps(10) infinite;
}

@keyframes grain-drift {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -10%); }
    20% { transform: translate(-15%, 5%); }
    30% { transform: translate(7%, -25%); }
    40% { transform: translate(-5%, 25%); }
    50% { transform: translate(-15%, 10%); }
    60% { transform: translate(15%, 0%); }
    70% { transform: translate(0%, 15%); }
    80% { transform: translate(3%, 35%); }
    90% { transform: translate(-10%, 10%); }
}

/* --- Light Pool (scroll-following) --- */
#light-pool {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background: radial-gradient(
        ellipse 500px 600px at 50% 50%,
        rgba(232, 160, 48, 0.08) 0%,
        rgba(232, 160, 48, 0.03) 40%,
        transparent 70%
    );
    transition: background 0.6s ease;
}

/* --- Glitch Layer --- */
#glitch-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    opacity: 0;
}

#glitch-layer.glitching {
    opacity: 1;
    animation: glitch-flash 150ms steps(2) forwards;
}

@keyframes glitch-flash {
    0% {
        backdrop-filter: hue-rotate(180deg) saturate(3);
        clip-path: inset(20% 0 60% 0);
    }
    33% {
        backdrop-filter: hue-rotate(90deg) saturate(2);
        clip-path: inset(50% 0 20% 0);
    }
    66% {
        backdrop-filter: hue-rotate(270deg) saturate(4);
        clip-path: inset(10% 0 70% 0);
    }
    100% {
        backdrop-filter: none;
        clip-path: inset(0);
        opacity: 0;
    }
}

/* --- Dawn Page (Hero Section) --- */
#dawn-page {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 2;
}

.dawn-light-pool {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%) scale(0);
    background: radial-gradient(
        ellipse 50% 50% at 50% 50%,
        rgba(232, 160, 48, 0.12) 0%,
        rgba(232, 160, 48, 0.05) 35%,
        rgba(232, 160, 48, 0.02) 60%,
        transparent 80%
    );
    animation: lamplight-bloom 1200ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
    pointer-events: none;
    z-index: 0;
}

@keyframes lamplight-bloom {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.dawn-content {
    position: relative;
    z-index: 2;
    text-align: center;
    opacity: 0;
    animation: fade-in 800ms ease forwards;
    animation-delay: 800ms;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.site-title {
    font-family: var(--font-headline);
    font-weight: 600;
    font-size: clamp(32px, 5vw, 64px);
    letter-spacing: 0.01em;
    color: var(--page-cream);
    text-shadow: 0 0 60px rgba(232, 160, 48, 0.3), 0 0 120px rgba(232, 160, 48, 0.1);
    margin-bottom: 24px;
}

.date-stamp-panel {
    display: inline-block;
    padding: 8px 20px;
    border: 1px solid var(--margin-gray);
    background: rgba(58, 48, 40, 0.4);
    position: relative;
}

.date-stamp-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.08;
    mix-blend-mode: overlay;
    pointer-events: none;
}

.date-stamp {
    font-family: var(--font-headline);
    font-weight: 300;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--margin-gray);
}

/* Dawn Divider */
.divider-dawn {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fade-in 800ms ease forwards;
    animation-delay: 1500ms;
}

/* --- Journal Stream --- */
#journal-stream {
    position: relative;
    z-index: 2;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 60px 24px 120px;
}

/* --- Journal Entry --- */
.journal-entry {
    position: relative;
    margin-bottom: var(--entry-spacing);
    opacity: 1;
}

.entry-date-panel {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid rgba(122, 112, 104, 0.4);
    background: rgba(58, 48, 40, 0.3);
    margin-bottom: 20px;
    position: relative;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.entry-date-panel:hover {
    border-color: rgba(232, 160, 48, 0.4);
    box-shadow: 0 0 12px rgba(232, 160, 48, 0.1);
}

.entry-date-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.06;
    mix-blend-mode: overlay;
    pointer-events: none;
}

.entry-date {
    font-family: var(--font-headline);
    font-weight: 300;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--margin-gray);
}

/* --- Margin Notes --- */
.margin-note {
    position: absolute;
    font-family: var(--font-body);
    font-weight: 400;
    font-style: italic;
    font-size: 13px;
    color: var(--margin-gray);
    opacity: 0;
    transition: opacity 0.5s ease;
    white-space: nowrap;
}

.margin-note.visible {
    opacity: 0.7;
}

.margin-note[data-side="left"] {
    right: calc(100% + 24px);
    top: 60px;
    text-align: right;
}

.margin-note[data-side="right"] {
    left: calc(100% + 24px);
    top: 60px;
    text-align: left;
}

/* --- Entry Body --- */
.entry-body {
    color: var(--page-cream);
}

.entry-body p {
    margin-bottom: 1.4em;
}

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

.entry-body em {
    color: var(--neon-amber);
    font-style: italic;
}

/* --- Text Links --- */
.text-link {
    color: var(--page-cream);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.text-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--neon-amber);
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 0 8px rgba(232, 160, 48, 0.4);
}

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

.text-link:hover::after {
    opacity: 1;
}

/* --- Neon Rose Accent --- */
.neon-rose {
    color: var(--neon-rose);
    text-shadow: 0 0 20px rgba(232, 72, 120, 0.3);
}

/* --- Dividers --- */
.divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    margin-bottom: var(--entry-spacing);
}

.flourish {
    width: 280px;
    height: auto;
    overflow: visible;
    transition: opacity 0.3s ease;
}

.flourish:hover {
    opacity: 1 !important;
}

/* SVG stroke animation for dividers */
.flourish path,
.flourish circle {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: opacity 0.3s ease;
}

.flourish.drawn path,
.flourish.drawn circle {
    animation: draw-stroke 800ms ease forwards;
}

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

.divider-final {
    margin-bottom: 40px;
}

/* --- Footer --- */
#site-footer {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 40px 0 60px;
}

.footer-text {
    font-family: var(--font-headline);
    font-weight: 300;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--margin-gray);
    opacity: 0.5;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .margin-note {
        position: relative;
        right: auto;
        left: auto;
        top: auto;
        display: block;
        margin-bottom: 12px;
        white-space: normal;
        opacity: 0.7;
    }

    .margin-note.visible {
        opacity: 0.7;
    }

    .margin-note[data-side="left"],
    .margin-note[data-side="right"] {
        right: auto;
        left: auto;
        top: auto;
        text-align: left;
    }
}

@media (max-width: 640px) {
    #journal-stream {
        padding: 40px 20px 80px;
    }

    .flourish {
        width: 200px;
    }

    :root {
        --entry-spacing: 50px;
    }
}
