/* ============================================================
   ronri.day — 論理 — The Architecture of Reasoning
   Stylesheet
   ============================================================ */

/* ---- Tokens ---- */
:root {
    --c-midnight-navy:    #0A1628;
    --c-theorem-slate:    #132238;
    --c-notation-cyan:    #64DFDF;
    --c-blueprint-teal:   #3A8F9E;
    --c-parchment-silver: #B8C0CC;
    --c-logic-gray:       #5A6577;
    --c-proof-gold:       #D4A84B;
    --c-axiom-blue:       #1B3A5C;

    --f-formal:  "Fira Code", ui-monospace, "SF Mono", Menlo, monospace;
    --f-prose:   "Cormorant Garamond", "Lora", Georgia, serif;
    --f-section: "Space Grotesk", "Inter", system-ui, sans-serif;
    --f-symbol:  "Noto Sans Math", "Fira Code", monospace;

    --content-pad: clamp(24px, 5vw, 96px);
    --rail-step-w: 560px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--c-midnight-navy);
    color: var(--c-parchment-silver);
    font-family: var(--f-prose);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
html { scroll-behavior: smooth; }
body {
    overflow-x: hidden;
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.5;
}
p, h1, h2, h3, h4, ul, ol { margin: 0; padding: 0; }

/* ---- Site shell + atmosphere ---- */
.site-shell {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.atmosphere {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.atmo-symbol {
    position: absolute;
    font-family: var(--f-symbol);
    color: var(--c-notation-cyan);
    opacity: 0.06;
    line-height: 1;
    user-select: none;
    animation: pulse 4s ease-in-out infinite;
}
.atmo-symbol-1 { top: 4vh;   left: 6vw;   font-size: clamp(180px, 28vw, 460px); animation-delay: 0s; }
.atmo-symbol-2 { top: 70vh;  left: 70vw;  font-size: clamp(160px, 24vw, 380px); animation-delay: 0.6s; }
.atmo-symbol-3 { top: 160vh; left: 8vw;   font-size: clamp(140px, 22vw, 360px); animation-delay: 1.2s; }
.atmo-symbol-4 { top: 230vh; left: 60vw;  font-size: clamp(160px, 26vw, 420px); animation-delay: 1.8s; }
.atmo-symbol-5 { top: 320vh; left: 12vw;  font-size: clamp(180px, 30vw, 480px); animation-delay: 2.4s; }
.atmo-symbol-6 { top: 420vh; left: 64vw;  font-size: clamp(200px, 34vw, 520px); animation-delay: 3.0s; }

@keyframes pulse {
    0%, 100% { opacity: 0.04; }
    50%      { opacity: 0.08; }
}

/* ---- Header ---- */
.site-header {
    position: relative;
    z-index: 2;
    padding: clamp(28px, 4vw, 64px) var(--content-pad);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 32px;
    flex-wrap: wrap;
}

.wordmark {
    display: flex;
    align-items: baseline;
    gap: 18px;
}
.wordmark-kanji {
    font-family: var(--f-symbol);
    font-size: clamp(22px, 2.2vw, 28px);
    color: var(--c-notation-cyan);
    letter-spacing: 0.08em;
}
.wordmark-roman {
    font-family: var(--f-section);
    font-weight: 500;
    font-size: clamp(14px, 1.2vw, 16px);
    color: var(--c-parchment-silver);
    letter-spacing: 0.18em;
    text-transform: lowercase;
}

.meta-line {
    font-family: var(--f-formal);
    font-size: 12px;
    color: var(--c-logic-gray);
    letter-spacing: 0.08em;
    display: flex;
    gap: 12px;
    align-items: baseline;
    flex-wrap: wrap;
}
.meta-divider { color: var(--c-blueprint-teal); }

/* ---- Tier shared ---- */
.tier {
    position: relative;
    z-index: 1;
    padding: clamp(40px, 6vw, 96px) var(--content-pad);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}
.tier.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.tier-label {
    display: flex;
    align-items: baseline;
    gap: 18px;
    margin-bottom: clamp(32px, 5vw, 80px);
    border-bottom: 1px solid var(--c-axiom-blue);
    padding-bottom: 18px;
}
.tier-numeral {
    font-family: var(--f-formal);
    font-size: clamp(20px, 2vw, 26px);
    color: var(--c-notation-cyan);
    letter-spacing: 0.1em;
}
.tier-name {
    font-family: var(--f-section);
    font-weight: 500;
    font-size: clamp(36px, 5vw, 60px);
    color: var(--c-blueprint-teal);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ---- Tier 1: Axioms ---- */
.tier-1 {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.tier-1-frame {
    position: relative;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
        "p1   p2"
        "conn conn"
        "c1   c1";
    gap: clamp(40px, 8vw, 120px);
    align-items: start;
    justify-items: center;
    padding: clamp(32px, 6vw, 80px) 0;
}

.inference-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}
.ifn-line {
    fill: none;
    stroke: var(--c-notation-cyan);
    stroke-width: 1;
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 1.6s ease;
    opacity: 0.55;
}
.tier-1.is-visible .ifn-line { stroke-dashoffset: 0; }
.tier-1.is-visible .ifn-line-b { transition-delay: 0.3s; }
.tier-1.is-visible .ifn-line-c { transition-delay: 0.5s; }

.axiom {
    position: relative;
    z-index: 2;
    max-width: 460px;
    text-align: center;
    padding: 24px;
}
.axiom-p1        { grid-area: p1;   justify-self: end;   text-align: right; }
.axiom-p2        { grid-area: p2;   justify-self: start; text-align: left; }
.axiom-connective{ grid-area: conn; }
.axiom-c1        { grid-area: c1; }

.axiom-tag {
    display: inline-block;
    font-family: var(--f-formal);
    font-size: 11px;
    color: var(--c-logic-gray);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 18px;
}
.axiom .formula {
    font-family: var(--f-formal);
    font-size: clamp(22px, 2.6vw, 36px);
    color: var(--c-notation-cyan);
    line-height: 1.3;
    margin-bottom: 14px;
}
.axiom .prose {
    font-family: var(--f-prose);
    font-weight: 300;
    font-size: clamp(15px, 1.2vw, 18px);
    color: var(--c-parchment-silver);
    line-height: 1.55;
    font-style: italic;
}

.connective-glyph {
    font-family: var(--f-symbol);
    font-size: clamp(48px, 6vw, 80px);
    color: var(--c-blueprint-teal);
    line-height: 1;
}

.tier-footnote {
    margin-top: 48px;
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}
.footnote-rule {
    font-family: var(--f-formal);
    font-size: 11px;
    color: var(--c-logic-gray);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ---- Tier 2: Propositions ---- */
.tier-2 {
    min-height: 120vh;
    background: linear-gradient(
        to bottom,
        var(--c-midnight-navy) 0%,
        rgba(19, 34, 56, 0.4) 50%,
        var(--c-midnight-navy) 100%
    );
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(140px, auto);
    gap: clamp(24px, 3vw, 48px);
    align-items: stretch;
}

.bento-cell {
    background: linear-gradient(
        145deg,
        rgba(19, 34, 56, 0.7) 0%,
        rgba(19, 34, 56, 0.35) 100%
    );
    padding: clamp(20px, 2.4vw, 36px);
    position: relative;
    transition: background 0.5s ease, transform 0.5s ease;
}
.bento-cell:hover {
    background: linear-gradient(
        145deg,
        rgba(27, 58, 92, 0.8) 0%,
        rgba(19, 34, 56, 0.55) 100%
    );
    transform: translateY(-2px);
}

.cell-mp { grid-column: span 4; }
.cell-mt { grid-column: span 4; grid-column-start: 8; }
.cell-tt { grid-column: span 5; grid-row: span 2; grid-column-start: 1; }
.cell-ds { grid-column: span 3; grid-column-start: 7; }
.cell-dm { grid-column: span 3; grid-column-start: 10; }
.cell-hs { grid-column: span 7; grid-column-start: 6; }

.cell-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid rgba(100, 223, 223, 0.18);
    padding-bottom: 14px;
    margin-bottom: 22px;
}
.cell-tag {
    font-family: var(--f-section);
    font-weight: 500;
    font-size: clamp(13px, 1vw, 15px);
    color: var(--c-blueprint-teal);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.cell-id {
    font-family: var(--f-formal);
    font-size: 11px;
    color: var(--c-logic-gray);
    letter-spacing: 0.1em;
}

.cell-body { margin-bottom: 18px; }
.cell-body .formula {
    font-family: var(--f-formal);
    font-size: clamp(18px, 1.6vw, 24px);
    color: var(--c-notation-cyan);
    line-height: 1.6;
}
.cell-body .formula-conclusion {
    color: var(--c-parchment-silver);
}

.inference-rule {
    border: 0;
    height: 1px;
    background: var(--c-notation-cyan);
    margin: 12px 0;
    width: 0;
    opacity: 0.7;
    transition: width 1.2s ease;
}
.bento-cell.is-visible .inference-rule { width: 100%; }

.cell-prose {
    font-family: var(--f-prose);
    font-weight: 300;
    font-size: clamp(14px, 1.05vw, 17px);
    color: var(--c-parchment-silver);
    line-height: 1.55;
    font-style: italic;
    border-top: 1px solid rgba(58, 143, 158, 0.15);
    padding-top: 14px;
}

/* Floating connectives between cells */
.floating-connective {
    grid-column: span 1;
    align-self: center;
    justify-self: center;
    font-family: var(--f-symbol);
    font-size: clamp(36px, 4vw, 60px);
    color: var(--c-blueprint-teal);
    opacity: 0.5;
    animation: pulse-conn 4s ease-in-out infinite;
}
.fc-1 { grid-column: span 1; }
.fc-2 { grid-column: span 2; grid-column-start: 6; grid-row: 2; align-self: center; }
.fc-3 { grid-column: span 1; grid-column-start: 5; grid-row: 3; align-self: center; }

@keyframes pulse-conn {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.6; }
}

/* Truth table */
.truth-table {
    border-collapse: collapse;
    width: 100%;
    font-family: var(--f-formal);
    font-size: 13px;
    margin-top: 8px;
}
.truth-table th {
    color: var(--c-blueprint-teal);
    font-weight: 500;
    padding: 8px 10px;
    text-align: center;
    border-bottom: 1px solid rgba(100, 223, 223, 0.25);
    letter-spacing: 0.08em;
}
.truth-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid rgba(10, 22, 40, 0.6);
    color: var(--c-notation-cyan);
}
.truth-table .tt-true {
    background: var(--c-axiom-blue);
    color: var(--c-notation-cyan);
}
.truth-table .tt-false {
    background: var(--c-midnight-navy);
    color: var(--c-logic-gray);
}

/* ---- Tier 3: The Chain (horizontal scroll) ---- */
.tier-3 {
    min-height: 150vh;
    padding-bottom: 0;
}

.tier-label-static {
    margin-bottom: 32px;
}

.chain-intro {
    max-width: 720px;
    margin: 0 auto clamp(32px, 4vw, 64px);
    text-align: center;
}
.chain-claim {
    font-family: var(--f-formal);
    font-size: clamp(28px, 3.6vw, 48px);
    color: var(--c-notation-cyan);
    margin-bottom: 18px;
    letter-spacing: 0.04em;
}
.chain-intro .prose {
    font-family: var(--f-prose);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(16px, 1.4vw, 20px);
    color: var(--c-parchment-silver);
    margin-bottom: 24px;
}
.chain-hint {
    font-family: var(--f-formal);
    font-size: 12px;
    color: var(--c-blueprint-teal);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    animation: chain-hint-pulse 2.4s ease-in-out infinite;
}
@keyframes chain-hint-pulse {
    0%, 100% { transform: translateX(0); opacity: 0.7; }
    50%      { transform: translateX(8px); opacity: 1; }
}

.chain-track {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--c-blueprint-teal) var(--c-theorem-slate);
    padding: 40px 0 60px;
    -webkit-overflow-scrolling: touch;
}
.chain-track::-webkit-scrollbar { height: 6px; }
.chain-track::-webkit-scrollbar-track { background: var(--c-theorem-slate); }
.chain-track::-webkit-scrollbar-thumb { background: var(--c-blueprint-teal); }

.chain-rail {
    position: relative;
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 80px clamp(40px, 8vw, 120px);
    width: max-content;
    min-height: 420px;
}

.proof-tree {
    position: absolute;
    top: 50%;
    left: 0;
    width: 4200px;
    height: 300px;
    transform: translateY(-50%);
    pointer-events: none;
    overflow: visible;
}
.tree-path,
.tree-branch {
    fill: none;
    stroke: var(--c-blueprint-teal);
    stroke-width: 1;
    opacity: 0.6;
}
#treePath {
    stroke-dasharray: 4000;
    stroke-dashoffset: 4000;
    transition: stroke-dashoffset 0.2s linear;
}
.tree-branch {
    stroke: var(--c-notation-cyan);
    opacity: 0.4;
}
.tree-node {
    fill: var(--c-midnight-navy);
    stroke: var(--c-notation-cyan);
    stroke-width: 1.5;
}
.tree-node-final {
    fill: var(--c-proof-gold);
    stroke: var(--c-proof-gold);
}

