/* ======================================
   desca.dev — Cartesian Meditation
   ====================================== */

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

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

body {
    background-color: #0b0d2e;
    color: #c8cde0;
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 300;
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Color Variables --- */
:root {
    --void: #0b0d2e;
    --bg-secondary: #1a1f3d;
    --bg-tertiary: #12153a;
    --coral: #ff6b5a;
    --ember: #d4a04a;
    --text-primary: #c8cde0;
    --text-warm: #e8e0d4;
    --grid-line: #1e2a5e;
    --shadow-violet: #2a1845;
    --muted: #6b7394;
}

/* --- Navigation --- */
#main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: rgba(11, 13, 46, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

#main-nav.nav-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

#main-nav.nav-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.nav-logo {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-size: 18px;
    color: var(--text-primary);
    letter-spacing: 0.08em;
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-numeral {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.3s ease;
}

.nav-numeral:hover {
    color: var(--coral);
    text-shadow: 0 0 12px rgba(255, 107, 90, 0.3);
}

/* --- Opening Viewport --- */
.section-opening {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--void);
    overflow: hidden;
}

.coordinate-plane {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1200px;
}

.grid-svg {
    position: absolute;
    width: 120%;
    height: 120%;
    transform: rotateX(2deg);
}

.axis-line {
    stroke: var(--grid-line);
    stroke-width: 1.5;
    stroke-linecap: round;
}

.grid-line {
    stroke: var(--grid-line);
    stroke-width: 0.5;
    opacity: 0;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.grid-line.animate-in {
    animation: drawLine 800ms ease-out forwards;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
        opacity: 0.4;
    }
}

.axis-labels text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: var(--muted);
    letter-spacing: 0.06em;
}

/* --- Logotype --- */
.logotype {
    position: absolute;
    z-index: 10;
    text-align: center;
    opacity: 0;
    transition: opacity 1000ms ease-out;
}

.logotype.visible {
    opacity: 1;
}

.logo-text {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-size: 72px;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(255, 107, 90, 0.3);
}

.logo-dev {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-size: 72px;
    letter-spacing: 0.08em;
    color: var(--coral);
    text-shadow: 0 0 20px rgba(255, 107, 90, 0.3);
    opacity: 0;
    display: inline-block;
    transition: opacity 0.4s ease;
}

.closing-dev.visible .closing-dev-char {
    opacity: 1;
}

/* --- Phosphor Glow Pulse --- */
@keyframes glowPulse {
    0%, 100% { text-shadow: 0 0 20px rgba(255, 107, 90, 0.3); }
    50% { text-shadow: 0 0 30px rgba(255, 107, 90, 0.5); }
}

.logotype.visible .logo-text {
    animation: glowPulse 4s ease-in-out infinite;
}

/* --- Meditation I --- */
.section-meditation-1 {
    position: relative;
    min-height: 100vh;
    background: var(--void);
    padding: 120px 40px 120px;
    overflow: hidden;
}

.meditation-1-content {
    display: flex;
    gap: 60px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 80vh;
    align-items: flex-start;
}

.meditation-1-text {
    flex: 0 0 40%;
    max-width: 520px;
    padding-top: 60px;
}

.meditation-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--coral);
    display: block;
    margin-bottom: 24px;
    text-shadow: 0 0 12px rgba(255, 107, 90, 0.2);
}

.meditation-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-size: 32px;
    color: var(--text-warm);
    line-height: 1.3;
    margin-bottom: 40px;
    font-style: italic;
}

.meditation-1-text p {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 300;
    font-size: 17px;
    line-height: 1.75;
    color: var(--text-primary);
    max-width: 580px;
    margin-bottom: 24px;
}

.meditation-1-grid {
    flex: 0 0 60%;
    position: relative;
    min-height: 500px;
    perspective: 1200px;
}

.perspective-grid-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateX(2deg);
}

.perspective-grid-svg line {
    stroke: var(--grid-line);
    stroke-width: 0.5;
    opacity: 0.4;
}

/* --- Wireframe Solids --- */
.solids-container {
    position: relative;
    width: 100%;
    height: 500px;
}

.solid-group {
    position: absolute;
    opacity: 0;
    transform: scale(0);
    transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 400ms ease;
}

.solid-group.visible {
    opacity: 1;
    transform: scale(1);
}

.solid-group[data-solid="cube"] {
    top: 10%;
    left: 15%;
}

