/* =====================================================================
   logic.day -- Pop-Art Celebration of Logical Thinking
   Z-pattern layout, neon-glow operators, color-blocked truth tables.
   ===================================================================== */

/* ---------- TOKENS ---------- */
:root {
    /* Palette */
    --bg:           #faf8f0;
    --ink:          #0a0a0a;
    --aurora-green: #34d399;
    --aurora-violet:#4a2a8a;
    --aurora-teal:  #2dd4bf;
    --bubble-fill:  #fff8e0;
    --crystal:      #a78bfa;
    --true-bg:      rgba(52, 211, 153, 0.20);
    --false-bg:     rgba(74, 42, 138, 0.15);
    --true-bg-hot:  rgba(52, 211, 153, 0.45);
    --false-bg-hot: rgba(74, 42, 138, 0.40);

    /* Type */
    --f-display: 'Bungee', 'Impact', sans-serif;
    --f-body:    'DM Sans', system-ui, sans-serif;
    --f-mono:    'Fira Mono', 'Menlo', monospace;

    /* Geometry */
    --outline:   3px solid var(--ink);
    --outline-fat: 5px solid var(--ink);

    /* Glow stacks (aurora) */
    --glow-aurora:
        0 0 2px  var(--aurora-green),
        0 0 6px  var(--aurora-green),
        0 0 12px var(--aurora-violet),
        0 0 24px var(--aurora-teal);
    --glow-violet:
        0 0 2px  var(--aurora-violet),
        0 0 6px  var(--aurora-violet),
        0 0 12px var(--crystal),
        0 0 24px var(--aurora-violet);
    --glow-teal:
        0 0 2px  var(--aurora-teal),
        0 0 6px  var(--aurora-teal),
        0 0 12px var(--aurora-green),
        0 0 24px var(--aurora-teal);
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--f-body);
    font-size: clamp(16px, 1.6vw, 19px);
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
table { border-collapse: collapse; }

/* ---------- BEN-DAY DOT FIELD (page-wide overlay, low opacity) ---------- */
.bday-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image: radial-gradient(rgba(10,10,10,0.06) 1.2px, transparent 1.5px);
    background-size: 14px 14px;
    mix-blend-mode: multiply;
}

/* ---------- Z-PATTERN GRID ---------- */
.z-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: minmax(min-content, auto);
    column-gap: clamp(40px, 8vw, 100px);
    row-gap: clamp(40px, 6vw, 80px);
    padding: clamp(48px, 7vw, 110px) clamp(24px, 6vw, 96px);
    position: relative;
    z-index: 2;
}
.z-cell {
    position: relative;
    min-width: 0;
}
.top-left    { grid-column: 1; grid-row: 1; }
.top-right   { grid-column: 2; grid-row: 1; }
.bottom-left { grid-column: 1; grid-row: 2; }
.bottom-right{ grid-column: 2; grid-row: 2; }

/* ---------- HERO ---------- */
.hero {
    min-height: 100vh;
    align-content: center;
}

.logo-logic {
    font-family: var(--f-display);
    font-size: clamp(48px, 13vw, 200px);
    line-height: 0.88;
    letter-spacing: 0.01em;
    color: var(--ink);
    display: inline-block;
    transform: translateY(0);
}
.logo-logic .char {
    display: inline-block;
    color: var(--ink);
    text-shadow: none;
    transition: text-shadow 0.5s ease;
    will-change: text-shadow;
}
.logo-logic.lit .char {
    animation: neon-build 900ms cubic-bezier(.2,.8,.2,1) forwards;
}
.logo-logic.lit .char:nth-child(1){ animation-delay: 0ms; }
.logo-logic.lit .char:nth-child(2){ animation-delay: 80ms; }
.logo-logic.lit .char:nth-child(3){ animation-delay: 160ms; }
.logo-logic.lit .char:nth-child(4){ animation-delay: 240ms; }
.logo-logic.lit .char:nth-child(5){ animation-delay: 320ms; }
@keyframes neon-build {
    0%   { text-shadow: none; }
    25%  { text-shadow: 0 0 2px var(--aurora-green); }
    50%  { text-shadow: 0 0 2px var(--aurora-green), 0 0 6px var(--aurora-green); }
    75%  { text-shadow: 0 0 2px var(--aurora-green), 0 0 6px var(--aurora-green), 0 0 12px var(--aurora-violet); }
    100% { text-shadow: var(--glow-aurora); }
}

