/* =====================================================
   simidiot.com — Idiot AI Simulation
   Memphis bold shapes + neubrutalism + broken-grid layout
   Palette:
     #FFF8E7 cream, #2D1B69 void purple, #FF6B6B error coral,
     #FFE66D idiot yellow, #4ECDC4 success teal, #FF8ED4 memphis pink,
     #45B7D1 glitch blue, #1A0E3A shadow grape,
     and accents #E8E0F0
   Fonts: Bungee, Work Sans, Fira Code, Inter, Space Mono, Lato
   ===================================================== */

:root {
    --cream: #FFF8E7;
    --void: #2D1B69;
    --coral: #FF6B6B;
    --yellow: #FFE66D;
    --teal: #4ECDC4;
    --pink: #FF8ED4;
    --blue: #45B7D1;
    --grape: #1A0E3A;
    --soft: #E8E0F0;

    --font-display: "Bungee", "Inter", "Lato", system-ui, sans-serif;
    --font-body: "Work Sans", "Inter", "Lato", system-ui, sans-serif;
    --font-mono: "Fira Code", "Space Mono", ui-monospace, Menlo, monospace;

    --spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--cream);
    color: var(--void);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.65;
    overflow-x: hidden;
}

body {
    background:
        radial-gradient(circle at 20% 10%, rgba(255, 142, 212, 0.08), transparent 40%),
        radial-gradient(circle at 80% 60%, rgba(78, 205, 196, 0.08), transparent 40%),
        var(--cream);
}

p { margin: 0 0 1em 0; }

/* ============== TOP BAR ============== */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 38px;
    background: var(--grape);
    color: var(--teal);
    font-family: var(--font-mono);
    font-size: 13px;
    z-index: 100;
    border-bottom: 2px solid var(--coral);
    box-shadow: 0 2px 0 var(--yellow);
}

.top-bar-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 18px;
    gap: 10px;
    overflow: hidden;
    white-space: nowrap;
}

.brand-mark {
    color: var(--yellow);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.bar-divider { color: var(--coral); }
.bar-stat { color: var(--teal); }

.bar-blink {
    margin-left: auto;
    color: var(--coral);
    animation: blinkCaret 0.9s steps(2) infinite;
}

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

@media (max-width: 700px) {
    .hide-sm { display: none; }
    .top-bar { font-size: 11px; }
}

/* ============== SHAPE LAYER ============== */
.shape-layer {
    position: fixed;
    inset: 38px 0 0 0;
    pointer-events: none;
    z-index: 1;
}

.shape {
    position: absolute;
    width: 56px;
    height: 56px;
    opacity: 0.85;
    animation: float 5s ease-in-out infinite;
    will-change: transform;
}

.shape.circle { border-radius: 50%; }
.shape.triangle {
    width: 0;
    height: 0;
    background: transparent !important;
    border-left: 32px solid transparent;
    border-right: 32px solid transparent;
    border-bottom: 56px solid currentColor;
}
.shape.rect {
    width: 64px;
    height: 44px;
    border-radius: 10px;
    transform: rotate(8deg);
}
.shape.squiggle {
    width: 80px;
    height: 22px;
    background: transparent !important;
    border-top: 4px dashed currentColor;
    border-radius: 50%;
}
.shape.zigzag {
    width: 70px;
    height: 22px;
    background: transparent !important;
    background-image: linear-gradient(135deg, currentColor 25%, transparent 25%, transparent 50%, currentColor 50%, currentColor 75%, transparent 75%, transparent) !important;
    background-size: 12px 12px;
}

.c-coral { background: var(--coral); color: var(--coral); }
.c-pink { background: var(--pink); color: var(--pink); }
.c-teal { background: var(--teal); color: var(--teal); }
.c-yellow { background: var(--yellow); color: var(--yellow); }
.c-blue { background: var(--blue); color: var(--blue); }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(6deg); }
}
.shape:nth-child(2n) { animation-duration: 6s; animation-delay: -1.2s; }
.shape:nth-child(3n) { animation-duration: 4.5s; animation-delay: -2s; }
.shape:nth-child(5n) { animation-duration: 7s; animation-delay: -3.4s; }
.shape:nth-child(7n) { animation-duration: 5.5s; animation-delay: -0.8s; }

