/* =========================================================
   JJUGGL.dev — Celestial Manuscript Design System
   Palette: #1C1430, #2A1F3D, #3D2E5C, #7B5EA7, #9B8EC4,
            #C9A84C, #E8E2F5, #F5EDD8
   Fonts: Fraunces (display), Crimson Pro (body), DM Sans (nav/labels)
   ========================================================= */

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

html {
    height: 100%;
    overflow: hidden;
}

body {
    height: 100vh;
    overflow: hidden;
    background-color: #1C1430;
    color: #E8E2F5;
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 18px;
    line-height: 1.7;
    display: flex;
}

/* --- Sidebar --- */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: linear-gradient(180deg, #1C1430 0%, #2A1F3D 55%, #1C1430 100%);
    border-right: 1px solid rgba(155, 142, 196, 0.28);
    box-shadow: 2px 0 12px rgba(155, 142, 196, 0.08), inset -1px 0 0 rgba(155, 142, 196, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0 30px;
    z-index: 100;
    overflow: hidden;
}

.sidebar-marble {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 60px,
        rgba(155, 142, 196, 0.025) 60px,
        rgba(155, 142, 196, 0.025) 62px
    );
    pointer-events: none;
    z-index: 0;
}

/* Vertical logo — rotated 90deg, placed at top */
#sidebar-logo {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0 20px;
    margin-bottom: 44px;
}

.logo-text {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 700, 'opsz' 144, 'WONK' 1;
    font-size: 22px;
    color: #C9A84C;
    letter-spacing: 0.06em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    white-space: nowrap;
    text-transform: uppercase;
    height: 180px;
    line-height: 1;
    text-shadow: 0 0 30px rgba(201, 168, 76, 0.3);
    transition: font-variation-settings 250ms ease;
}

.logo-text:hover {
    font-variation-settings: 'wght' 900, 'opsz' 144, 'WONK' 1;
}

/* Sidebar Navigation */
#sidebar-nav {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 0 28px;
}

#sidebar-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #9B8EC4;
    text-decoration: none;
    padding: 8px 12px;
    border-left: 2px solid transparent;
    transition: color 200ms ease-out, border-left-color 300ms ease-out;
}

.nav-item:hover,
.nav-item.active {
    color: #F5EDD8;
    border-left-color: #C9A84C;
}

/* Sidebar Constellation */
#sidebar-constellation {
    position: relative;
    z-index: 2;
    margin-top: auto;
    width: 100%;
    padding: 0 20px 10px;
    display: flex;
    justify-content: center;
}

#sidebar-svg {
    animation: constellation-float 8s ease-in-out infinite;
}

@keyframes constellation-float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}

/* Star nodes pulse */
.star-node {
    animation: star-pulse 4s ease-in-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}

.star-node:nth-child(odd) {
    animation-delay: 0s;
}

.star-node:nth-child(even) {
    animation-delay: 2s;
}

@keyframes star-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* --- Main Content --- */
#main-content {
    position: fixed;
    left: 240px;
    top: 0;
    right: 0;
    bottom: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    background-color: #1C1430;
    scroll-behavior: smooth;
}

/* Starfield */
#starfield-container {
    position: fixed;
    left: 240px;
    top: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

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

/* Watercolor Blobs */
#watercolor-blobs {
    position: fixed;
    left: 240px;
    top: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.blob-svg {
    position: absolute;
    pointer-events: none;
}

.blob-1 {
    top: -10%;
    right: -5%;
    width: 60%;
    height: 60%;
    animation: blob-drift-1 38s ease-in-out infinite;
}

.blob-2 {
    bottom: 10%;
    left: 5%;
    width: 50%;
    height: 50%;
    animation: blob-drift-2 45s ease-in-out infinite;
}

.blob-3 {
    top: 40%;
    right: 20%;
    width: 45%;
    height: 45%;
    animation: blob-drift-3 32s ease-in-out infinite;
}

@keyframes blob-drift-1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(-3%, 5%) scale(1.05); }
    50% { transform: translate(4%, -3%) scale(0.97); }
    75% { transform: translate(-2%, -4%) scale(1.03); }
}

@keyframes blob-drift-2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    30% { transform: translate(4%, -3%) scale(1.04); }
    60% { transform: translate(-3%, 5%) scale(0.96); }
    80% { transform: translate(2%, 3%) scale(1.02); }
}

@keyframes blob-drift-3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    20% { transform: translate(2%, 4%) scale(1.03); }
    55% { transform: translate(-4%, -2%) scale(0.98); }
    80% { transform: translate(3%, -3%) scale(1.05); }
}

