/*
 * THE TECHNO-SOCIAL DILEMMA — v 0.9
 * ══════════════════════════════════════
 */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

:root {
    --color-bg: #f5f5f0;
    --color-text: #1d1f21;
    --color-text-muted: #5c5c5c;
    --color-accent: #8b1a1a;
    --color-border: #c5c5c0;
    --color-card-bg: #f0ece4;
    --color-card-border: #1d1f21;
    --font-mono: 'Space Mono', 'Courier New', monospace;
    --card-w: 100px;
    --card-w-center: 110px;
    --transition-speed: 0.6s;
}

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

body {
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1.7;
    color: var(--color-text);
    background: radial-gradient(ellipse at center, #f5f5f0 0%, #e0e0d8 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 1.5rem 1.5rem;
    position: relative;
    overflow-x: hidden;
}

/* ═══════════════════════════════════════════
   BACKGROUND EFFECTS
   ═══════════════════════════════════════════ */

.bg-effects {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 0;
}

.bg-pulse {
    position: absolute;
    top: -10%; left: -10%; right: -10%; bottom: -10%;
    background: radial-gradient(ellipse at center,
        rgba(139, 26, 26, 0.06) 0%, transparent 50%);
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

.bg-noise {
    position: absolute;
    top: -50%; left: -50%; right: -50%; bottom: -50%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.05;
    animation: noise 0.5s steps(3) infinite;
}

@keyframes noise {
    0% { transform: translate(0, 0); }
    33% { transform: translate(-5px, -5px); }
    66% { transform: translate(5px, 5px); }
    100% { transform: translate(0, 0); }
}

/* ═══════════════════════════════════════════
   LAYOUT — vertically + horizontally centered
   ═══════════════════════════════════════════ */

main {
    position: relative;
    z-index: 1;
    max-width: 920px;
    margin: 0 auto;
    min-height: calc(100vh - 3rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════
   SPLASH — animated intro sequence
   ═══════════════════════════════════════════ */

.splash {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.5s ease;
}

main.active .splash {
    opacity: 0;
    pointer-events: none;
}

.splash-stage {
    position: relative;
    width: 600px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.splash-line {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.splash-line.visible {
    opacity: 1;
}

#splash-1, #splash-2 {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
}

.splash-title {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    line-height: 1.2;
    color: var(--color-text);
}

.btn-begin {
    font-family: var(--font-mono);
    font-size: 1rem;
    padding: 0.7rem 2rem;
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    letter-spacing: 0.1em;
    transition: background 0.2s ease, opacity 0.6s ease;
    white-space: nowrap;
    margin-top: 2rem;
}

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

/* ═══════════════════════════════════════════
   BOARD — 2×2 grid with center
   ═══════════════════════════════════════════ */

.board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
        "time      space"
        "center    center"
        "awareness agency";
    gap: 0.75rem 1.5rem;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease 0.3s;
}

main.active .board {
    opacity: 1;
    pointer-events: auto;
}

.q-time      { grid-area: time; }
.q-space     { grid-area: space; }
.center-cluster { grid-area: center; }
.q-awareness { grid-area: awareness; }
.q-agency    { grid-area: agency; }

/* ═══════════════════════════════════════════
   QUADRANTS
   ═══════════════════════════════════════════ */

.quadrant {
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.quadrant.visible {
    opacity: 1;
    visibility: visible;
}

.quadrant-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.card-row {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    align-items: flex-start;
}

/* ═══════════════════════════════════════════
   CENTER CLUSTER — absolute positioning
   ═══════════════════════════════════════════ */

.center-cluster {
    position: relative;
    height: 220px;
    margin: 1rem 0;
}

.center-cluster .card {
    position: absolute;
    top: 50%;
    width: var(--card-w-center);
    transition: left var(--transition-speed) ease,
                transform var(--transition-speed) ease,
                z-index var(--transition-speed) ease,
                opacity 0.4s ease,
                box-shadow 0.3s ease,
                top 0.2s ease-out;
}

#card-tech {
    left: calc(50% - 70px);
    transform: translate(-50%, -50%);
    z-index: 1;
}

#card-social {
    left: calc(50% + 70px);
    transform: translate(-50%, -50%);
    z-index: 2;
}

#card-dilemma {
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

#card-conclusion {
    left: calc(50% + 230px);
    transform: translate(-50%, -50%);
    z-index: 1;
}

/* Crossed state */
.center-crossed #card-tech {
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    z-index: 1;
}

.center-crossed #card-social {
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    z-index: 2;
}

