/* ===========================================
   xanadu.wiki - Warm Monochromatic Scholarly Design
   =========================================== */

/* --- Color Reference (all DESIGN.md colors) ---
   #2A241C - Primary Text (Charcoal Brown)
   #8B7355 - Secondary Text (Warm Brown)
   #B8A89C - Tertiary Text (Sage Brown)
   #D8D4CC - Lightest Text / Borders (Faded Brown)
   #FDFBF8 - Background Primary (Off-White)
   #FFFCF7 - Background Secondary (Light Cream)
   #F7F1E8 - Background Tertiary (Soft Warm)
   #C89968 - Node Accent (Warm Gold) - used in graph nodes
   #6B5B47 - Accent Hover (Deep Brown)
   #AAAAAA - Footer text
   #00000008 - Shadow Color
--- */

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

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

body {
    font-family: 'Commissioner', sans-serif;
    font-weight: 400;
    color: #2A241C;
    background-color: #FDFBF8;
    line-height: 1.75;
    font-size: clamp(0.95rem, 1vw, 1.1rem);
    overflow-x: hidden;
    /* Subtle aged-paper diagonal pattern */
    background-image: repeating-linear-gradient(
        135deg,
        transparent,
        transparent 39px,
        rgba(42, 36, 28, 0.01) 39px,
        rgba(42, 36, 28, 0.01) 40px
    );
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Commissioner', sans-serif;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.meta-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    color: #8B7355;
}

.annotation-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1rem;
    color: #8B7355;
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    color: #2A241C;
    margin-bottom: 2rem;
    text-align: center;
}

/* ===========================================
   Opening Portal Section (0-50vh)
   =========================================== */
#opening-portal {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: 25vh;
    padding-left: 25vw;
    overflow: hidden;
}

#background-network {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#site-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    text-transform: uppercase;
    color: #2A241C;
    letter-spacing: -0.02em;
    line-height: 1.2;
    z-index: 10;
    opacity: 0;
    transition: opacity 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#site-title.visible {
    opacity: 1;
}

#site-subtitle {
    z-index: 10;
    margin-top: 0.25rem;
    opacity: 0;
    transition: opacity 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 300ms;
}

#site-subtitle.visible {
    opacity: 1;
}

/* ===========================================
   Welcome Node Section (50vh-150vh)
   =========================================== */
#welcome-node {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
}

.welcome-card {
    max-width: 65ch;
    background: #FFFCF7;
    border: 1px solid #D8D4CC;
    box-shadow: 0 1px 3px #00000008;
    padding: 3rem;
    border-radius: 2px;
}

.welcome-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.connectivity-icon {
    flex-shrink: 0;
}

.welcome-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    color: #2A241C;
}

.welcome-text p {
    margin-bottom: 1.25rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

.welcome-text p:nth-child(2) {
    transition-delay: 100ms;
}

.welcome-text p:nth-child(3) {
    transition-delay: 200ms;
}

.explore-link {
    display: inline-block;
    margin-top: 1.5rem;
    color: #6B5B47;
    text-decoration: none;
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    transition: text-decoration-color 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-bottom: 1px solid transparent;
}

.explore-link:hover {
    border-bottom-color: #6B5B47;
}

/* ===========================================
   Topic Grid Section (150vh-400vh)
   =========================================== */
#topic-grid {
    min-height: 250vh;
    padding: 6rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.topic-nodes-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, 180px);
    gap: 1.5rem;
    justify-content: center;
    padding: 2rem 0;
}

.topic-node {
    width: 180px;
    height: 180px;
    background: #FFFCF7;
    border: 1px solid #D8D4CC;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    text-align: center;
    border-radius: 2px;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                border-color 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                background-color 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.topic-node.visible {
    opacity: 1;
    transform: scale(1);
}

.topic-node:hover {
    border-color: #B8A89C;
    background-color: #F7F1E8;
}

.node-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 600;
    font-size: 1.125rem;
    color: #2A241C;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.node-count {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 0.875rem;
    color: #C89968;
}

/* ===========================================
   Connection Visualization Section (400vh-550vh)
   =========================================== */
#connection-viz {
    min-height: 150vh;
    padding: 6rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.viz-description {
    max-width: 65ch;
    text-align: center;
    margin-bottom: 3rem;
}

#force-graph {
    width: 100%;
    max-width: 1200px;
    height: 600px;
    background: #FFFCF7;
    border: 1px solid #D8D4CC;
    border-radius: 2px;
}

#force-graph .graph-edge {
    stroke: #D8D4CC;
    stroke-opacity: 0.4;
    fill: none;
    stroke-width: 1.5;
}

#force-graph .graph-node {
    cursor: pointer;
    transition: r 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#force-graph .graph-label {
    font-family: 'Caveat', cursive;
    font-size: 13px;
    fill: #8B7355;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#force-graph .graph-node:hover + .graph-label,
#force-graph .graph-label.active {
    opacity: 1;
}

/* ===========================================
   Document Gallery Section (550vh-700vh)
   =========================================== */
#document-gallery {
    min-height: 150vh;
    padding: 6rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.documents-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 300px));
    gap: 2rem;
    justify-content: center;
    padding: 2rem 0;
}

.document-card {
    background: #FFFCF7;
    border: 1px solid #D8D4CC;
    border-radius: 2px;
    padding: 1.5rem;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                border-color 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.document-card.visible {
    opacity: 1;
    transform: translateX(0);
}

.document-card:hover {
    border-color: #B8A89C;
    box-shadow: 0 2px 6px #00000008;
}

.doc-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    color: #2A241C;
    margin-bottom: 0.35rem;
    line-height: 1.3;
}

.doc-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    color: #8B7355;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.doc-excerpt {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #2A241C;
    margin-bottom: 1rem;
}

.doc-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.doc-related {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    color: #B8A89C;
    text-decoration: none;
    letter-spacing: 0.03em;
    transition: color 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.doc-related:hover {
    color: #8B7355;
}

/* ===========================================
   Closing Reflection Section (700vh+)
   =========================================== */
#closing-reflection {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8rem 2rem 4rem;
}

.reflection-content {
    max-width: 65ch;
    text-align: center;
}

.reflection-content p {
    font-family: 'Commissioner', sans-serif;
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.8;
    color: #2A241C;
    margin-bottom: 2rem;
    letter-spacing: 0.01em;
}

#site-footer {
    margin-top: 6rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 2rem 0;
}

.footer-item {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    color: #AAAAAA;
    letter-spacing: 0.05em;
}

/* ===========================================
   Responsive Breakpoints
   =========================================== */

/* Tablet: 768px */
@media (max-width: 768px) {
    #opening-portal {
        padding-top: 20vh;
        padding-left: 10vw;
    }

    .topic-nodes-container {
        grid-template-columns: repeat(2, 180px);
    }

    .documents-container {
        grid-template-columns: 1fr 1fr;
    }

    .welcome-card {
        padding: 2rem;
    }

    #force-graph {
        height: 400px;
    }
}

/* Mobile: 480px */
@media (max-width: 480px) {
    #opening-portal {
        padding-top: 25vh;
        padding-left: 8vw;
    }

    .topic-nodes-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .topic-node {
        width: 100%;
        height: auto;
        min-height: 120px;
    }

    .documents-container {
        grid-template-columns: 1fr;
    }

    #force-graph {
        height: 300px;
    }

    .welcome-card {
        padding: 1.5rem;
    }

    #site-footer {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .reflection-content p {
        font-size: 1rem;
    }
}