/* --- Content Sections --- */
.content-section {
    position: relative;
    z-index: 10;
    padding: 80px 0 60px;
    min-height: 80vh;
}

.section-inner {
    max-width: 720px;
    padding: 0 60px;
}

/* Stagger layout */
.stagger-left .section-inner {
    margin-left: 60px;
    margin-right: auto;
}

.stagger-right .section-inner {
    margin-left: 100px;
    margin-right: auto;
}

/* Entry animation — starts hidden */
.content-section {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 700ms cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 700ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

/* Section header area */
.section-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.section-constellation {
    opacity: 0.85;
    flex-shrink: 0;
}

.section-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    letter-spacing: 0.25em;
    color: #7B5EA7;
    text-transform: uppercase;
    opacity: 0.8;
}

/* Headings */
.display-heading {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 800, 'opsz' 144, 'WONK' 1;
    font-size: clamp(2.4rem, 5vw, 4.2rem);
    line-height: 1.08;
    color: #F5EDD8;
    margin-bottom: 28px;
    letter-spacing: -0.02em;
    transition: font-variation-settings 250ms ease;
}

.display-heading em {
    font-style: italic;
    color: #C9A84C;
    font-variation-settings: 'wght' 600, 'opsz' 144, 'WONK' 1;
}

.display-heading:hover {
    font-variation-settings: 'wght' 900, 'opsz' 144, 'WONK' 1;
}

.section-heading {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 700, 'opsz' 48, 'WONK' 1;
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    line-height: 1.15;
    color: #F5EDD8;
    margin-bottom: 24px;
    letter-spacing: -0.015em;
    transition: font-variation-settings 250ms ease;
}

.section-heading em {
    font-style: italic;
    color: #C9A84C;
}

.section-heading:hover {
    font-variation-settings: 'wght' 900, 'opsz' 48, 'WONK' 1;
}

/* Watercolor Divider */
.watercolor-divider {
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(123, 94, 167, 0.4) 20%,
        rgba(201, 168, 76, 0.5) 50%,
        rgba(123, 94, 167, 0.4) 80%,
        transparent 100%
    );
    margin: 0 0 32px;
    border-radius: 2px;
    position: relative;
}

.watercolor-divider::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(201, 168, 76, 0.2) 40%,
        rgba(201, 168, 76, 0.2) 60%,
        transparent
    );
}

/* Section body text */
.section-body {
    color: #E8E2F5;
}

.lead-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 400;
    color: #F5EDD8;
    line-height: 1.65;
    margin-bottom: 20px;
}

p {
    font-size: 1rem;
    color: #E8E2F5;
    line-height: 1.75;
    margin-bottom: 16px;
}

.pull-quote {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 400, 'opsz' 48, 'WONK' 0;
    font-style: italic;
    font-size: 1.3rem;
    color: #F5EDD8;
    border-left: 2px solid #C9A84C;
    padding: 12px 0 12px 24px;
    margin: 28px 0;
    background: linear-gradient(90deg, rgba(201, 168, 76, 0.05), transparent);
}

/* Ink-drawn horizontal rule */
.ink-rule {
    display: block;
    margin-top: 48px;
    opacity: 0.6;
}

/* --- Project List --- */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-top: 28px;
}

.project-item {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.project-node {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #C9A84C;
    box-shadow: 0 0 10px rgba(201, 168, 76, 0.4);
    flex-shrink: 0;
    margin-top: 8px;
}

.project-content {
    flex: 1;
}

.project-title {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 600, 'opsz' 48, 'WONK' 1;
    font-size: 1.2rem;
    color: #F5EDD8;
    margin-bottom: 6px;
    transition: font-variation-settings 250ms ease, color 200ms ease;
}

.project-title:hover {
    font-variation-settings: 'wght' 800, 'opsz' 48, 'WONK' 1;
    color: #C9A84C;
}

.project-desc {
    font-size: 0.95rem;
    color: #E8E2F5;
    opacity: 0.85;
    margin-bottom: 8px;
    line-height: 1.65;
}

.project-tag {
    font-family: 'DM Sans', sans-serif;
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #9B8EC4;
    opacity: 0.8;
}

/* --- Cartography Grid --- */
.cartography-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 28px;
}

.map-item {
    padding: 20px;
    border: 1px solid rgba(155, 142, 196, 0.2);
    background: rgba(42, 31, 61, 0.4);
    position: relative;
    overflow: hidden;
}