/* Spread state — three cards in a row: Tech → Social → Dilemma */
.center-spread #card-tech {
    left: calc(50% - 130px);
    transform: translate(-50%, -50%);
    z-index: 1;
}

.center-spread #card-social {
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.center-spread #card-dilemma {
    left: calc(50% + 130px);
    z-index: 1;
}

.center-spread #card-conclusion {
    left: calc(50% + 330px);
    transform: translate(-50%, -50%);
}

/* ═══════════════════════════════════════════
   CROSS OVERLAY — clickable zone for crossed cards
   ═══════════════════════════════════════════ */

.cross-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    z-index: 3;
    display: block;
    pointer-events: none;
    text-decoration: none;
}

.cross-overlay.active {
    pointer-events: auto;
    cursor: pointer;
}

/* Hovering the overlay scales both crossed cards */
.cross-overlay.active:hover ~ #card-tech {
    transform: translate(-50%, -50%) rotate(45deg) scale(1.05);
}

.cross-overlay.active:hover ~ #card-social {
    transform: translate(-50%, -50%) rotate(-45deg) scale(1.05);
}

/* ═══════════════════════════════════════════
   CARDS — tarot style, fade-in only
   ═══════════════════════════════════════════ */

.card {
    display: block;
    width: var(--card-w);
    aspect-ratio: 2 / 3;
    border: 3px double var(--color-card-border);
    border-radius: 6px;
    background: var(--color-card-bg);
    text-decoration: none;
    color: var(--color-text);
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, box-shadow 0.3s ease, transform 0.2s ease-out;
}

.card.revealed {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

/* ── Hover: lift ── */

/* Quadrant cards: transform lift */
.card-row .card.revealed:hover {
    transform: translateY(-6px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* Center cards: top lift (transform is used for positioning) */
.center-cluster .card.revealed:hover {
    top: calc(50% - 6px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* Center cards keep translate for absolute positioning */
.center-cluster .card {
    transform: translate(-50%, -50%);
}

.card-face {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-image {
    flex: 1;
    border-bottom: 1px solid var(--color-card-border);
}

.card-title {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    text-align: center;
    padding: 0.35rem 0.2rem;
    letter-spacing: 0.02em;
    line-height: 1.2;
}


/* ── Exception: crossed cards wiggle ── */

.center-crossed #card-tech.revealed:hover {
    top: 50%;
    box-shadow: none;
    animation: wiggle-tech 0.3s ease-in-out 2;
}

.center-crossed #card-social.revealed:hover {
    top: 50%;
    box-shadow: none;
    animation: wiggle-social 0.3s ease-in-out 2;
}

@keyframes wiggle-tech {
    0%, 100% { transform: translate(-50%, -50%) rotate(45deg); }
    25% { transform: translate(-50%, -50%) rotate(48deg); }
    75% { transform: translate(-50%, -50%) rotate(42deg); }
}

@keyframes wiggle-social {
    0%, 100% { transform: translate(-50%, -50%) rotate(-45deg); }
    25% { transform: translate(-50%, -50%) rotate(-42deg); }
    75% { transform: translate(-50%, -50%) rotate(-48deg); }
}

/* ═══════════════════════════════════════════
   THE GAP — absence of a card
   ═══════════════════════════════════════════ */

.card.card-gap {
    background: transparent;
    border-style: dashed;
    border-color: var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-label {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--color-border);
    letter-spacing: 0.04em;
    text-align: center;
    line-height: 1.3;
}

/* Exception: The Gap — dark glow, no lift */
.card.card-gap.revealed:hover {
    transform: none;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.25),
                0 0 30px rgba(0, 0, 0, 0.1);
}

/* ═══════════════════════════════════════════
   GAP STACK — The Gap + The Story layered
   ═══════════════════════════════════════════ */

.gap-stack {
    position: relative;
    width: var(--card-w);
    flex-shrink: 0;
}

#card-story {
    position: absolute;
    top: 22px;
    left: 0;
    z-index: 2;
}

/* ═══════════════════════════════════════════
   NAV BUTTONS — fixed, flanking the spread
   ═══════════════════════════════════════════ */

.btn-back, .btn-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    font-family: var(--font-mono);
    font-size: 1.3rem;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease, opacity 0.3s ease, visibility 0.3s ease;
    line-height: 1;
}

.btn-back:hover, .btn-next:hover {
    color: var(--color-text);
}

.btn-back {
    left: calc(50% - 470px);
}

.btn-next {
    right: calc(50% - 470px);
}

.btn-back.hidden, .btn-next.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   OUTRO — closing screen
   ═══════════════════════════════════════════ */

.outro {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #f5f5f0, #e0e0d8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.outro.visible {
    opacity: 1;
    pointer-events: auto;
}

.outro-body {
    position: relative;
}

.outro-heading {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
    margin-bottom: 2.5rem;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.outro.visible .outro-heading {
    opacity: 1;
    transition-delay: 0.4s;
}

.outro-links {
    display: flex;
    align-items: center;
    gap: 3rem;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.outro.visible .outro-links {
    opacity: 1;
    transition-delay: 1s;
}

.outro-link {
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--color-text);
    text-decoration: none;
    text-align: center;
    line-height: 1.3;
    padding: 1.5rem 2rem;
    transition: color 0.2s ease;
}

.outro-link:hover {
    color: var(--color-accent);
}

/* ═══════════════════════════════════════════
   LOGIN GATE
   ═══════════════════════════════════════════ */

.login-gate {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #f5f5f0, #e0e0d8);
}

.login-gate.active {
    display: flex;
}

.login-gate.fade-out {
    animation: gate-fade 0.5s ease forwards;
}

@keyframes gate-fade {
    to { opacity: 0; }
}

.login-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.login-box input {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    color: var(--color-text);
    text-align: center;
    letter-spacing: 0.05em;
    outline: none;
    width: 200px;
    transition: border-color 0.2s ease;
}

.login-box input:focus {
    border-color: var(--color-text);
}

.login-box input::placeholder {
    color: var(--color-border);
    letter-spacing: 0.1em;
}

#login-btn {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.5rem 1.5rem;
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    letter-spacing: 0.1em;
    margin-top: 0.4rem;
    transition: background 0.2s ease;
}

#login-btn:hover {
    background: var(--color-accent);
}

