:root {
    --bg-color: #F9F7F2;
    --accent-color: #722F37;
    --text-color: #1A1A1A;
    --text-dark: #171818;
    --text-muted: #6B6B6B;
    --glass-bg: #F4F1EA;
    --glass-border: #E5E1D8;
    --font-main: 'Newsreader', serif;
    --font-ui: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    display: block;
}

/* Smooth Page Transitions */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.4s;
}

/* Make UI elements use sans-serif */
button, select, .badge, .camera-info-overlay, .debug-select, .step-num {
    font-family: var(--font-ui) !important;
}

.text-content h1, .text-content h2 {
    font-family: var(--font-main);
    color: var(--text-dark);
}




/* Section Layouts */
.intro-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent),
        radial-gradient(circle at bottom left, rgba(99, 102, 241, 0.05), transparent);
}

.intro-section h1 {
    font-size: 3.5rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.4em;
    margin-bottom: 4rem;
    color: var(--text-color);
    text-align: center;
    line-height: 1.2;
}

.intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4rem;
    max-width: 1600px;
    width: 100%;
}

.intro-text {
    max-width: 1200px;
    width: 100%;
}



.header-image {
    max-width: 700px;
    width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.15);
    border: 12px solid white;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.header-image:hover {
    transform: scale(1.03) translateY(-10px);
}

/* Card Interaction Enhancements */
.nav-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.nav-card.active {
    transform: none;
    box-shadow: none;
}













.instruction-steps {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 0.5rem;
}

.step {
    display: none;
    gap: 1rem;
    align-items: flex-start;
}

.step.active {
    display: flex;
}

.walkthrough-section .step {
    display: none;
}

.walkthrough-section .step.active {
    display: flex !important;
}

#walkthroughCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    outline: none;
}

.step-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover:not(:disabled) {
    background: var(--accent-color);
    color: white;
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #cbd5e1;
    color: #94a3b8;
}

.step-num {
    font-family: serif;
    font-weight: 600;
    color: var(--accent-color);
    font-size: 1rem;
    min-width: 1.25rem;
    text-align: right;
}

.step p {
    margin: 0;
    color: #475569;
    font-size: 0.85rem;
}

.inline-icon {
    width: 1.1em;
    height: 1.1em;
    vertical-align: middle;
    display: inline-block;
    margin: 0 0.1rem;
    stroke: var(--text-color);
}