.logo-day {
    font-family: var(--f-display);
    font-size: clamp(36px, 6vw, 96px);
    line-height: 1;
    letter-spacing: 0.02em;
    text-align: right;
    position: relative;
    color: var(--ink);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 600ms ease 250ms, transform 600ms cubic-bezier(.2,.8,.2,1) 250ms;
}
.logo-day .dot { color: var(--aurora-violet); }
.logo-day.shown {
    opacity: 1;
    transform: translateX(0);
}
.kicker {
    margin-top: 18px;
    font-family: var(--f-mono);
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--aurora-violet);
    text-align: right;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 700ms ease 600ms, transform 700ms ease 600ms;
}
.logo-day.shown + .kicker,
.logo-day.shown ~ .kicker { opacity: 1; transform: translateY(0); }

.crystal-accent {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: var(--crystal);
    border: var(--outline);
    transform: rotate(45deg);
    margin-left: 14px;
    vertical-align: middle;
    box-shadow: 0 0 0 0 var(--crystal);
    animation: crystal-pulse 3s ease-in-out infinite;
}
.crystal-accent.big {
    width: 26px; height: 26px;
    margin-left: 22px;
}
@keyframes crystal-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(167,139,250,0.6); }
    50%      { box-shadow: 0 0 0 14px rgba(167,139,250,0);   }
}

/* Hero bottom-left: speech bubble */
.bottom-left {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 24px;
}
.speech-bubble {
    position: relative;
    background: var(--bubble-fill);
    border: var(--outline-fat);
    border-radius: 28px;
    padding: 22px 32px;
    max-width: 540px;
    box-shadow: 8px 8px 0 0 var(--ink);
    transform: translateY(20px);
    opacity: 0;
    transition: opacity 500ms ease, transform 600ms cubic-bezier(.2,.8,.2,1);
}
.speech-bubble.in { opacity: 1; transform: translateY(0); }
.speech-bubble.big {
    padding: 30px 44px;
    border-radius: 36px;
}
.bubble-text {
    font-family: var(--f-display);
    font-size: clamp(28px, 4.5vw, 56px);
    line-height: 1;
    color: var(--ink);
    letter-spacing: 0.02em;
}
.bubble-tail {
    position: absolute;
    width: 0;
    height: 0;
    bottom: -22px;
    left: 56px;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 24px solid var(--ink);
}
.bubble-tail::after {
    content: '';
    position: absolute;
    top: -28px;
    left: -14px;
    width: 0; height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 18px solid var(--bubble-fill);
}

.ben-day-stripe {
    width: 220px;
    height: 16px;
    background-image: radial-gradient(var(--ink) 28%, transparent 30%);
    background-size: 14px 14px;
    opacity: 0.18;
    border-radius: 2px;
}

/* Hero bottom-right: AND logic gate */
.bottom-right {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 14px;
}
.logic-gate-frame {
    position: relative;
    width: clamp(220px, 28vw, 380px);
    padding: 20px 24px 16px;
    background: var(--bubble-fill);
    border: var(--outline-fat);
    border-radius: 18px;
    box-shadow: 8px 8px 0 0 var(--ink);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 600ms ease, transform 700ms cubic-bezier(.2,.8,.2,1);
}
.logic-gate-frame.in { opacity: 1; transform: translateX(0); }
.logic-gate { width: 100%; height: auto; display: block; }
.logic-gate .gate-body,
.logic-gate .gate-wire {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: stroke-draw 1100ms ease 200ms forwards;
}
.logic-gate .gate-wire { animation-duration: 700ms; }
.logic-gate-frame.lit { filter: drop-shadow(0 0 8px var(--aurora-green)) drop-shadow(0 0 18px var(--aurora-violet)); }
@keyframes stroke-draw {
    to { stroke-dashoffset: 0; }
}
.gate-label {
    font-family: var(--f-mono);
    font-size: 14px;
    fill: var(--ink);
}
.gate-caption {
    font-family: var(--f-display);
    font-size: 28px;
    letter-spacing: 0.06em;
    color: var(--ink);
    text-shadow: var(--glow-teal);
    display: inline-block;
    margin-top: 4px;
}