#login-btn.shake {
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.login-error {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--color-accent);
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ═══════════════════════════════════════════
   INSTANT JUMP (no transitions)
   ═══════════════════════════════════════════ */

body.no-transition * {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 960px) {
    .btn-back { left: 1rem; }
    .btn-next { right: 1rem; }
}

@media (max-width: 700px) {
    .board {
        grid-template-columns: 1fr;
        grid-template-areas:
            "center"
            "time"
            "space"
            "awareness"
            "agency";
        gap: 2rem;
    }

    :root {
        --card-w: 90px;
        --card-w-center: 100px;
    }

    .center-cluster {
        height: 190px;
    }

    #card-tech { left: calc(50% - 55px); }
    #card-social { left: calc(50% + 55px); }
    #card-conclusion { left: calc(50% + 190px); }

    .center-spread #card-tech { left: calc(50% - 110px); }
    .center-spread #card-social { left: 50%; }
    .center-spread #card-dilemma { left: calc(50% + 110px); }
    .center-spread #card-conclusion { left: calc(50% + 280px); }

    .splash-stage { width: 90vw; }

    .splash-title {
        font-size: 2rem;
        letter-spacing: 0.12em;
    }

    .outro-links {
        flex-direction: column;
        gap: 1.5rem;
    }

    .outro-link {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    :root {
        --card-w: 75px;
        --card-w-center: 85px;
    }

    .center-cluster {
        height: 160px;
    }

    #card-tech { left: calc(50% - 45px); }
    #card-social { left: calc(50% + 45px); }
    #card-conclusion { left: calc(50% + 155px); }

    .center-spread #card-tech { left: calc(50% - 95px); }
    .center-spread #card-social { left: 50%; }
    .center-spread #card-dilemma { left: calc(50% + 95px); }
    .center-spread #card-conclusion { left: calc(50% + 240px); }

    .card-title {
        font-size: 0.5rem;
    }

    .splash-title {
        font-size: 1.4rem;
        letter-spacing: 0.08em;
    }

    .outro-link {
        font-size: 1.2rem;
        padding: 1rem 1.5rem;
    }
}