.chain-step {
    flex: 0 0 auto;
    width: var(--rail-step-w);
    max-width: 80vw;
    background: rgba(10, 22, 40, 0.85);
    border: 1px solid rgba(100, 223, 223, 0.18);
    padding: clamp(28px, 3vw, 44px);
    scroll-snap-align: center;
    position: relative;
    z-index: 2;
    backdrop-filter: blur(4px);
    transition: border-color 0.4s ease, transform 0.4s ease;
}
.chain-step.is-active {
    border-color: var(--c-notation-cyan);
    transform: translateY(-4px);
}
.chain-step .step-tag {
    display: block;
    font-family: var(--f-formal);
    font-size: 12px;
    color: var(--c-logic-gray);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 16px;
}
.chain-step .formula {
    font-family: var(--f-formal);
    font-size: clamp(22px, 2.4vw, 32px);
    color: var(--c-notation-cyan);
    line-height: 1.4;
    margin-bottom: 16px;
}
.chain-step .prose {
    font-family: var(--f-prose);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(15px, 1.15vw, 18px);
    color: var(--c-parchment-silver);
    line-height: 1.55;
}
.chain-step-final {
    border-color: var(--c-proof-gold);
    background: rgba(212, 168, 75, 0.06);
}
.chain-step-final .formula {
    color: var(--c-proof-gold);
}