/* Scroll cue */
.scroll-cue {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: var(--f-mono);
    font-size: 11px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--ink);
    opacity: 0.55;
}
.cue-line {
    width: 1px;
    height: 36px;
    background: var(--ink);
    animation: cue-fall 1.6s ease-in-out infinite;
    transform-origin: top;
}
@keyframes cue-fall {
    0%   { transform: scaleY(0); }
    50%  { transform: scaleY(1); }
    100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ---------- SECTION FRAMING ---------- */
.section { position: relative; z-index: 2; }
.section + .section { padding-top: 0; }
.section-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    gap: 18px;
    padding: 0 clamp(24px, 6vw, 96px);
    margin: 60px 0 24px;
}
.section-num {
    font-family: var(--f-mono);
    font-size: 13px;
    letter-spacing: 0.16em;
    color: var(--aurora-violet);
}
.section-title {
    font-family: var(--f-display);
    font-size: clamp(28px, 4.5vw, 64px);
    line-height: 1;
    color: var(--ink);
    letter-spacing: 0.02em;
}
.section-rule {
    flex: 1;
    height: 4px;
    background: var(--ink);
    margin-left: 6px;
    align-self: center;
}

/* ---------- OPERATORS Z-PATTERN ---------- */
.op-symbol {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(220px, 30vw, 360px);
    padding: 32px;
    border: var(--outline-fat);
    background: var(--bubble-fill);
    box-shadow: 10px 10px 0 0 var(--ink);
    overflow: hidden;
    transform: translateX(-30px);
    opacity: 0;
    transition: opacity 500ms ease, transform 600ms cubic-bezier(.2,.8,.2,1);
}
.op-symbol.bottom-right,
.op-symbol.top-right {
    transform: translateX(30px);
}
.op-symbol.in { opacity: 1; transform: translateX(0); }

.symbol-wrap {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.op-glyph {
    font-family: var(--f-display);
    font-size: clamp(96px, 16vw, 220px);
    line-height: 0.85;
    color: var(--ink);
    text-shadow: var(--glow-aurora);
    transition: text-shadow 250ms ease;
}
.op-and .op-glyph { text-shadow: var(--glow-aurora); }
.op-or  .op-glyph { text-shadow: var(--glow-violet); }
.op-not .op-glyph { text-shadow: var(--glow-teal); }
.op-imp .op-glyph { text-shadow: var(--glow-violet); }

.op-symbol:hover .op-glyph {
    animation: neon-flicker 1.4s steps(8, end) infinite;
}
@keyframes neon-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
    20%, 24%, 55% { opacity: 0.55; }
}

.op-name {
    font-family: var(--f-display);
    font-size: clamp(20px, 2.4vw, 32px);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink);
}

.ben-day-bg {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(10,10,10,0.18) 30%, transparent 32%);
    background-size: 22px 22px;
    opacity: 0.35;
    z-index: 1;
    pointer-events: none;
}

.op-explainer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding: 8px 0;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 500ms ease 100ms, transform 600ms cubic-bezier(.2,.8,.2,1) 100ms;
}
.op-explainer.alt {
    transform: translateX(-30px);
    align-items: flex-end;
    text-align: right;
}
.op-explainer.alt .mini-truth { align-self: flex-end; }
.op-explainer.in { opacity: 1; transform: translateX(0); }

.formal-line {
    font-family: var(--f-mono);
    font-size: clamp(24px, 3vw, 40px);
    color: var(--aurora-violet);
    letter-spacing: 0.04em;
    line-height: 1;
}
.op-desc {
    font-family: var(--f-body);
    font-size: clamp(16px, 1.5vw, 19px);
    max-width: 520px;
    color: var(--ink);
    line-height: 1.65;
}