/* ============== MAIN / SCENES ============== */
main {
    position: relative;
    z-index: 5;
    padding-top: 38px;
}

.scene {
    position: relative;
    min-height: 100vh;
    padding: 80px 8vw;
    overflow: hidden;
}

.scene + .scene { padding-top: 60px; }

/* miscalculated spacing */
#sceneTranslator { margin-top: 6vh; }
#sceneAdvisor { margin-top: 18vh; }
#sceneCredits { margin-top: 4vh; }

.block {
    position: relative;
    background: var(--cream);
    border: 3px solid var(--void);
    border-radius: 4px;
    padding: 28px 32px;
    box-shadow: 8px 8px 0 var(--void);
    margin: 24px 0;
    transition: transform 0.4s var(--spring), box-shadow 0.3s ease;
}

.tilt-left  { transform: rotate(-2.3deg) translateX(-12px); }
.tilt-right { transform: rotate(2.7deg)  translateX(14px); }

.block:hover { box-shadow: 12px 12px 0 var(--coral); }

/* ============== TYPOGRAPHY ============== */
.display-h1, .display-h2 {
    font-family: var(--font-display);
    margin: 0 0 12px 0;
    letter-spacing: 0.04em;
    line-height: 1.05;
}
.display-h1 { font-size: clamp(44px, 7vw, 80px); color: var(--coral); transform: rotate(-1.5deg); }
.display-h2 { font-size: clamp(36px, 5.4vw, 60px); color: var(--coral); transform: rotate(1.2deg); }
.display-h2.dark-text { color: var(--void); }

.readout-label {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--coral);
    letter-spacing: 0.06em;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.readout-text {
    font-family: var(--font-body);
    font-size: 17px;
    color: var(--void);
    line-height: 1.65;
    font-weight: 400;
}
.readout-text.big-quote {
    font-size: 22px;
    font-weight: 500;
    line-height: 1.45;
}

/* ============== ANNOTATIONS ============== */
.annot {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--coral);
    background: rgba(255, 107, 107, 0.08);
    padding: 4px 8px;
    border-radius: 3px;
    border: 1px dashed var(--coral);
    display: inline-block;
    margin-top: 10px;
    letter-spacing: 0.03em;
}
.annot-coral { color: var(--coral); border-color: var(--coral); }
.annot-teal  { color: var(--teal); border-color: var(--teal); background: rgba(78,205,196,0.08); }
.annot-tl { position: absolute; top: 16px; left: 16px; }
.annot-br { position: absolute; bottom: 16px; right: 16px; }
.annot-bottom { display: block; margin-top: 14px; }
.annot-inline { display: inline-block; margin-top: 6px; font-size: 10px; }

/* ============== BOOT SCENE ============== */
.boot-scene {
    background: var(--grape);
    color: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 6vw;
}

.boot-frame {
    width: min(820px, 100%);
    background: #07041a;
    border: 3px solid var(--teal);
    border-radius: 8px;
    box-shadow: 12px 12px 0 var(--coral), 12px 12px 0 6px var(--yellow);
    overflow: hidden;
    transform: rotate(-1.2deg);
}

.boot-chrome {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #110827;
    border-bottom: 2px solid var(--teal);
}
.boot-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--coral);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.boot-dot:nth-child(2) { background: var(--yellow); }
.boot-dot:nth-child(3) { background: var(--teal); }
.boot-title {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--soft);
    opacity: 0.7;
}

.boot-body {
    padding: 22px 26px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--teal);
    min-height: 320px;
    line-height: 1.8;
}
.boot-line {
    white-space: pre;
    overflow: hidden;
}
.boot-line.caret-line {
    color: var(--yellow);
    margin-top: 10px;
}

.boot-scene .annot-tl,
.boot-scene .annot-br {
    color: var(--yellow);
    border-color: var(--yellow);
    background: rgba(255, 230, 109, 0.06);
}