.button-container {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.object-toggles {
    display: flex;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-toggle {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-toggle.active {
    background: var(--accent-color);
    color: white;
    /* Removed white glow box-shadow */
}

.action-buttons-overlay {
    position: absolute;
    bottom: 2rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    /* Let clicks pass through empty areas */
}

.rotate-controls {
    position: absolute;
    left: 0;
    bottom: 0;
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

.zoom-controls {
    position: absolute;
    right: 0;
    bottom: 0;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

.button-group {
    display: flex;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 0.25rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    /* Re-enable clicks for the buttons */
    gap: 0.5rem;
}

.btn-icon {
    border: none;
    background: transparent;
    color: var(--text-color);
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s ease;
    flex-shrink: 0;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-icon:hover {
    color: var(--accent-color);
}

.btn-icon:active {
    opacity: 0.7;
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-icon:disabled:hover {
    color: var(--text-color);
}

#animateBtn.playing {
    color: var(--accent-color);
    background: rgba(99, 102, 241, 0.1);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 0.375rem;
    color: var(--accent-color);
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

@media (max-width: 1200px) {
    .intro-section h1 {
        font-size: 2.5rem;
        letter-spacing: 0.2em;
    }

    .header-image {
        max-width: 90%;
    }
}


/* References Section Styles */
.references-section {
    background-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-top: 1px solid var(--glass-border);
}

.references-section h2 {
    font-size: 2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 4rem;
    color: var(--text-color);
}

.references-list {
    list-style: decimal;
    padding-left: 2rem;
    max-width: 1600px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.references-list li {
    padding: 0.5rem 0;
    font-size: 1.1rem;
    color: var(--text-color);
}

.references-list a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    display: inline-block;
}

.references-list a:hover {
    background: rgba(99, 102, 241, 0.05);
    color: #4f46e5;
    text-decoration: underline;
}

@media (max-width: 900px) {












    .references-list {
        padding-left: 1.5rem;
    }

    .references-list a {
        padding: 0.25rem 0.5rem;
        font-size: 1rem;
    }
}


.demo-section,
.explanation-section,
.walkthrough-section,
.intro-section,
.references-section {
    position: relative;
    width: 100%;
    border-top: 1px solid var(--glass-border);
    padding: 4rem 2rem;
    box-sizing: border-box;
}

.demo-layout {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
}

.demo-left-column {
    width: 100%;
    z-index: 20;
    display: flex;
    flex-direction: column;
}

.demo-right-column {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: transparent;
    border: none;
    padding: 2rem;
    padding-top: 0; /* Reduced top padding as text-content is above */
    border-radius: 0;
    box-shadow: none;
}

.text-content {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 2.5rem 2rem 1rem 2rem; /* More top padding, less bottom */
    box-shadow: none;
}

.text-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.text-content p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.text-content h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.canvas-container,
.apparatus-preview-container {
    flex: 1;
    position: relative;
    min-height: 500px;
    border-radius: 0.5rem;
    overflow: hidden;
}

#renderCanvas,
#rayTracingCanvas,
#rayTracingCanvasFinal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    outline: none;
    touch-action: none;
}

@media (max-width: 1024px) {
    .demo-layout {
        flex-direction: column;
    }

    .demo-left-column {
        position: static;
        max-width: 100%;
        padding: 1.5rem;
        pointer-events: auto;
    }

    .text-content {
        background: transparent;
        backdrop-filter: none;
        border: none;
        padding: 0;
        box-shadow: none;
    }

    .demo-right-column {
        padding: 0 1.5rem 1.5rem 1.5rem;
    }

    .canvas-container,
    .apparatus-preview-container {
        height: 60vh;
        min-height: 400px;
    }

    .demo-section,
    .explanation-section,
    .walkthrough-section,
    .intro-section,
    .references-section {
        padding: 3rem 1.5rem;
    }
}
@media (max-width: 768px) {
    .demo-section,
    .explanation-section,
    .walkthrough-section,
    .intro-section,
    .references-section {
        padding: 2rem 1rem;
    }

    .rotate-controls .button-group,
    .zoom-controls .button-group {
        flex-direction: column;
    }
}

/* ── Woodcut Caption ───────────────────────────────────────────────────────── */
.woodcut-caption {
    max-width: 1200px;
    text-align: center;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.7;
    margin-top: 1.25rem;
}

/* ── Explanation Section ──────────────────────────────────────────────────── */
.explanation-section {
    background: transparent;
    border-bottom: 1px solid var(--glass-border);
}

/* ── Right: 3D preview canvas ────────────────────────────────────────────── */

#stepOneCanvas,
#stepTwoCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    outline: none;
}

#previewCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    outline: none;
    touch-action: none;
}

/* ── Canvas Navigation Buttons ────────────────────────────────────────────── */
.canvas-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3.5rem;
    height: 3.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.canvas-nav-btn svg {
    width: 1.5rem;
    height: 1.5rem;
}

.canvas-nav-btn:hover {
    opacity: 1;
    background: white;
    color: var(--accent-color);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.canvas-nav-btn.prev {
    left: 1.5rem;
}

.canvas-nav-btn.next {
    right: 1.5rem;
}

.canvas-nav-btn.bottom {
    top: auto;
    bottom: 1.5rem;
    transform: none;
}

.canvas-nav-btn.bottom:hover {
    transform: scale(1.1);
}

.canvas-nav-btn:disabled {
    opacity: 0.1;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Annotation pills ─────────────────────────────────────────────────────── */
.apparatus-pill {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: white;
    color: black;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding-top: 1px;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid black;
    visibility: hidden;
    /* shown by JS once positioned */
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.apparatus-pill:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.apparatus-pill::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    font-family: 'Inter', sans-serif;
    font-weight: normal;
}

.apparatus-pill:hover::after {
    opacity: 1;
    visibility: visible;
}

.apparatus-pill.active {
    background: var(--accent-color);
    color: white;
    border-color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.45);
}

/* ── Debug Overlays ──────────────────────────────────────────────────────── */
.debug-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    z-index: 100;
}

.camera-info-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-color);
    font-family: monospace;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    line-height: 1.4;
    white-space: pre;
}

.debug-select {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-main);
    cursor: pointer;
    outline: none;
}

.debug-select:hover {
    border-color: var(--accent-color);
}

#normalsBtn.active {
    color: var(--accent-color);
    background: rgba(99, 102, 241, 0.1);
}