.solid-group[data-solid="sphere"] {
    top: 35%;
    left: 55%;
}

.solid-group[data-solid="tetrahedron"] {
    top: 55%;
    left: 25%;
}

.wireframe-solid {
    width: 100px;
    height: 100px;
    display: block;
}

.solid-wireframe line,
.solid-wireframe ellipse,
.solid-wireframe path {
    stroke: var(--text-primary);
    stroke-width: 1;
    opacity: 0.6;
    fill: none;
}

.solid-wireframe {
    animation: slowRotate 30s linear infinite;
    transform-origin: center;
}

@keyframes slowRotate {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

.cube-wire { animation-duration: 28s; }
.sphere-wire { animation-duration: 35s; }
.tetra-wire { animation-duration: 32s; }
.torus-wire { animation-duration: 38s; }

.impossible-shadow {
    width: 80px;
    height: 30px;
    margin-top: -5px;
    margin-left: 10px;
    opacity: 0;
    transition: opacity 400ms ease 300ms;
}

.solid-group.visible .impossible-shadow {
    opacity: 1;
}

.shadow-shape {
    fill: var(--shadow-violet);
    opacity: 0.3;
}

.shadow-path {
    fill: none;
    stroke: var(--shadow-violet);
    stroke-width: 4;
    opacity: 0.3;
}

.coord-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--muted);
    display: block;
    margin-top: 4px;
    text-align: center;
}

/* --- Meditation II: Cogito --- */
.section-meditation-2 {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 120px 40px;
    background: var(--void);
    transition: background-color 4000ms ease;
    overflow: hidden;
}

.section-meditation-2.bg-transition {
    background-color: var(--bg-secondary);
}

.horizon-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--coral);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 1500ms ease-out;
    z-index: 1;
    box-shadow: 0 0 12px rgba(255, 107, 90, 0.4), 0 0 24px rgba(255, 107, 90, 0.15);
}

.horizon-line.visible {
    transform: scaleX(1);
}

@keyframes horizonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.horizon-line.visible {
    animation: horizonPulse 4s ease-in-out infinite;
}

.cogito-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 800px;
}

.cogito-content .meditation-label {
    text-align: center;
    margin-bottom: 48px;
}

.cogito-statement {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-size: clamp(32px, 5vw, 64px);
    line-height: 1.3;
    color: var(--text-warm);
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 2000ms ease-out, transform 2000ms ease-out;
}

.cogito-statement.visible {
    opacity: 1;
    transform: translateY(0);
}

.cogito-body {
    max-width: 520px;
    margin: 0 auto;
    text-align: left;
}

.cogito-body p {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 300;
    font-size: 17px;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 24px;
}

/* --- Meditation III: Clear and Distinct --- */
.section-meditation-3 {
    position: relative;
    min-height: 100vh;
    background: var(--bg-secondary);
    padding: 120px 40px 160px;
}

.meditation-3-header {
    text-align: center;
    margin-bottom: 80px;
}

.meditation-3-header .meditation-title {
    font-style: italic;
}

/* --- Broken Grid --- */
.broken-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto;
    gap: 60px 70px;
    max-width: 1200px;
    margin: 0 auto;
}

.idea-block {
    background: var(--bg-tertiary);
    padding: 48px 40px;
    transform: rotate(var(--rotation, 0deg));
    transition: transform 0.6s ease, opacity 0.8s ease;
    opacity: 0;
    border-left: 2px solid transparent;
}

.idea-block.visible {
    opacity: 1;
}

.idea-block:hover {
    border-left-color: rgba(255, 107, 90, 0.15);
}

.idea-block-1 {
    grid-column: 1;
    grid-row: 1;
}

.idea-block-2 {
    grid-column: 2;
    grid-row: 1;
    margin-top: 40px;
}

.idea-block-3 {
    grid-column: 3;
    grid-row: 1;
    margin-top: -20px;
}

.idea-block-4 {
    grid-column: 1;
    grid-row: 2;
    margin-top: -30px;
}

.idea-block-5 {
    grid-column: 2;
    grid-row: 2;
}

.idea-block-6 {
    grid-column: 3;
    grid-row: 2;
    margin-top: 20px;
}

.idea-block h3 {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 20px;
    color: var(--text-warm);
    margin-bottom: 20px;
    line-height: 1.3;
}

.idea-block p {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-primary);
}

/* --- Closing Viewport --- */
.section-closing {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--void);
    overflow: hidden;
}