.map-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(201, 168, 76, 0.4), transparent);
}

.map-label {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 600, 'opsz' 48, 'WONK' 1;
    font-size: 1rem;
    color: #C9A84C;
    margin-bottom: 8px;
}

.map-desc {
    font-size: 0.88rem;
    color: #E8E2F5;
    opacity: 0.8;
    line-height: 1.6;
}

/* --- Instruments --- */
.instruments-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 28px;
}

.instrument {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 12px;
    border-bottom: 1px solid rgba(155, 142, 196, 0.2);
}

.instrument-icon {
    margin-bottom: 14px;
    opacity: 0.9;
}

.instrument-name {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 600, 'opsz' 48, 'WONK' 1;
    font-size: 1rem;
    color: #F5EDD8;
    margin-bottom: 8px;
    transition: font-variation-settings 250ms ease, color 200ms ease;
}

.instrument:hover .instrument-name {
    font-variation-settings: 'wght' 800, 'opsz' 48, 'WONK' 1;
    color: #C9A84C;
}

.instrument-desc {
    font-size: 0.82rem;
    color: #9B8EC4;
    line-height: 1.55;
    margin-bottom: 0;
}

/* --- Atlas Entries --- */
.atlas-entries {
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin-top: 28px;
}

.atlas-entry {
    padding-bottom: 28px;
    border-bottom: 1px solid rgba(155, 142, 196, 0.15);
    position: relative;
}

.atlas-entry::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7B5EA7;
    box-shadow: 0 0 8px rgba(123, 94, 167, 0.5);
}

.entry-date {
    font-family: 'DM Sans', sans-serif;
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #7B5EA7;
    margin-bottom: 8px;
}

.entry-title {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 600, 'opsz' 48, 'WONK' 1;
    font-size: 1.15rem;
    color: #F5EDD8;
    margin-bottom: 10px;
    line-height: 1.3;
    transition: font-variation-settings 250ms ease, color 200ms ease;
}

.atlas-entry:hover .entry-title {
    font-variation-settings: 'wght' 800, 'opsz' 48, 'WONK' 1;
    color: #C9A84C;
}

.entry-excerpt {
    font-size: 0.93rem;
    color: #E8E2F5;
    opacity: 0.8;
    line-height: 1.7;
    margin-bottom: 10px;
}

.entry-tag {
    font-family: 'DM Sans', sans-serif;
    font-size: 9px;
    letter-spacing: 0.18em;
    color: #9B8EC4;
    opacity: 0.75;
}

/* --- Contact Grid --- */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 40px;
    margin: 28px 0 32px;
}

.contact-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(155, 142, 196, 0.15);
}

.contact-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 9px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #7B5EA7;
}

.contact-value {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.05rem;
    color: #E8E2F5;
}

.closing-note {
    font-family: 'Fraunces', Georgia, serif;
    font-variation-settings: 'wght' 400, 'opsz' 48, 'WONK' 0;
    font-style: italic;
    font-size: 1.05rem;
    color: #9B8EC4;
    margin-top: 24px;
    line-height: 1.6;
}

/* --- Scrollbar styling for main content --- */
#main-content::-webkit-scrollbar {
    width: 4px;
}

#main-content::-webkit-scrollbar-track {
    background: #1C1430;
}

#main-content::-webkit-scrollbar-thumb {
    background: rgba(155, 142, 196, 0.3);
    border-radius: 2px;
}

#main-content::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.4);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    #sidebar {
        width: 180px;
    }
    #starfield-container,
    #watercolor-blobs,
    #main-content {
        left: 180px;
    }
    .stagger-right .section-inner {
        margin-left: 60px;
    }
    .instruments-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .cartography-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    #sidebar {
        width: 60px;
    }
    #starfield-container,
    #watercolor-blobs,
    #main-content {
        left: 60px;
    }
    .logo-text {
        font-size: 14px;
    }
    #sidebar-nav,
    #sidebar-constellation {
        display: none;
    }
    .stagger-left .section-inner,
    .stagger-right .section-inner {
        margin-left: 20px;
        padding: 0 20px;
    }
    .instruments-row {
        grid-template-columns: 1fr 1fr;
    }
    .contact-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Pulsing star animation classes (assigned in JS) --- */
@keyframes star-twinkle {
    0%, 100% { opacity: var(--star-base-opacity, 0.3); }
    50% { opacity: var(--star-peak-opacity, 0.7); }
}

.twinkling-star {
    animation: star-twinkle var(--star-duration, 4s) ease-in-out infinite;
}