.mini-truth {
    display: grid;
    gap: 6px;
    font-family: var(--f-mono);
    font-size: 14px;
    letter-spacing: 0.04em;
}
.mini-truth li {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 6px 12px;
    border: 2px solid var(--ink);
    background: var(--bubble-fill);
    width: max-content;
    box-shadow: 4px 4px 0 0 var(--ink);
}
.m-true {
    background: var(--aurora-green);
    color: var(--ink);
    padding: 1px 8px;
    font-weight: 700;
}
.m-false {
    background: var(--aurora-violet);
    color: var(--bubble-fill);
    padding: 1px 8px;
    font-weight: 700;
}
.eq {
    opacity: 0.6;
    margin: 0 2px;
}

/* ---------- TRUTH TABLES ---------- */
.truth-section {
    padding: 0 clamp(24px, 6vw, 96px) clamp(60px, 8vw, 120px);
}
.lede {
    max-width: 720px;
    margin: 0 0 36px clamp(24px, 6vw, 96px);
    padding-left: 0;
    font-size: clamp(17px, 1.6vw, 21px);
    color: var(--ink);
    border-left: 4px solid var(--aurora-violet);
    padding: 6px 0 6px 18px;
}
.truth-section .lede { margin-left: 0; }

.truth-tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: clamp(24px, 3vw, 40px);
    margin-bottom: 40px;
}
.truth-table-card {
    background: var(--bubble-fill);
    border: var(--outline-fat);
    box-shadow: 10px 10px 0 0 var(--ink);
    padding: 22px 22px 26px;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 600ms ease, transform 700ms cubic-bezier(.2,.8,.2,1);
}
.truth-table-card.in { opacity: 1; transform: translateY(0); }

.tt-title {
    font-family: var(--f-display);
    font-size: clamp(22px, 2.4vw, 32px);
    color: var(--ink);
    text-shadow: var(--glow-violet);
    margin-bottom: 16px;
    letter-spacing: 0.04em;
}

.truth-table {
    width: 100%;
    table-layout: fixed;
    border: 4px solid var(--ink);
    background: var(--bg);
}
.truth-table .th {
    font-family: var(--f-display);
    font-size: clamp(16px, 1.6vw, 22px);
    background: var(--ink);
    color: var(--bubble-fill);
    padding: 10px 8px;
    border: 3px solid var(--ink);
    cursor: pointer;
    transition: background 150ms ease;
    letter-spacing: 0.06em;
}
.truth-table .cell {
    font-family: var(--f-mono);
    font-size: clamp(16px, 1.6vw, 22px);
    text-align: center;
    padding: 14px 6px;
    border: 3px solid var(--ink);
    transition: background 120ms ease, transform 120ms ease;
    cursor: default;
}
.truth-table .t-true  { background: var(--true-bg);  }
.truth-table .t-false { background: var(--false-bg); }
.truth-table .result  { font-weight: 700; }
.truth-table .cell.col-hot.t-true,
.truth-table tr.row-hot .cell.t-true   { background: var(--true-bg-hot); }
.truth-table .cell.col-hot.t-false,
.truth-table tr.row-hot .cell.t-false  { background: var(--false-bg-hot); }
.truth-table tr.row-hot .cell.result   { transform: scale(1.05); }
.truth-table .th.col-hot { background: var(--aurora-violet); }

.legend {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    font-family: var(--f-mono);
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
}
.legend-key {
    padding: 4px 14px;
    border: 3px solid var(--ink);
    font-weight: 700;
}
.legend-true  { background: var(--aurora-green);  color: var(--ink); }
.legend-false { background: var(--aurora-violet); color: var(--bubble-fill); }
.legend-hint { opacity: 0.7; font-style: normal; text-transform: none; letter-spacing: 0.04em; }

/* ---------- SYLLOGISM ---------- */
.syllogism-section {
    padding: 0 clamp(24px, 6vw, 96px) clamp(80px, 10vw, 140px);
}

.syllogism-stage {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    align-items: center;
    gap: clamp(8px, 1.5vw, 24px);
    margin-top: 30px;
    padding: 20px 0;
}