.closing-plane {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1200px;
}

.closing-grid {
    position: absolute;
    width: 120%;
    height: 120%;
    transform: rotateX(2deg);
}

.closing-grid line {
    transition: stroke 2000ms ease;
}

.closing-grid.warm line {
    stroke: var(--ember);
}

.closing-axis {
    stroke: var(--grid-line);
    stroke-width: 1.5;
}

.closing-grid.warm .closing-axis {
    stroke: var(--ember);
}

/* --- Closing Solids --- */
.closing-solids {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 80px;
    z-index: 5;
}

.closing-solid-group {
    position: relative;
    cursor: default;
    transition: transform 0.3s ease;
}

.closing-solid-group .wireframe-solid {
    width: 100px;
    height: 100px;
}

.closing-solid-group .solid-wireframe line,
.closing-solid-group .solid-wireframe ellipse,
.closing-solid-group .solid-wireframe path {
    stroke: var(--text-primary);
    stroke-width: 1;
    opacity: 0.6;
    fill: none;
    transition: stroke 0.4s ease, opacity 0.4s ease;
}

.solid-fill {
    fill: transparent;
    transition: fill 0.4s ease;
}

.closing-solid-group:hover .solid-wireframe line,
.closing-solid-group:hover .solid-wireframe ellipse,
.closing-solid-group:hover .solid-wireframe path {
    stroke: var(--coral);
    opacity: 1;
}

.closing-solid-group:hover .solid-fill {
    fill: rgba(255, 107, 90, 0.08);
}

.closing-shadow {
    width: 80px;
    height: 30px;
    margin-top: -5px;
    margin-left: 10px;
}

.closing-shadow .shadow-shape {
    fill: var(--shadow-violet);
    opacity: 0.3;
    transition: all 2000ms ease-in-out;
}

.closing-shadow .shadow-path {
    fill: none;
    stroke: var(--shadow-violet);
    stroke-width: 4;
    opacity: 0.3;
    transition: all 2000ms ease-in-out;
}

.solid-info {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.closing-solid-group:hover .solid-info {
    opacity: 1;
}

.solid-name {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--coral);
    display: block;
    text-shadow: 0 0 12px rgba(255, 107, 90, 0.3);
}

.solid-coord {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--muted);
    display: block;
    margin-top: 2px;
}

/* --- Closing Logotype --- */
.closing-logotype {
    position: absolute;
    z-index: 10;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 1000ms ease-out;
}

.closing-logotype.visible {
    opacity: 1;
}

/* .dev character stagger animation */
.closing-dev-char {
    display: inline-block;
    opacity: 0;
    transition: opacity 400ms ease;
}

.closing-dev-char.visible {
    opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .broken-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 40px;
    }

    .idea-block-1 { grid-column: 1; grid-row: 1; }
    .idea-block-2 { grid-column: 2; grid-row: 1; margin-top: 0; }
    .idea-block-3 { grid-column: 1; grid-row: 2; margin-top: 0; }
    .idea-block-4 { grid-column: 2; grid-row: 2; margin-top: 0; }
    .idea-block-5 { grid-column: 1; grid-row: 3; }
    .idea-block-6 { grid-column: 2; grid-row: 3; margin-top: 0; }

    .meditation-1-content {
        flex-direction: column;
    }

    .meditation-1-text {
        flex: 1;
        max-width: 100%;
        padding-top: 0;
    }

    .meditation-1-grid {
        flex: 1;
        width: 100%;
    }

    .closing-solids {
        flex-wrap: wrap;
        gap: 40px;
        padding: 40px;
    }
}

@media (max-width: 768px) {
    .logo-text,
    .logo-dev {
        font-size: 48px;
    }

    .broken-grid {
        grid-template-columns: 1fr;
    }

    .idea-block-2,
    .idea-block-3,
    .idea-block-4,
    .idea-block-6 {
        margin-top: 0;
    }

    #main-nav {
        padding: 0 20px;
    }

    .nav-links {
        gap: 20px;
    }

    .section-meditation-1,
    .section-meditation-2,
    .section-meditation-3 {
        padding: 80px 20px;
    }

    .closing-solids {
        gap: 30px;
        padding: 20px;
    }
}

/* --- Selection --- */
::selection {
    background: rgba(255, 107, 90, 0.2);
    color: var(--text-warm);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--void);
}

::-webkit-scrollbar-thumb {
    background: var(--grid-line);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}