/* ============== SQUIGGLE SEPARATOR ============== */
.squiggle-sep {
    width: 100%;
    height: 60px;
    margin: 10px 0;
    overflow: hidden;
    position: relative;
    z-index: 4;
}
.squiggle-sep svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============== PERCEPTION SCENE ============== */
.perception-scene {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 30px;
    padding-bottom: 120px;
}

.perception-scene .block-title { grid-column: 1 / span 2; }
.perception-scene .block-art   { grid-column: 1; grid-row: 2; }
.perception-scene .block-readout { grid-column: 2; grid-row: 2; }

.block-art {
    background: var(--cream);
    border: 3px solid var(--void);
    padding: 18px;
    position: relative;
    text-align: center;
}
.composition {
    width: 100%;
    max-width: 380px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.bbox {
    position: absolute;
    top: 12%;
    left: 8%;
    width: 56%;
    height: 70%;
    border: 2px dashed var(--coral);
    border-radius: 4px;
    pointer-events: none;
    animation: bboxPulse 3.4s ease-in-out infinite;
}
.bbox-label {
    position: absolute;
    top: -18px;
    left: 0;
    background: var(--coral);
    color: var(--cream);
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 2px;
    letter-spacing: 0.04em;
}

@keyframes bboxPulse {
    0%, 100% { opacity: 0.95; transform: translate(0,0); }
    40% { opacity: 0.5; transform: translate(2px,-1px); }
    70% { opacity: 0.85; transform: translate(-2px,1px); }
}

/* ============== METERS ============== */
.readout-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0 8px;
}
.conf-meter {
    display: grid;
    grid-template-columns: 110px 1fr 38px;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--void);
    letter-spacing: 0.05em;
}
.conf-meter .meter-label { text-align: left; }
.conf-meter .meter-val { text-align: right; }
.meter-bar {
    height: 12px;
    background: rgba(45, 27, 105, 0.08);
    border: 1.5px solid var(--void);
    border-radius: 2px;
    overflow: hidden;
}
.meter-bar > span {
    display: block;
    height: 100%;
    background: var(--coral);
    transform-origin: left;
    transition: width 1s var(--spring);
}
.conf-meter.dark { color: var(--soft); }
.conf-meter.dark .meter-bar { background: rgba(232, 224, 240, 0.08); border-color: var(--soft); }

/* ============== TRANSLATOR SCENE ============== */
.translator-scene {
    background: repeating-linear-gradient(
        90deg,
        var(--cream) 0,
        var(--cream) 8px,
        rgba(255, 230, 109, 0.18) 8px,
        rgba(255, 230, 109, 0.18) 16px
    );
    padding-bottom: 120px;
}

.trans-grid {
    display: grid;
    grid-template-columns: 1fr 80px 1fr;
    gap: 16px;
    align-items: center;
    margin-top: 30px;
}

.trans-input, .trans-output {
    min-height: 220px;
}

.trans-output {
    margin-left: -8%;
    z-index: 2;
}

.trans-arrow {
    text-align: center;
    transform: rotate(-7deg);
}
.trans-arrow svg {
    width: 100%;
    max-width: 80px;
    height: auto;
}

@media (max-width: 760px) {
    .trans-grid { grid-template-columns: 1fr; }
    .trans-arrow { transform: rotate(86deg); margin: 12px 0; }
    .trans-output { margin-left: 0; }
    .perception-scene { grid-template-columns: 1fr; }
    .perception-scene .block-title,
    .perception-scene .block-art,
    .perception-scene .block-readout {
        grid-column: 1;
    }
}

/* ============== ADVISOR SCENE ============== */
.advisor-scene {
    background: var(--cream);
    padding-bottom: 140px;
}