.chain-arrow {
    flex: 0 0 auto;
    font-family: var(--f-symbol);
    font-size: clamp(28px, 3vw, 44px);
    color: var(--c-blueprint-teal);
    opacity: 0.6;
    z-index: 2;
}

.chain-progress {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px var(--content-pad) 60px;
    display: flex;
    align-items: center;
    gap: 18px;
}
.chain-progress-track {
    flex: 1;
    height: 1px;
    background: rgba(58, 143, 158, 0.25);
    position: relative;
}
.chain-progress-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    background: var(--c-notation-cyan);
    transition: width 0.2s linear;
}
.chain-progress-label {
    font-family: var(--f-formal);
    font-size: 12px;
    color: var(--c-logic-gray);
    letter-spacing: 0.12em;
    min-width: 60px;
    text-align: right;
}

/* ---- Tier 4: Q.E.D. ---- */
.tier-4 {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    transition: background-color 1.2s ease;
}
.tier-4.is-collapsing {
    background: #000000;
}

.qed-stage {
    position: relative;
    height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qed-tombstone {
    width: 16px;
    height: 16px;
    background: var(--c-proof-gold);
    transform-origin: center;
    transform: scale(1);
    transition: transform 0.15s linear, background-color 0.6s ease;
    z-index: 1;
}
.tier-4.is-collapsing .qed-tombstone {
    background: #000000;
}

.qed-caption {
    position: absolute;
    bottom: -120px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 3;
    pointer-events: none;
}
.qed-kanji {
    font-family: var(--f-symbol);
    font-size: clamp(40px, 4vw, 56px);
    color: var(--c-parchment-silver);
    letter-spacing: 0.18em;
    margin-bottom: 12px;
    opacity: 0.85;
}
.qed-roman {
    font-family: var(--f-section);
    font-weight: 500;
    font-size: clamp(13px, 1.1vw, 16px);
    color: var(--c-blueprint-teal);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.qed-prose {
    font-family: var(--f-prose);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(15px, 1.2vw, 18px);
    color: var(--c-logic-gray);
}

/* ---- Footer ---- */
.site-footer {
    position: relative;
    z-index: 2;
    padding: clamp(40px, 5vw, 80px) var(--content-pad);
    border-top: 1px solid var(--c-axiom-blue);
    background: var(--c-midnight-navy);
}
.colophon {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 18px;
}
.colophon-line {
    font-family: var(--f-formal);
    font-size: 12px;
    color: var(--c-logic-gray);
    letter-spacing: 0.14em;
}
.colophon-line:first-child {
    color: var(--c-notation-cyan);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .tier-1-frame {
        grid-template-columns: 1fr;
        grid-template-areas:
            "p1"
            "p2"
            "conn"
            "c1";
        gap: 48px;
    }
    .axiom-p1, .axiom-p2 { justify-self: center; text-align: center; }

    .bento-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .cell-mp,
    .cell-mt,
    .cell-tt,
    .cell-ds,
    .cell-dm,
    .cell-hs {
        grid-column: 1 / -1;
        grid-row: auto;
    }
    .floating-connective {
        grid-column: 1 / -1;
        grid-row: auto;
        margin: 0 auto;
    }
    .fc-1, .fc-2, .fc-3 {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}

@media (max-width: 768px) {
    .chain-track {
        overflow-x: hidden;
        scroll-snap-type: none;
    }
    .chain-rail {
        flex-direction: column;
        width: 100%;
        gap: 24px;
        padding: 32px var(--content-pad);
        min-height: auto;
    }
    .chain-step {
        width: 100%;
        max-width: 100%;
    }
    .proof-tree { display: none; }
    .chain-arrow {
        transform: rotate(90deg);
    }

    .colophon { justify-content: flex-start; }
}