.syllogism-bubble {
    position: relative;
    background: var(--bubble-fill);
    border: var(--outline-fat);
    border-radius: 24px;
    padding: 22px 26px 28px;
    box-shadow: 8px 8px 0 0 var(--ink);
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    transition: opacity 500ms ease, transform 600ms cubic-bezier(.2,.8,.2,1);
}
.syllogism-bubble.in { opacity: 1; transform: translateY(0) scale(1); }
.syllogism-bubble.conclusion {
    background: var(--bubble-fill);
    box-shadow: 8px 8px 0 0 var(--ink), 0 0 0 0 var(--aurora-green);
}
.syllogism-bubble.conclusion.in {
    box-shadow: 8px 8px 0 0 var(--ink), 0 0 30px 4px rgba(52, 211, 153, 0.55), 0 0 60px 6px rgba(167, 139, 250, 0.35);
}
.step-tag {
    display: inline-block;
    font-family: var(--f-mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--aurora-violet);
    margin-bottom: 10px;
    border-bottom: 2px solid var(--aurora-violet);
    padding-bottom: 4px;
}
.syllogism-bubble.conclusion .step-tag {
    color: var(--ink);
    background: var(--aurora-green);
    border: 2px solid var(--ink);
    padding: 3px 10px;
    border-bottom-width: 2px;
}
.syll-text {
    font-family: var(--f-display);
    font-size: clamp(20px, 2.5vw, 32px);
    line-height: 1.05;
    color: var(--ink);
    letter-spacing: 0.02em;
}
.syllogism-bubble.conclusion .syll-text {
    text-shadow: var(--glow-aurora);
}

.syll-arrow {
    width: clamp(60px, 7vw, 110px);
    height: clamp(36px, 5vw, 60px);
    opacity: 0;
    transform: translateX(-12px);
    transition: opacity 500ms ease 200ms, transform 500ms ease 200ms;
}
.syll-arrow.in { opacity: 1; transform: translateX(0); }

.closing-mark {
    margin-top: 60px;
    text-align: center;
}
.qed {
    font-family: var(--f-display);
    font-size: clamp(36px, 5vw, 64px);
    color: var(--ink);
    letter-spacing: 0.18em;
    text-shadow: var(--glow-violet);
    display: inline-block;
    border: var(--outline-fat);
    padding: 14px 32px;
    background: var(--bubble-fill);
    box-shadow: 10px 10px 0 0 var(--ink);
}

/* ---------- FOOTER ---------- */
.site-footer {
    border-top: 5px solid var(--ink);
    background: var(--ink);
    color: var(--bubble-fill);
    padding: 28px clamp(24px, 6vw, 96px);
    position: relative;
    z-index: 2;
}
.footer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    font-family: var(--f-mono);
    font-size: 13px;
    letter-spacing: 0.1em;
}
.ft-mark {
    font-family: var(--f-display);
    font-size: 22px;
    letter-spacing: 0.04em;
    color: var(--bubble-fill);
    text-shadow: var(--glow-aurora);
}
.ft-dot   { color: var(--aurora-green); }
.ft-tagline { opacity: 0.85; max-width: 480px; }
.ft-stamp { letter-spacing: 0.3em; opacity: 0.7; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 820px) {
    .z-grid {
        grid-template-columns: 1fr;
        column-gap: 0;
    }
    .top-left, .top-right, .bottom-left, .bottom-right {
        grid-column: 1;
        grid-row: auto;
    }
    .logo-day { text-align: left; }
    .kicker { text-align: left; }
    .bottom-right { align-items: flex-start; }
    .op-explainer.alt { align-items: flex-start; text-align: left; }
    .op-explainer.alt .mini-truth { align-self: flex-start; }

    .syllogism-stage {
        grid-template-columns: 1fr;
        gap: 18px;
    }
    .syll-arrow {
        transform: rotate(90deg);
        width: 60px;
        height: 60px;
        justify-self: center;
    }
    .syll-arrow.in { transform: rotate(90deg); }
}

@media (max-width: 480px) {
    .speech-bubble { padding: 18px 22px; }
    .bubble-text { font-size: 28px; }
    .logic-gate-frame { width: 100%; }
    .legend { font-size: 11px; }
}