.advice-card {
    background: var(--yellow);
    border: 3px solid var(--void);
    padding: 36px 40px 32px;
    position: relative;
    box-shadow: 10px 10px 0 var(--coral);
    max-width: 760px;
    margin: 24px auto;
}
.quote-mark {
    font-family: var(--font-display);
    font-size: 110px;
    color: var(--coral);
    line-height: 0.5;
    position: absolute;
    top: 30px;
    left: 18px;
    opacity: 0.9;
}
.advice-text {
    font-family: var(--font-body);
    font-size: 18px;
    color: var(--void);
    padding-left: 60px;
    margin: 0 0 18px 0;
    line-height: 1.55;
}
.advice-text em {
    font-style: italic;
    background: var(--coral);
    color: var(--cream);
    padding: 0 4px;
}
.advice-cite {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--void);
    padding-left: 60px;
    opacity: 0.85;
}
.cite-fake {
    background: rgba(45, 27, 105, 0.1);
    padding: 1px 5px;
    border-radius: 2px;
}

.peer-badge {
    position: absolute;
    bottom: -22px;
    right: -10px;
    background: var(--teal);
    color: var(--grape);
    border: 3px solid var(--void);
    padding: 8px 14px;
    transform: rotate(6deg);
    font-family: var(--font-mono);
    font-size: 11px;
    box-shadow: 4px 4px 0 var(--coral);
    text-align: center;
}
.peer-stamp {
    display: block;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--grape);
}
.peer-detail {
    display: block;
    font-size: 10px;
    margin-top: 2px;
    color: var(--void);
}

.tip-block {
    max-width: 460px;
    margin: 28px 0;
}
.advisor-scene .tip-block:nth-of-type(odd) { margin-left: 6%; }
.advisor-scene .tip-block:nth-of-type(even) { margin-left: auto; margin-right: 6%; }

/* ============== CREDITS SCENE ============== */
.credits-scene {
    background: var(--void);
    color: var(--soft);
    padding: 100px 8vw 140px;
    position: relative;
    overflow: hidden;
}

.credits-inner {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    z-index: 3;
}

.credits-line {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--soft);
    margin-bottom: 30px;
    line-height: 1.7;
}

.final-stat {
    display: inline-block;
    margin: 16px 0 30px;
    text-align: center;
}
.final-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--teal);
    letter-spacing: 0.1em;
    margin-bottom: 6px;
}
.final-num {
    font-family: var(--font-display);
    font-size: clamp(48px, 6vw, 64px);
    color: var(--yellow);
    letter-spacing: 0.04em;
    display: inline-block;
}
.final-stat.bounce .final-num {
    animation: bounceIn 0.8s var(--spring) both;
}

@keyframes bounceIn {
    0% { transform: scale(0.4) translateY(40px); opacity: 0; }
    60% { transform: scale(1.15) translateY(-6px); opacity: 1; }
    100% { transform: scale(1) translateY(0); }
}

.credits-meters {
    max-width: 360px;
    margin: 24px auto 30px;
    text-align: left;
}

.credit-list {
    margin: 30px auto 20px;
    max-width: 480px;
    border-top: 1px dashed var(--soft);
    border-bottom: 1px dashed var(--soft);
    padding: 18px 0;
}
.credit-row {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--soft);
    padding: 4px 0;
    letter-spacing: 0.04em;
}
.credit-row span:first-child { color: var(--teal); }
.credit-row span:last-child  { color: var(--yellow); }

.credits-scene .boot-line.static {
    text-align: center;
    color: var(--coral);
    font-family: var(--font-mono);
    font-size: 13px;
    margin-top: 24px;
    opacity: 0.85;
}
.credits-scene .boot-line.static::before { content: attr(data-text); }

/* drift shapes */
.drift-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.drift-layer .shape.drift {
    position: absolute;
    top: -80px;
    animation: driftDown 9s linear infinite;
    opacity: 0.7;
}
@keyframes driftDown {
    0%   { transform: translateY(0) rotate(0deg); opacity: 0.7; }
    90%  { opacity: 0.7; }
    100% { transform: translateY(120vh) rotate(360deg); opacity: 0; }
}

