/* ============================================
   conc.quest - Styles
   Monochrome Card-Flip Concurrency Experience
   ============================================ */

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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #0A0A0A;
    color: #FAFAFA;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.7;
    letter-spacing: 0.02em;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Dot Navigation --- */
#dot-nav {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 1000;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 2px solid #333333;
    background: transparent;
    cursor: pointer;
    transition: all 200ms ease;
    position: relative;
}

.dot.active {
    width: 10px;
    height: 10px;
    border-color: #FFFFFF;
    background: #FFFFFF;
}

.dot:hover {
    border-color: #999999;
}

.dot-tooltip {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.8rem);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #999999;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
}

.dot:hover .dot-tooltip {
    opacity: 1;
}

/* --- Card Spine (Main Container) --- */
#card-spine {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 0;
    gap: 48px;
}

/* --- Card Container --- */
.card-container {
    width: 90vw;
    max-width: 720px;
    aspect-ratio: 16 / 10;
    perspective: 1200px;
    scroll-snap-align: center;
    position: relative;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.card-container.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.card-container.dimmed {
    opacity: 0.7;
    transform: scale(0.95);
    transition: opacity 300ms ease, transform 300ms ease;
}

/* --- Card (Flip Container) --- */
.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 600ms cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: pointer;
    will-change: transform;
}

.card.flipped {
    transform: rotateY(180deg);
}

/* --- Card Faces --- */
.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border: 1px solid #333333;
    overflow: hidden;
}

.card-front {
    background-color: #FAFAFA;
    color: #0A0A0A;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: border-color 200ms ease;
}

.card-front:hover {
    border-color: #E0E0E0;
}

.card-back {
    background-color: #1A1A1A;
    color: #E0E0E0;
    transform: rotateY(180deg);
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Grid Underlay --- */
.card-front::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(to right, #0A0A0A 1px, transparent 1px),
        linear-gradient(to bottom, #0A0A0A 1px, transparent 1px);
    background-size: 8px 8px;
    opacity: 0.03;
    pointer-events: none;
}

.card-back::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(to right, #FAFAFA 1px, transparent 1px),
        linear-gradient(to bottom, #FAFAFA 1px, transparent 1px);
    background-size: 8px 8px;
    opacity: 0.03;
    pointer-events: none;
}

/* --- Card Number Watermark --- */
.card-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 8rem);
    color: #0A0A0A;
    opacity: 0.08;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}

/* --- Registration Marks --- */
.registration-mark {
    position: absolute;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    color: #999999;
    opacity: 0.4;
    pointer-events: none;
    line-height: 1;
}

.card-back .registration-mark {
    color: #666666;
}

.registration-mark.tl { top: 8px; left: 10px; }
.registration-mark.tr { top: 8px; right: 10px; }
.registration-mark.bl { bottom: 8px; left: 10px; }
.registration-mark.br { bottom: 8px; right: 10px; }

/* --- Card Grid (Front Face Content) --- */
.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    height: 100%;
    padding: 40px;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* --- Card Icon --- */
.card-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.iso-icon {
    width: 100%;
    max-width: 180px;
    height: auto;
}

.icon-annotation {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.8rem);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #666666;
}

/* --- Card Text (Front Face) --- */
.card-text {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.card-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #0A0A0A;
    line-height: 1.1;
}

.card-subtitle {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.8rem);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #666666;
}

/* --- Card Back Content --- */
.card-back-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    z-index: 1;
    max-height: 100%;
    overflow-y: auto;
}

.back-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #FAFAFA;
    margin-bottom: 4px;
}

.card-back-content p {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    line-height: 1.7;
    letter-spacing: 0.02em;
    color: #E0E0E0;
}

.manifesto {
    font-weight: 700;
    font-size: clamp(0.9rem, 1.6vw, 1.05rem);
    color: #FAFAFA;
}

.back-label {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.65rem, 1vw, 0.75rem);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #666666;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #333333;
}

/* --- Terminal Log (Exit Card Back) --- */
.terminal-log {
    font-family: 'IBM Plex Mono', monospace;
}

.terminal-line {
    color: #FAFAFA;
    margin-top: 8px;
}

.terminal-prompt {
    color: #999999;
    margin-right: 8px;
}

.terminal-output {
    color: #666666;
    padding-left: 20px;
}

.blink-cursor {
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* --- Card Edge Flash Effect --- */
.card-edge-flash {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: #FFFFFF;
    transform: translateX(-50%) scaleX(0);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: none;
}

.card-edge-flash.flash {
    animation: edgeFlash 600ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes edgeFlash {
    0% { transform: translateX(-50%) scaleX(0); opacity: 0; }
    40% { transform: translateX(-50%) scaleX(0); opacity: 0; }
    48% { transform: translateX(-50%) scaleX(1); opacity: 1; }
    52% { transform: translateX(-50%) scaleX(1); opacity: 1; }
    60% { transform: translateX(-50%) scaleX(0); opacity: 0; }
    100% { transform: translateX(-50%) scaleX(0); opacity: 0; }
}

/* --- Gear Rotation Animations --- */
.gear-rotate {
    transform-origin: center;
    animation: gearSpin 8s linear infinite;
}

.gear-rotate-reverse {
    transform-origin: center;
    animation: gearSpin 8s linear infinite reverse;
}

@keyframes gearSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Conveyor Animation --- */
.conveyor-move {
    animation: conveyorShift 3s linear infinite;
}

@keyframes conveyorShift {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -18; }
}

/* --- Flow Dash Animation (Channels) --- */
.flow-dash {
    animation: flowDash 2s linear infinite;
}

.flow-dash-reverse {
    animation: flowDash 2s linear infinite reverse;
}

@keyframes flowDash {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -24; }
}

/* --- Paused animation when flipped --- */
.card.flipped .iso-icon * {
    animation-play-state: paused;
}

/* --- Entrance Animation for first card --- */
.card-container.entrance {
    animation: cardEntrance 350ms ease-out forwards;
}

@keyframes cardEntrance {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(1.05);
    }
    60% {
        opacity: 1;
        transform: translateY(5px) scale(1.0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1.0);
    }
}

/* --- Mobile Responsive --- */
@media (max-width: 600px) {
    .card-grid {
        grid-template-columns: 1fr;
        padding: 24px;
        gap: 12px;
    }

    .card-icon {
        order: -1;
    }

    .iso-icon {
        max-width: 120px;
    }

    .card-back {
        padding: 24px;
    }

    .card-back-content p {
        font-size: clamp(0.8rem, 1.4vw, 0.9rem);
    }

    #dot-nav {
        right: 12px;
        gap: 12px;
    }

    .dot-tooltip {
        display: none;
    }

    #card-spine {
        padding: 24px 0;
        gap: 32px;
    }

    .card-container {
        aspect-ratio: 16 / 12;
    }
}

@media (max-width: 400px) {
    .card-container {
        aspect-ratio: 4 / 5;
    }

    .card-back {
        padding: 20px;
    }

    .card-back-content {
        gap: 10px;
    }
}

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

::-webkit-scrollbar-track {
    background: #0A0A0A;
}

::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #666666;
}

/* --- Selection --- */
::selection {
    background: #333333;
    color: #FAFAFA;
}
