:root {
    /* "Modern Gallery" Theme: Compact Viewport Edition */
    --bg-color: #fdfdfd;
    --card-bg: #ffffff;
    --text-color: #061735;
    --muted-text: #4a5b7c;
    --accent-color: #B3892C;
    --border-color: #e2e8f0;
    
    --font-serif: 'Merriweather', 'Georgia', serif;
    --font-sans: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    
    --border-radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    font-size: 16px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3 {
    font-family: var(--font-serif);
    color: var(--text-color);
    margin-top: 0;
    line-height: 1.1;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

a:hover {
    color: #061735;
}

/* Header - Uncluttered */
header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    border-bottom: none; /* Override default link style */
}

.full-logo {
    height: 40px;
    width: auto;
    display: block;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
}

nav a.special {
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
nav a.special:hover {
    background: var(--accent-color);
    color: #fff;
}

/* Main Layout */
main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

footer {
    text-align: center;
    padding: 1rem 0;
    color: var(--muted-text);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-color);
    background: #fff;
    flex-shrink: 0;
}

/* Home Page - Clean Gallery Wall (Compact 100vh) */
.hero {
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Ensure it doesn't overflow */
    overflow: hidden; 
}

.hero h2 {
    font-size: 2.5rem; /* Reduced from 3rem */
    margin-bottom: 0.25rem;
}

.hero p {
    font-size: 1.1rem; /* Reduced from 1.25rem */
    color: var(--muted-text);
    margin-bottom: 2rem; /* Reduced from 3rem */
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Changed to 3 columns */
    gap: 2rem; /* Reduced from 3rem */
    max-width: 1000px; /* Slightly wider for 3 cols */
    margin: 0 auto 1.5rem auto; /* Reduced bottom margin */
    text-align: left;
}

/* --- Perception & Structure (Curator's Cut) --- */
/* Closure: "The Alignment" */
.perception-closure .demo-canvas { background: #1a1a1a; }
.perception-closure .demo-canvas::before { /* Static arc */
    content: '';
    width: 150px; height: 150px;
    border: 15px solid var(--accent-color);
    border-radius: 50%;
    border-color: var(--accent-color) var(--accent-color) transparent transparent;
    transform: rotate(45deg);
    animation: none;
}
.perception-closure .demo-canvas::after { /* User-controlled arc */
    content: '';
    width: 150px; height: 150px;
    border: 15px solid var(--accent-color);
    border-radius: 50%;
    border-color: transparent transparent var(--accent-color) var(--accent-color);
    animation: none;
    transition: transform 0.1s ease-out, opacity 0.2s;
}
.js-active .perception-closure .demo-canvas::after {
    transform: rotate(calc(var(--int-x, 0.5) * 720deg - 360deg));
    opacity: calc(1 - abs(var(--int-x, 0.5) - 0.625) * 5); /* Opaque near solution */
}

@keyframes proximityGroup { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(20px, 0); } }
.perception-proximity .demo-canvas { background: #222; }
.perception-proximity .demo-canvas::before { content: ''; width: 10px; height: 10px; background: #fff; box-shadow: -20px 0 0 #fff, -20px 20px 0 #fff, 0 20px 0 #fff; position: absolute; left: 40%; animation: proximityGroup 7s ease-in-out infinite; }
.perception-proximity .demo-canvas::after { content: ''; width: 10px; height: 10px; background: var(--accent-color); box-shadow: 20px 0 0 var(--accent-color), 20px 20px 0 var(--accent-color), 0 20px 0 var(--accent-color); position: absolute; right: 40%; animation: proximityGroup 7s ease-in-out infinite reverse; }

@keyframes similarityPulse { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.2); opacity: 1; } }
.perception-similarity .demo-canvas { background: #111; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); width: 200px; height: 200px; gap: 10px; }
.perception-similarity .demo-canvas::before { content: ''; grid-area: 1 / 1 / 5 / 5; background-image: radial-gradient(circle, #333 4px, transparent 5px); background-size: 50px 50px; }
.perception-similarity .demo-canvas::after { content: ''; position: absolute; width: 40px; height: 40px; background: var(--accent-color); border-radius: 50%; top: calc(50% - 20px); left: calc(50% - 20px); box-shadow: 50px 0 0 var(--accent-color), -50px 0 0 var(--accent-color); animation: similarityPulse 4s ease-in-out infinite; }

@keyframes figureGroundShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.perception-figure-ground .demo-canvas { background: linear-gradient(90deg, #fff 50%, #000 50%); background-size: 200% 100%; animation: figureGroundShift 8s ease-in-out infinite; }
.perception-figure-ground .demo-canvas::before { content: ''; width: 100px; height: 150px; background: inherit; background-position: 100% 50%; border-radius: 50px; border: 4px solid var(--accent-color); mix-blend-mode: difference; }

@keyframes continuityFlow { 0% { background-position: 0 0; } 100% { background-position: 100px 0; } }
.perception-continuity .demo-canvas { background: #061735; }
.perception-continuity .demo-canvas::before { content: ''; width: 100%; height: 50px; background: repeating-linear-gradient(90deg, var(--accent-color) 0, var(--accent-color) 10px, transparent 10px, transparent 40px); opacity: 0.8; transform: rotate(15deg); animation: continuityFlow 2s linear infinite; }

/* --- Structure (The Grid) --- */
@keyframes goldenSpiral { 0% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(180deg) scale(0.6); } 100% { transform: rotate(360deg) scale(1); } }
.structure-golden-ratio .demo-canvas { background: #061735; overflow: hidden; }
.structure-golden-ratio .demo-canvas::before { content: ''; width: 200px; height: 200px; border: 1px solid rgba(255,255,255,0.3); border-radius: 0 0 200px 0; position: absolute; top: 20%; left: 20%; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); transform-origin: 0 0; animation: goldenSpiral 19s linear infinite; }

.structure-rule-of-thirds .demo-canvas { background: #061735; position: relative; }
.structure-rule-of-thirds .demo-canvas::before { content: ''; position: absolute; width: 100%; height: 100%; background: linear-gradient(90deg, transparent 33%, rgba(255,255,255,0.2) 33%, rgba(255,255,255,0.2) 34%, transparent 34%, transparent 66%, rgba(255,255,255,0.2) 66%, rgba(255,255,255,0.2) 67%, transparent 67%), linear-gradient(0deg, transparent 33%, rgba(255,255,255,0.2) 33%, rgba(255,255,255,0.2) 34%, transparent 34%, transparent 66%, rgba(255,255,255,0.2) 66%, rgba(255,255,255,0.2) 67%, transparent 67%); }
.structure-rule-of-thirds .demo-canvas::after { content: ''; width: 20px; height: 20px; background: var(--accent-color); border-radius: 50%; position: absolute; top: 33%; left: 66%; transform: translate(-50%, -50%); animation: colorBreath 3s ease-in-out infinite; }

/* Hierarchy: "Flattening the Scale" */
.structure-hierarchy .demo-canvas { background: #061735; }
.structure-hierarchy .demo-canvas::before { /* Large circle shrinks */
    content: '';
    width: 120px; height: 120px;
    background: var(--accent-color);
    border-radius: 50%;
    position: absolute;
    animation: none;
    transition: all 0.1s ease-out;
}
.structure-hierarchy .demo-canvas::after { /* Small circle grows */
    content: '';
    width: 60px; height: 60px;
    background: #4a5b7c;
    border-radius: 50%;
    position: absolute;
    animation: none;
    box-shadow: none;
    transition: all 0.1s ease-out;
}
.js-active .structure-hierarchy .demo-canvas::before {
    width: calc(120px - var(--int-y, 0.5) * 60px);
    height: calc(120px - var(--int-y, 0.5) * 60px);
}
.js-active .structure-hierarchy .demo-canvas::after {
    width: calc(60px + var(--int-y, 0.5) * 60px);
    height: calc(60px + var(--int-y, 0.5) * 60px);
}

@keyframes economyFade { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.structure-economy .demo-canvas { background: #061735; }
.structure-economy .demo-canvas::before { content: ''; width: 60px; height: 60px; border: 2px solid #fff; position: absolute; }
.structure-economy .demo-canvas::after { content: ''; width: 200px; height: 200px; background-image: radial-gradient(#4a5b7c 2px, transparent 2px); background-size: 20px 20px; position: absolute; animation: economyFade 6s ease-in-out infinite; }

@keyframes varietyDance { 0% { border-radius: 0; background: #4a5b7c; transform: rotate(0); } 33% { border-radius: 50%; background: var(--accent-color); } 66% { border-radius: 0; background: #fff; transform: rotate(180deg); } 100% { border-radius: 0; background: #4a5b7c; transform: rotate(360deg); } }
.structure-variety .demo-canvas { background: #061735; }
.structure-variety .demo-canvas::before { content: ''; width: 80px; height: 80px; animation: varietyDance 8s linear infinite; }

/* --- Spatial Depth (Curator's Cut) --- */
@keyframes roadMove { 0% { background-position: 0 0; } 100% { background-position: 0 100px; } }
.spatial-depth-linear-perspective .demo-canvas { background: #061735; perspective: 200px; overflow: hidden; }
.spatial-depth-linear-perspective .demo-canvas::before { content: ''; position: absolute; width: 300%; left: -100%; height: 100%; background: linear-gradient(90deg, transparent 49%, var(--accent-color) 49%, var(--accent-color) 51%, transparent 51%), linear-gradient(0deg, transparent 49%, rgba(255,255,255,0.2) 49%, rgba(255,255,255,0.2) 51%, transparent 51%); background-size: 100px 100px; transform: rotateX(60deg); transform-origin: 50% 100%; animation: roadMove 2s linear infinite; }

/* Atmospheric Perspective: "The Range" */
.spatial-depth-atmospheric-perspective .demo-canvas { background: #d0dbe8; position: relative; overflow: hidden; }
.spatial-depth-atmospheric-perspective .demo-canvas::before { /* Back layer */
    content: '';
    width: 150%; height: 100px;
    background: #8da1bf;
    border-radius: 50% 50% 0 0;
    position: absolute;
    bottom: 40px; left: -20px;
    animation: none;
    transition: filter 0.1s ease-out;
}
.spatial-depth-atmospheric-perspective .demo-canvas::after { /* Front layer */
    content: '';
    width: 150%; height: 80px;
    background: #061735;
    border-radius: 50% 50% 0 0;
    position: absolute;
    bottom: -20px; right: -20px;
    animation: none;
}
.js-active .spatial-depth-atmospheric-perspective .demo-canvas::before {
    filter:
        saturate(calc(1 - var(--int-y, 0.5)))
        brightness(calc(1 + var(--int-y, 0.5) * 0.5));
}

@keyframes foreshortenTurn { 0% { transform: rotateX(0deg) scaleY(1); } 50% { transform: rotateX(75deg) scaleY(0.5); } 100% { transform: rotateX(0deg) scaleY(1); } }
.spatial-depth-foreshortening .demo-canvas { background: #061735; perspective: 400px; }
.spatial-depth-foreshortening .demo-canvas::before { content: ''; width: 80px; height: 150px; background: var(--accent-color); transform-origin: bottom center; animation: foreshortenTurn 5s ease-in-out infinite; }

/* Overlapping: "The Eclipse" */
.spatial-depth-overlapping .demo-canvas { background: #061735; }
.spatial-depth-overlapping .demo-canvas::before {
    content: '';
    width: 100px; height: 100px;
    border-radius: 50%;
    position: absolute;
    background: var(--accent-color);
    mix-blend-mode: screen;
    animation: none;
    transition: transform 0.1s ease-out;
}
.spatial-depth-overlapping .demo-canvas::after {
    content: '';
    width: 100px; height: 100px;
    border-radius: 50%;
    position: absolute;
    background: #4a5b7c;
    animation: none;
}
.js-active .spatial-depth-overlapping .demo-canvas::before {
    transform: translateX(calc((var(--int-x, 0.5) - 0.5) * 100px));
}

/* --- Color Dynamics --- */
@keyframes tempShift { 0%, 100% { left: 20%; background: #ff4500; } 50% { left: 80%; background: #1e90ff; } }
.color-dynamics-temperature .demo-canvas { background: linear-gradient(90deg, #330000 0%, #000033 100%); position: relative; }
.color-dynamics-temperature .demo-canvas::before { content: ''; width: 50px; height: 50px; border-radius: 50%; position: absolute; top: calc(50% - 25px); animation: tempShift 8s ease-in-out infinite; box-shadow: 0 0 20px rgba(255,255,255,0.2); }

@keyframes saturationPulse { 0%, 100% { filter: grayscale(100%); transform: scale(0.9); } 50% { filter: grayscale(0%); transform: scale(1.1); } }
.color-dynamics-saturation .demo-canvas { background: #111; }
.color-dynamics-saturation .demo-canvas::before { content: ''; width: 100px; height: 100px; background: linear-gradient(45deg, #ff00cc, #3333ff); border-radius: 50%; animation: saturationPulse 4s ease-in-out infinite; }

.color-dynamics-simultaneous-contrast .demo-canvas { display: grid; grid-template-columns: 1fr 1fr; width: 100%; height: 100%; padding: 0; }
.color-dynamics-simultaneous-contrast .demo-canvas::before { content: ''; background: #061735; display: flex; align-items: center; justify-content: center; border-right: 1px solid #fff; }
.color-dynamics-simultaneous-contrast .demo-canvas::after { content: ''; background: #B3892C; display: flex; align-items: center; justify-content: center; }
/* Using a child element for the grey square trick would be ideal, but with pseudo-elements only, we use box-shadow/inset tricks or gradients. 
   Here, we'll use a background image gradient on the main container to create the 'squares' inside the pseudo-elements. */
.color-dynamics-simultaneous-contrast .demo-canvas { 
    background: transparent; 
}
/* Re-implementing correctly for pseudo-element limitation: */
.color-dynamics-simultaneous-contrast .demo-canvas {
    background: linear-gradient(90deg, #061735 50%, #B3892C 50%);
    position: relative;
}
.color-dynamics-simultaneous-contrast .demo-canvas::before {
    content: '';
    position: absolute;
    width: 40px; height: 40px;
    background: #7f7f7f;
    top: calc(50% - 20px);
    left: 25%;
}
.color-dynamics-simultaneous-contrast .demo-canvas::after {
    content: '';
    position: absolute;
    width: 40px; height: 40px;
    background: #7f7f7f;
    top: calc(50% - 20px);
    left: 70%; /* Adjusted from 75% for visual balance */
}

.composition-section {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding-top: 1.5rem; /* Reduced from 2rem */
    border-top: 1px solid var(--border-color);
}

.composition-section h3 {
    font-size: 1.25rem;
    margin-bottom: 0.1rem;
}

.composition-section p {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

a.button {
    padding: 0.6rem 1.5rem; /* Slightly smaller button */
    font-size: 0.95rem;
}

/* Detail Pages */
.detail-container {
    display: grid;
    grid-template-columns: 35% 65%;
    gap: 4rem;
    align-items: center;
    height: 100%;
    width: 100%;
}

.text-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.detail-container h2 {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.definition {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--muted-text);
    border-left: 4px solid var(--accent-color);
    padding-left: 1.5rem;
    margin-bottom: 3rem;
}

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

.page-nav a {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--muted-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-nav a:hover {
    color: var(--accent-color);
}

.visual-demo {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    height: 100%;
    max-height: 70vh;
    display: flex;
}

.demo-canvas {
    width: 100%;
    flex-grow: 1;
    background: #061735;
    border: 1px solid #eee;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
}

/* --- Curatorial Edition: Keyframes --- */
@keyframes vibrate { 0% { transform: translate(0, 0); } 20% { transform: translate(-1px, 0); } 40% { transform: translate(1px, 0); } 60% { transform: translate(-1px, 0); } 80% { transform: translate(1px, 0); } 100% { transform: translate(0, 0); } }
@keyframes drift { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(10px, -10px); } 50% { transform: translate(5px, 5px); } 75% { transform: translate(-10px, 10px); } }
@keyframes lightShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes colorBreath { 0%, 100% { transform: scale(1); filter: blur(2px); } 50% { transform: scale(1.1); filter: blur(5px); } }
@keyframes moireRotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes spaceBreathe { 0%, 100% { transform: scale(0.9); } 50% { transform: scale(1.1); } }
@keyframes spotlight { 0% { mask-position: -50% -50%; -webkit-mask-position: -50% -50%; } 25% { mask-position: 150% -50%; -webkit-mask-position: 150% -50%; } 50% { mask-position: 150% 150%; -webkit-mask-position: 150% 150%; } 75% { mask-position: -50% 150%; -webkit-mask-position: -50% 150%; } 100% { mask-position: -50% -50%; -webkit-mask-position: -50% -50%; } }
@keyframes orbit { from { transform: rotate(0deg) translateX(100px) rotate(0deg); } to { transform: rotate(360deg) translateX(100px) rotate(-360deg); } }
@keyframes blurFocus { 0% { filter: blur(0px); transform: translateX(-100px); } 20% { filter: blur(5px); transform: translateX(-50px); } 40% { filter: blur(10px); transform: translateX(0px); } 60% { filter: blur(5px); transform: translateX(50px); } 80% { filter: blur(0px); transform: translateX(100px); } 100% { filter: blur(0px); transform: translateX(-100px); } }
@keyframes glitch { 0% { transform: translate(0); } 90% { transform: translate(0); } 91% { transform: translate(-2px, 2px); } 92% { transform: translate(2px, -2px); } 93% { transform: translate(0); } }
@keyframes ghostTrail { 0% { transform: translateX(-150px); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateX(150px); opacity: 0; } }
@keyframes polyrhythm { 0%, 100% { height: 20px; opacity: 0.5; } 50% { height: 100px; opacity: 1; } }
@keyframes gestalt { 0%, 100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0.5; } 50% { transform: translate(0, 0) rotate(0); opacity: 1; border-color: var(--accent-color); } }
@keyframes thesisGrid { 0% { width: 0; height: 0; opacity: 0; transform: translate(-50%, -50%) rotate(0deg); } 10% { width: 200px; height: 200px; opacity: 1; transform: translate(-50%, -50%) rotate(0deg); } 30% { transform: translate(-50%, -50%) rotate(0deg); border-color: rgba(255,255,255,0.2); } 40% { transform: translate(-50%, -50%) rotate(0deg) scale(0.9); } 60% { transform: translate(-40%, -40%) rotate(15deg); border-color: rgba(255,255,255,0.6); } 80% { transform: translate(-40%, -40%) rotate(15deg); opacity: 1; } 90% { opacity: 0; transform: translate(-40%, -40%) rotate(15deg) scale(1.1); } 100% { opacity: 0; } }
@keyframes antithesisShape { 0%, 25% { transform: translate(150px, 100px) scale(0); opacity: 0; } 35% { transform: translate(50px, 20px) scale(1); opacity: 1; } 60% { transform: translate(-20px, 20px) scale(1); } 80% { transform: translate(-20px, 20px) scale(1); opacity: 1; } 90% { transform: translate(-20px, 20px) scale(0); opacity: 0; } 100% { opacity: 0; } }

/* --- The Elements (Curator's Cut) --- */
/* Line: "The Bowstring" - Tension & Distortion */
.element-line .demo-canvas { background: #061735; }
.element-line .demo-canvas::before {
    content: '';
    width: 80%; height: 4px;
    background: var(--accent-color);
    border-radius: 2px;
    animation: none;
    transition: transform 0.05s ease-out;
}
.js-active .element-line .demo-canvas::before {
    transform-origin: calc(var(--int-x, 0.5) * 100%) 50%;
    transform:
        translateY(calc((var(--int-y, 0.5) - 0.5) * 200px))
        scaleY(calc(1 + (abs(var(--int-y, 0.5) - 0.5)) * 10));
}

/* Shape: "The Metamorphosis" - Geometric vs. Organic */
.element-shape .demo-canvas { background: #061735; }
.element-shape .demo-canvas::before {
    content: '';
    width: 150px; height: 150px;
    background: var(--accent-color);
    animation: none;
    transition: border-radius 0.1s ease-out;
}
.js-active .element-shape .demo-canvas::before {
    border-radius: calc(var(--int-x, 0.5) * 75px); /* 0 to 50% */
}
.element-shape .demo-canvas::after { display: none; }

/* Form: Chiaroscuro & Light Source */
.element-form .demo-canvas::before {
    content: '';
    width: 200px; height: 200px;
    border-radius: 50%;
    animation: none;
}
.js-active .element-form .demo-canvas::before {
    background: radial-gradient(circle at calc(var(--int-x, 0.5) * 100%) calc(var(--int-y, 0.5) * 100%), #fff, #061735 70%);
}

/* Color: Interaction of Color (Albers Style) */
.element-color .demo-canvas {
    background: #555;
    transition: background-color 0.1s ease-out;
}
.js-active .element-color .demo-canvas {
    background-color: hsl(calc(var(--int-y, 0.5) * 360), 40%, 30%);
}
.element-color .demo-canvas::before {
    content: '';
    width: 120px; height: 120px;
    background: var(--accent-color);
    animation: none;
    mix-blend-mode: normal; /* Override */
}
.element-color .demo-canvas::after { display: none; }


/* Texture: Noise Density */
.element-texture .demo-canvas {
    background: #111;
    overflow: hidden;
}
.element-texture .demo-canvas::before {
    content: '';
    animation: none;
    width: 300%; height: 300%;
    background-image:
        radial-gradient(#fff 1px, transparent 1px),
        radial-gradient(#fff 1px, transparent 1px);
    background-size: 10px 10px;
    background-position: 0 0, 5px 5px;
    transition: opacity 0.1s;
}
.js-active .element-texture .demo-canvas::before {
    opacity: calc(var(--int-y, 0.5) * 0.5);
    transform: translate(calc((var(--int-x, 0.5) - 0.5) * -100px), calc((var(--int-y, 0.5) - 0.5) * -100px));
}
.element-texture .demo-canvas::after { display: none; }

/* Space: "The Vise" - Pressure & Void */
.element-space .demo-canvas {
    background: var(--accent-color); /* The void is the subject */
    flex-direction: row;
    padding: 0;
}
.element-space .demo-canvas::before, .element-space .demo-canvas::after {
    content: '';
    background: #061735; /* Positive forms */
    height: 100%;
    width: 25%;
    border: none;
    animation: none;
    transition: width 0.1s ease-out;
}
.js-active .element-space .demo-canvas::before {
    width: calc(var(--int-x, 0.5) * 49.5%);
}
.js-active .element-space .demo-canvas::after {
    width: calc((1 - var(--int-x, 0.5)) * 49.5%);
}

/* Value: Clarity from Darkness */
.element-value .demo-canvas {
    background: #111;
    -webkit-mask-image: none;
    mask-image: none;
    animation: none;
    transition: filter 0.1s ease-out;
}
.element-value .demo-canvas::before {
    content: '';
    width: 100%; height: 100%;
    background: transparent;
    opacity: 1;
    /* Ghostly shapes */
    box-shadow:
        50px 50px 80px 20px #777,
        -70px -30px 60px 10px #555,
        80px -90px 40px 0px #999,
        -20px 80px 50px 0 #444;
}
.js-active .element-value .demo-canvas {
    filter: contrast(calc(1 + var(--int-y, 0.5) * 15));
}

/* --- The Principles (Curator's Cut) --- */
/* Balance: "The Lever" - Asymmetric Equilibrium */
.principle-balance .demo-canvas { background: #fff; }
.principle-balance .demo-canvas::before { /* The large, faint mass */
    content: '';
    width: 200px; height: 200px;
    background: #ccc;
    border-radius: 50%;
    position: absolute;
    left: 10%;
    animation: none;
    transition: opacity 0.2s ease-out;
}
.principle-balance .demo-canvas::after { /* The small, dense subject */
    content: '';
    width: 50px; height: 50px;
    background: #000;
    position: absolute;
    right: 10%;
    animation: none;
    transition: transform 0.1s ease-out;
}
.js-active .principle-balance .demo-canvas::before {
    /* Becomes more solid as the small square moves away */
    opacity: calc(0.2 + (1 - var(--int-x, 0.5)) * 0.6);
}
.js-active .principle-balance .demo-canvas::after {
    transform: translateX(calc((var(--int-x, 0.5) - 0.5) * -150px));
}

/* Contrast: "The Edge" */
.principle-contrast .demo-canvas {
    background: linear-gradient(90deg, #fff 50%, #000 50%);
    transition: background-position 0.1s ease-out;
}
.principle-contrast .demo-canvas::before {
    display: none; /* Not needed */
}
.js-active .principle-contrast .demo-canvas {
    background-size: 200% 100%;
    background-position: calc(var(--int-x, 0.5) * 100%) 0;
}


.principle-emphasis .demo-canvas { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: 200px; background-image: radial-gradient(#4a5b7c 2px, transparent 2px); background-size: 20px 20px; animation: glitch 0.23s infinite; }
.principle-emphasis .demo-canvas::before { content: ''; width: 20px; height: 20px; background: var(--accent-color); position: absolute; top: 61%; left: 61%; box-shadow: 0 0 20px var(--accent-color); }

.principle-movement .demo-canvas { background: #fff; }
.principle-movement .demo-canvas::before { content: ''; width: 50px; height: 50px; border: 2px solid #000; border-radius: 50%; box-shadow: -30px 0 0 -5px rgba(0,0,0,0.5), -60px 0 0 -10px rgba(0,0,0,0.3), -90px 0 0 -15px rgba(0,0,0,0.1); animation: ghostTrail 4.1s linear infinite; }

.principle-pattern .demo-canvas { background-color: #061735; background-image: url('../img/glider.png'); background-size: 40px 40px; image-rendering: pixelated; animation: scrollBg 37s steps(8) infinite; }
@keyframes scrollBg { from { background-position: 0 0; } to { background-position: 40px 40px; } }

/* Rhythm: "The Colonnade" - Interval & Pacing */
.principle-rhythm .demo-canvas {
    background: #061735;
    flex-direction: row;
    gap: 10px;
}
.principle-rhythm .demo-canvas::before, .principle-rhythm .demo-canvas::after {
    content: '';
    width: 20px;
    height: 80%;
    background: var(--accent-color);
    animation: none;
    transition: margin-left 0.1s ease-out;
}
.js-active .principle-rhythm .demo-canvas::before {
    /* Regular spacing */
    margin-left: 10px;
}
.js-active .principle-rhythm .demo-canvas::after {
    /* Syncopated spacing based on X */
    margin-left: calc(10px + var(--int-x, 0.5) * 100px);
}

/* Unity: "Wave of Order" - From Chaos to Order */
.principle-unity .demo-canvas {
    background: #fff;
    /* This is too complex for pure CSS vars. We need a different approach.
       Let's do a simpler "Gravity Well" concept. */
    --chaos-x: 40px;
    --chaos-y: 40px;
    --chaos-r: 15deg;
}
.principle-unity .demo-canvas::before, .principle-unity .demo-canvas::after {
    content: '';
    width: 50px; height: 50px;
    border: 2px solid #000;
    position: absolute;
    animation: none;
    transition: transform 0.1s ease-out;
}
.principle-unity .demo-canvas::before {
    transform: translate(var(--chaos-x), var(--chaos-y)) rotate(var(--chaos-r));
}
.principle-unity .demo-canvas::after {
    transform: translate(calc(var(--chaos-x) * -1), calc(var(--chaos-y) * -1)) rotate(calc(var(--chaos-r) * -1));
}
.js-active .principle-unity .demo-canvas {
    /* Y axis pulls the chaotic elements into a unified center */
    --chaos-x: calc(40px * (1 - var(--int-y, 0.5)));
    --chaos-y: calc(40px * (1 - var(--int-y, 0.5)));
    --chaos-r: calc(15deg * (1 - var(--int-y, 0.5)));
}

/* --- The Synthesis: Composition (The 10/10 Rework) --- */
/* The Synthesis Engine: A Tunable System of Order & Entropy */

.composition-composition .demo-canvas {
    background: #000;
    position: relative;
    perspective: 1000px;
    overflow: hidden;
    --sweet-x: 0.618;
    --entropy: var(--int-x, 0.5);
    --energy: var(--int-y, 0.5);
    /* Deviation from the Golden Mean */
    --dev: calc(var(--entropy) - var(--sweet-x));
    --abs-dev: max(var(--dev), calc(var(--dev) * -1));
}

/* Layer 1: The Atmosphere (Energy Axis - Y) */
/* Replaces .layer-space */
.layer-space {
    position: absolute;
    width: 100%; height: 100%;
    top: 0; left: 0;
    z-index: 0;
    background: radial-gradient(
        circle at 50% calc(100% - var(--energy) * 80%), 
        hsl(210, 50%, calc(10% + var(--energy) * 40%)) 0%, 
        #000 70%
    );
    transition: background 0.1s;
}

.horizon {
    display: none; /* Removing the literal horizon */
}

/* Layer 2: The Grid (Order vs Entropy - X) */
/* Replaces .layer-structure */
.layer-structure {
    position: absolute;
    top: 50%; left: 50%;
    width: 100%; height: 100%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
    /* Grid fades out as Entropy (X) increases */
    opacity: calc(1 - var(--entropy) * 0.8);
    transition: opacity 0.1s;
}
.layer-structure::before { /* Golden Section Vertical */
    content: ''; position: absolute; top: 0; bottom: 0; left: 61.8%;
    border-left: 1px solid rgba(255,255,255,0.2);
}
.layer-structure::after { /* Golden Section Horizontal */
    content: ''; position: absolute; top: 61.8%; right: 0; left: 0;
    border-top: 1px solid rgba(255,255,255,0.2);
}

/* Layer 3: The Fragments (The Search for Synthesis) */
/* Replaces .layer-subject */
.layer-subject {
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0; /* Centered anchor */
    z-index: 20;
}

/* Fragment A: The Thesis (Geometry/Logic) */
.layer-subject::before {
    content: '';
    position: absolute;
    width: 150px; height: 150px;
    border: 2px solid #fff;
    top: -75px; left: -75px;
    /* Moves LEFT based on deviation. Aligns at 0. */
    transform: 
        translate(calc(var(--dev) * -300px), calc(var(--dev) * -100px)) 
        rotate(calc(var(--dev) * -45deg));
    box-shadow: 0 0 20px rgba(255,255,255,0.1);
    transition: transform 0.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Fragment B: The Antithesis (Chaos/Emotion) */
.layer-subject::after {
    content: '';
    position: absolute;
    width: 150px; height: 150px;
    background: var(--accent-color);
    border-radius: 50%;
    top: -75px; left: -75px;
    mix-blend-mode: exclusion;
    opacity: 0.8;
    /* Moves RIGHT based on deviation. Aligns at 0. */
    transform: 
        translate(calc(var(--dev) * 300px), calc(var(--dev) * 100px)) 
        rotate(calc(var(--dev) * 90deg))
        scale(calc(1 - var(--abs-dev) * 0.5)); /* Shrinks when far apart */
    transition: transform 0.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Visual "Lock-In" Bloom */
/* We create a pseudo-element on the parent canvas that glows when near the sweet spot */
.composition-composition .demo-canvas::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 200px; height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff, transparent 70%);
    opacity: calc(1 - var(--abs-dev) * 10); /* Only visible when dev is near 0 */
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 30;
}

/* Interaction Overrides */
.js-active .composition-composition .demo-canvas {
    perspective: 1000px; /* Reset perspective interaction */
}
.js-active .layer-subject {
    transform: none; /* Reset simple translation */
}

/* --- Interaction Overrides (Enabled by interaction.js) --- */
.js-active .spatial-depth-linear-perspective .demo-canvas {
    perspective-origin: calc(var(--int-x, 0.5) * 100%) calc(var(--int-y, 0.5) * 100%);
    transition: perspective-origin 0.1s ease-out;
}

.js-active .perception-proximity .demo-canvas::before {
    animation: none;
    transform: translate(calc((var(--int-x, 0.5) - 0.5) * -100px), 0);
    transition: transform 0.1s ease-out;
}
.js-active .perception-proximity .demo-canvas::after {
    animation: none;
    transform: translate(calc((var(--int-x, 0.5) - 0.5) * 100px), 0);
    transition: transform 0.1s ease-out;
}

.js-active .color-dynamics-temperature .demo-canvas::before {
    animation: none;
    left: calc(var(--int-x, 0.5) * 80% + 10%);
    transition: left 0.1s ease-out;
}

/* --- Batch 1: Elements & Principles Interactions --- */
/* Line: Tension/Vibration (Y axis) */
.js-active .element-line .demo-canvas::before {
    /* Speed up animation based on Y. 0.05s (fast) to 0.5s (slow) */
    animation-duration: calc(0.05s + var(--int-y, 0.5) * 0.45s);
}

/* Shape: Drift (X/Y axis) */
.js-active .element-shape .demo-canvas::before {
    animation: none;
    top: calc(var(--int-y, 0.5) * 80% + 10%);
    left: calc(var(--int-x, 0.5) * 80% + 10%);
    transition: top 0.1s, left 0.1s;
}
.js-active .element-shape .demo-canvas::after {
    animation: none;
    /* Mirror movement */
    top: calc((1 - var(--int-y, 0.5)) * 80% + 10%);
    left: calc((1 - var(--int-x, 0.5)) * 80% + 10%);
    transition: top 0.1s, left 0.1s;
}

/* Form: Light Source (X/Y axis) */
.js-active .element-form .demo-canvas::before {
    animation: none;
    /* Move the radial gradient center */
    background: radial-gradient(circle at calc(var(--int-x, 0.5) * 100%) calc(var(--int-y, 0.5) * 100%), #fff, #061735);
    background-size: 200% 200%;
}

/* Color: Hue (X axis) */
.js-active .element-color .demo-canvas::before {
    animation: none;
    filter: hue-rotate(calc(var(--int-x, 0.5) * 360deg));
}
.js-active .element-color .demo-canvas::after {
    animation: none;
    filter: hue-rotate(calc(var(--int-x, 0.5) * -360deg));
}

/* Texture: Interference (X axis) */
.js-active .element-texture .demo-canvas::before {
    animation: none;
    /* Rotate top layer based on X */
    transform: rotate(calc(var(--int-x, 0.5) * 90deg));
}

/* Space: Volume (Y axis) */
.js-active .element-space .demo-canvas::after {
    animation: none;
    /* Scale the inner box */
    transform: scale(calc(0.5 + var(--int-y, 0.5)));
}

/* Value: Spotlight (X/Y axis) */
.js-active .element-value .demo-canvas {
    animation: none;
    -webkit-mask-position: calc(var(--int-x, 0.5) * 100%) calc(var(--int-y, 0.5) * 100%);
    mask-position: calc(var(--int-x, 0.5) * 100%) calc(var(--int-y, 0.5) * 100%);
}

/* Balance: Fulcrum (X axis) */
.js-active .principle-balance .demo-canvas::after {
    animation: none;
    /* Orbit around different points */
    transform-origin: calc(var(--int-x, 0.5) * 100px) 50%;
    transform: rotate(calc(var(--time, 0) * 1deg)); /* Needs time, fallback to simple rotation override if time missing */
    animation: orbit 5s linear infinite; /* Just speed change or keep constant? Let's offset position */
    left: calc(var(--int-x, 0.5) * 60% + 20%);
}

/* Contrast: Focus (Y axis) */
.js-active .principle-contrast .demo-canvas::before {
    animation: none;
    filter: blur(calc(var(--int-y, 0.5) * 20px));
}

/* Emphasis: Anomaly Position (X/Y axis) */
.js-active .principle-emphasis .demo-canvas::before {
    top: calc(var(--int-y, 0.5) * 80% + 10%);
    left: calc(var(--int-x, 0.5) * 80% + 10%);
    transition: top 0.1s, left 0.1s;
}

/* Movement: Velocity (X axis) */
.js-active .principle-movement .demo-canvas::before {
    /* Speed control */
    animation-duration: calc(0.5s + var(--int-x, 0.5) * 5s);
}

/* Pattern: Distortion (X/Y axis) */
.js-active .principle-pattern .demo-canvas {
    animation: none;
    background-position: calc(var(--int-x, 0) * 100px) calc(var(--int-y, 0) * 100px);
}

/* Rhythm: Tempo (X axis) */
.js-active .principle-rhythm .demo-canvas::before {
    animation-duration: calc(0.2s + var(--int-x, 0.5) * 2s);
}
.js-active .principle-rhythm .demo-canvas::after {
    animation-duration: calc(0.3s + var(--int-x, 0.5) * 3s);
}

/* Unity: Chaos vs Order (Y axis) */
.js-active .principle-unity .demo-canvas::before {
    animation: none;
    /* Interpolate between chaotic (rotated/offset) and unified (0,0) */
    transform: translate(calc(var(--int-y, 0.5) * -40px), calc(var(--int-y, 0.5) * -40px)) rotate(calc(var(--int-y, 0.5) * 15deg));
    border-color: rgba(0,0,0, calc(1 - var(--int-y, 0.5) * 0.5));
}
.js-active .principle-unity .demo-canvas::after {
    animation: none;
    transform: translate(calc(var(--int-y, 0.5) * 40px), calc(var(--int-y, 0.5) * 40px)) rotate(calc(var(--int-y, 0.5) * -15deg));
}

/* --- Batch 2: Perception & Structure Interactions --- */
/* Closure: Gap Size (X axis) */
.js-active .perception-closure .demo-canvas::before {
    animation: none;
    transform: rotate(calc(var(--int-x, 0.5) * 360deg));
    /* Change border style to simulate closing gaps? Hard with border-dashed. 
       Instead, we rotate it to align/misalign or change color opacity. */
    border-color: rgba(179, 137, 44, calc(0.2 + var(--int-x, 0.5)));
}

/* Similarity: Highlight (X axis) */
.js-active .perception-similarity .demo-canvas::after {
    animation: none;
    /* Scale based on X to show "pop out" */
    transform: scale(calc(1 + var(--int-x, 0.5) * 0.5));
    opacity: calc(0.5 + var(--int-x, 0.5));
}

/* Figure-Ground: Shift (X axis) */
.js-active .perception-figure-ground .demo-canvas {
    animation: none;
    background-position: calc(var(--int-x, 0.5) * 100%) 50%;
}

/* Continuity: Flow (Y axis) */
.js-active .perception-continuity .demo-canvas::before {
    animation: none;
    /* Change angle of flow */
    transform: rotate(calc((var(--int-y, 0.5) - 0.5) * 45deg));
    background-position: calc(var(--int-x, 0) * 100px) 0;
}

/* Golden Ratio: Zoom (X axis) */
.js-active .structure-golden-ratio .demo-canvas::before {
    animation: none;
    /* Manual zoom/unwind */
    transform: rotate(calc(var(--int-x, 0.5) * 720deg)) scale(calc(0.2 + var(--int-x, 0.5)));
}

/* Rule of Thirds: Focal Point (X/Y axis) */
.js-active .structure-rule-of-thirds .demo-canvas::after {
    animation: none;
    /* Snap to nearest third? Smooth move is better interaction */
    top: calc(var(--int-y, 0.5) * 100%);
    left: calc(var(--int-x, 0.5) * 100%);
}

/* Hierarchy: Flattening (Y axis) */
.js-active .structure-hierarchy .demo-canvas::before {
    /* Large circle shrinks */
    width: calc(120px - var(--int-y, 0.5) * 60px);
    height: calc(120px - var(--int-y, 0.5) * 60px);
}
.js-active .structure-hierarchy .demo-canvas::after {
    /* Small circle grows */
    width: calc(60px + var(--int-y, 0.5) * 60px);
    height: calc(60px + var(--int-y, 0.5) * 60px);
}

/* Economy: Clutter Removal (X axis) */
.js-active .structure-economy .demo-canvas::after {
    animation: none;
    opacity: calc(1 - var(--int-x, 0.5)); /* X=1 clears the clutter */
}

/* Variety: Mutation Speed (X axis) */
.js-active .structure-variety .demo-canvas::before {
    animation-duration: calc(0.5s + (1 - var(--int-x, 0.5)) * 10s);
}

/* --- Batch 3: Spatial & Color Interactions --- */
/* Atmospheric Perspective: Fog Density (Y axis) */
.js-active .spatial-depth-atmospheric-perspective .demo-canvas::before {
    animation: none;
    /* Move layers closer/further or change opacity */
    opacity: calc(1 - var(--int-y, 0.5));
    transform: translateX(calc((var(--int-x, 0.5) - 0.5) * 20px));
}
.js-active .spatial-depth-atmospheric-perspective .demo-canvas::after {
    animation: none;
    opacity: calc(1 - var(--int-y, 0.5));
    transform: translateX(calc((var(--int-x, 0.5) - 0.5) * -20px));
}

/* Foreshortening: 3D Rotation (X/Y axis) */
.js-active .spatial-depth-foreshortening .demo-canvas::before {
    animation: none;
    transform: rotateX(calc((var(--int-y, 0.5) - 0.5) * 180deg)) rotateY(calc((var(--int-x, 0.5) - 0.5) * 180deg));
}

/* Overlapping: Explosion (X axis) */
.js-active .spatial-depth-overlapping .demo-canvas::before {
    animation: none;
    /* Move background circle left/back */
    transform: translateX(calc((var(--int-x, 0.5) - 0.5) * -100px)) scale(calc(1 - var(--int-x, 0.5) * 0.5));
    z-index: 1;
}
.js-active .spatial-depth-overlapping .demo-canvas::after {
    /* Move foreground circle right/forward */
    transform: translateX(calc((var(--int-x, 0.5) - 0.5) * 100px)) scale(calc(1 + var(--int-x, 0.5) * 0.2));
    z-index: 2;
}

/* Saturation: Intensity (Y axis) */
.js-active .color-dynamics-saturation .demo-canvas::before {
    animation: none;
    filter: grayscale(calc(1 - var(--int-y, 0.5)));
    transform: scale(calc(0.8 + var(--int-y, 0.5) * 0.4));
}

/* Simultaneous Contrast: Split Position (X axis) */
.js-active .color-dynamics-simultaneous-contrast .demo-canvas {
    /* Move the gradient stop */
    background: linear-gradient(90deg, #061735 calc(var(--int-x, 0.5) * 100%), #B3892C calc(var(--int-x, 0.5) * 100%));
}
.js-active .color-dynamics-simultaneous-contrast .demo-canvas::before {
    left: calc(var(--int-x, 0.5) * 50% - 20px);
}
.js-active .color-dynamics-simultaneous-contrast .demo-canvas::after {
    left: calc(50% + var(--int-x, 0.5) * 50% - 20px);
}

/* Responsive Adjustments */
@media (max-width: 800px) {
    body { height: auto; overflow-x: auto; }
    .detail-container { grid-template-columns: 1fr; gap: 2rem; }
    
    /* Mobile Typography Scale */
    .detail-container h2 { font-size: 2.5rem; }
    .definition { font-size: 1.1rem; }

    header { flex-direction: column; padding: 1rem; }
    nav ul { gap: 1rem; flex-wrap: wrap; justify-content: center; }
    .grid-container { grid-template-columns: 1fr; }
    .card ul { columns: 1; }
}