/* ============== ERROR BOXES ============== */
.errbox {
    position: absolute;
    border: 2px dashed var(--coral);
    border-radius: 2px;
    pointer-events: none;
    z-index: 6;
}
.errbox-tag {
    position: absolute;
    top: -16px;
    left: -2px;
    background: var(--coral);
    color: var(--cream);
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.errbox-1 { top: 30%; right: 4%; width: 180px; height: 110px; transform: rotate(-3deg); }
.errbox-2 { top: 18%; left: 3%; width: 160px; height: 90px; transform: rotate(2deg); }
.errbox-3 { bottom: 8%; right: 6%; width: 200px; height: 60px; transform: rotate(-2deg); border-color: var(--teal); }
.errbox-3 .errbox-tag { background: var(--teal); color: var(--grape); }
.errbox-4 { bottom: 4%; left: 4%; width: 240px; height: 70px; transform: rotate(3deg); }

/* ============== GLITCH SECTIONS ============== */
.glitch-section {
    animation: glitchShift 9s infinite;
}
@keyframes glitchShift {
    0%, 92%, 100% { transform: translate(0,0); text-shadow: none; }
    93% { transform: translate(3px, 0); text-shadow: -1px 0 var(--coral), 1px 0 var(--teal); }
    94% { transform: translate(-2px, 0); text-shadow: 1px 0 var(--coral), -1px 0 var(--teal); }
    95% { transform: translate(0, 0); text-shadow: none; }
}

/* ============== ENTRANCE ANIMATIONS ============== */
.scene .block {
    opacity: 0;
}
.scene.in-view .block {
    opacity: 1;
    animation: snapIn 0.85s var(--spring) both;
}
.scene.in-view .block:nth-child(1) { animation-delay: 0.05s; }
.scene.in-view .block:nth-child(2) { animation-delay: 0.18s; }
.scene.in-view .block:nth-child(3) { animation-delay: 0.32s; }
.scene.in-view .block:nth-child(4) { animation-delay: 0.45s; }
.scene.in-view .block:nth-child(5) { animation-delay: 0.55s; }

@keyframes snapIn {
    0%   { opacity: 0; transform: translateX(-60px) rotate(-12deg); }
    65%  { opacity: 1; transform: translateX(8px) rotate(3deg); }
    85%  { transform: translateX(-3px) rotate(-1deg); }
    100% { opacity: 1; }
}

/* boot scene blocks animate together */
.boot-scene .boot-frame {
    opacity: 1;
}

/* meter fills wait until visible */
.meter-bar > span { width: 0 !important; }
.scene.in-view .meter-bar > span,
.in-view .meter-bar > span {
    width: var(--w, 0) !important;
}

/* fallback: use inline style width as final value */
.meter-bar > span[style] { width: 0 !important; }
.scene.in-view .meter-bar > span[style] {
    /* let JS apply width inline by removing this class */
}

/* simpler: keep meter widths driven by inline style; just animate from 0 */
.meter-bar > span {
    width: 0;
    animation: meterFill 1.2s var(--spring) forwards;
    animation-play-state: paused;
}
.scene.in-view .meter-bar > span,
.in-view .meter-bar > span {
    animation-play-state: running;
}

@keyframes meterFill {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

/* The above keyframe doesn't work because width itself needs animating.
   Do it the simple way: width 0 baseline, scale via JS class. */
.meter-bar > span {
    animation: none;
    transition: width 1.2s var(--spring);
}
.scene.in-view .meter-bar > span,
.in-view .meter-bar > span {
    /* width set via inline style takes effect */
}

/* ============== FOOTER ============== */
.page-footer {
    background: var(--grape);
    color: var(--soft);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 2px solid var(--coral);
    position: relative;
    z-index: 8;
}
.page-footer span:first-child { color: var(--yellow); }
.footer-mid { color: var(--teal); }

/* ============== RESPONSIVE TILT REDUCTION ============== */
@media (max-width: 600px) {
    .scene { padding: 50px 5vw; }
    .tilt-left, .tilt-right { transform: none; }
    .block { box-shadow: 5px 5px 0 var(--void); }
    .display-h1 { font-size: 40px; }
    .display-h2 { font-size: 30px; }
    .errbox { display: none; }
}

/* ============== UTILS ============== */
.hidden { display: none !important; }
