/* ================================================================
   sim-ai.org — Simulation AI Organization
   Editorial-flow / Tufte-style research paper layout
   Palette: Institutional Warmth on cream
   ================================================================ */

:root {
    --paper: #FAF6F0;
    --paper-2: #F0EAE0;
    --ink: #2A2420;
    --body: #3A3430;
    --gold: #C8A882;
    --gold-soft: #E8C8A0;
    --margin: #8A7A6A;
    --stroke: #6A5A4A;
    --fill: #D8CCBA;

    --serif-display: "Playfair Display", "Source Serif 4", Georgia, serif;
    --serif-body: "Source Serif 4", Georgia, "Times New Roman", serif;
    --mono: "Fira Mono", "Menlo", "Consolas", monospace;

    --ease: cubic-bezier(0.4, 0.0, 0.2, 1.0);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--body);
    font-family: var(--serif-body);
    font-size: 17px;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    overflow-x: hidden;
}

/* ----------------------------------------------------------------
   Paper container
   ---------------------------------------------------------------- */
.paper {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 48px 120px;
    position: relative;
}

/* ----------------------------------------------------------------
   Title block (50vh)
   ---------------------------------------------------------------- */
.title-block {
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 0 100px;
}

.title-inner {
    max-width: 680px;
}

.paper-title {
    font-family: var(--serif-display);
    font-weight: 700;
    font-size: 56px;
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 18px;
}

.paper-subtitle {
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    color: var(--margin);
    text-transform: none;
    margin: 0 0 36px;
}

.title-rule {
    display: block;
    width: 120px;
    height: 2px;
    margin: 0 auto 28px;
    overflow: visible;
}

.title-rule.small {
    width: 80px;
    margin: 18px auto 18px;
}

.paper-meta {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--margin);
    margin: 0;
}

.paper-meta .dot {
    margin: 0 10px;
    color: var(--gold);
}

/* ----------------------------------------------------------------
   Section + grid
   ---------------------------------------------------------------- */
.section {
    padding: 0 0 100px;
    position: relative;
}

.section-divider {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 60px 0 64px;
    position: relative;
}

.section-divider::before,
.section-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--gold);
    opacity: 0.55;
}

.section-divider::before { margin-right: 18px; }
.section-divider::after  { margin-left: 18px; }

.section-circle {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    overflow: visible;
}

.section-circle .circle-num {
    font-family: var(--serif-display);
    font-weight: 400;
    font-size: 18px;
    fill: var(--ink);
}

.grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 40px;
    max-width: 880px;
    margin: 0 auto;
    align-items: start;
}

.content {
    max-width: 680px;
}

/* ----------------------------------------------------------------
   Margin column
   ---------------------------------------------------------------- */
.margin {
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    letter-spacing: 0.03em;
    color: var(--margin);
    padding-top: 6px;
    position: sticky;
    top: 32px;
    align-self: start;
}

.margin .margin-label {
    color: var(--ink);
    letter-spacing: 0.1em;
    margin: 0 0 4px;
    font-weight: 500;
}

.margin .margin-meta {
    margin: 0 0 4px;
}

.margin .margin-meta.dim {
    color: var(--margin);
    opacity: 0.85;
}

.sparkline {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed rgba(138, 122, 106, 0.35);
}

.sparkline svg {
    width: 100px;
    height: 22px;
    display: block;
}

.sparkline-label {
    display: block;
    font-size: 11px;
    color: var(--margin);
    margin-top: 4px;
    letter-spacing: 0.04em;
}

/* ----------------------------------------------------------------
   Body text
   ---------------------------------------------------------------- */
.section-title {
    font-family: var(--serif-display);
    font-weight: 500;
    font-size: 42px;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 32px;
}

.lede {
    font-size: 19px;
    line-height: 1.7;
    color: var(--ink);
    margin: 0 0 1.5em;
    font-weight: 400;
}

.content p {
    margin: 0 0 1.5em;
    font-size: 17px;
    line-height: 1.8;
    color: var(--body);
}

.content p em {
    font-style: italic;
    color: var(--ink);
}

/* ----------------------------------------------------------------
   Figures
   ---------------------------------------------------------------- */
.figure {
    margin: 48px 0 56px;
    padding: 24px 24px 18px;
    background: var(--paper-2);
    border: 1px solid rgba(200, 168, 130, 0.35);
    border-radius: 2px;
    position: relative;
}

.figure svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.figure figcaption {
    font-family: var(--serif-body);
    font-style: italic;
    font-size: 13px;
    line-height: 1.55;
    color: var(--stroke);
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(106, 90, 74, 0.18);
}

.figure .fig-label {
    font-family: var(--mono);
    font-style: normal;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--gold);
    margin-right: 8px;
    text-transform: uppercase;
}

/* ----------------------------------------------------------------
   Node-link diagram (Section 01)
   ---------------------------------------------------------------- */
.node-link .edge {
    fill: none;
    stroke: var(--stroke);
    stroke-width: 1;
    opacity: 0.75;
}

.node-link .node circle {
    fill: var(--paper);
    stroke: var(--stroke);
    stroke-width: 1.5;
}

.node-link .node:nth-child(2) circle,
.node-link .node:nth-child(4) circle {
    fill: var(--fill);
}

.node-link .node-label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    fill: var(--stroke);
    text-anchor: middle;
}

/* path-draw animation for edges */
.node-link .edge {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
}

.node-link.in-view .edge {
    animation: draw 1.5s var(--ease) forwards;
}

.node-link.in-view .edge:nth-child(1) { animation-delay: 0.0s; }
.node-link.in-view .edge:nth-child(2) { animation-delay: 0.2s; }
.node-link.in-view .edge:nth-child(3) { animation-delay: 0.4s; }
.node-link.in-view .edge:nth-child(4) { animation-delay: 0.6s; }
.node-link.in-view .edge:nth-child(5) { animation-delay: 0.8s; }
.node-link.in-view .edge:nth-child(6) { animation-delay: 1.0s; }
.node-link.in-view .edge:nth-child(7) { animation-delay: 1.2s; }
.node-link.in-view .edge:nth-child(8) { animation-delay: 1.4s; }
.node-link.in-view .edge:nth-child(9) { animation-delay: 1.6s; }
.node-link.in-view .edge:nth-child(10){ animation-delay: 1.8s; }

.node-link .node {
    opacity: 0;
    transform-origin: center;
}

.node-link.in-view .node {
    animation: nodePop 0.6s var(--ease) forwards;
}

.node-link.in-view .node:nth-of-type(1) { animation-delay: 0.4s; }
.node-link.in-view .node:nth-of-type(2) { animation-delay: 0.7s; }
.node-link.in-view .node:nth-of-type(3) { animation-delay: 1.0s; }
.node-link.in-view .node:nth-of-type(4) { animation-delay: 1.3s; }
.node-link.in-view .node:nth-of-type(5) { animation-delay: 1.6s; }
.node-link.in-view .node:nth-of-type(6) { animation-delay: 1.9s; }
.node-link.in-view .node:nth-of-type(7) { animation-delay: 2.2s; }
.node-link.in-view .node:nth-of-type(8) { animation-delay: 2.5s; }

@keyframes draw {
    to { stroke-dashoffset: 0; }
}

@keyframes nodePop {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ----------------------------------------------------------------
   Section 02 schematic
   ---------------------------------------------------------------- */
.schematic .stage rect {
    fill: var(--paper);
    stroke: var(--stroke);
    stroke-width: 1;
}

.schematic .stage.adjudication rect {
    fill: var(--fill);
    stroke: var(--stroke);
    stroke-width: 1;
}

.schematic .stage-title {
    font-family: var(--serif-display);
    font-weight: 500;
    font-size: 14px;
    fill: var(--ink);
    text-anchor: middle;
}

.schematic .stage-title.small {
    font-size: 12px;
}

.schematic .stage-sub {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    fill: var(--margin);
    text-anchor: middle;
}

.schematic .stage-sub.small {
    font-size: 9px;
}

.schematic .flow {
    fill: none;
    stroke: var(--stroke);
    stroke-width: 1;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.schematic.in-view .flow {
    animation: draw 1.3s var(--ease) forwards;
}

.schematic.in-view .flow:nth-child(1) { animation-delay: 0.2s; }
.schematic.in-view .flow:nth-child(2) { animation-delay: 0.4s; }
.schematic.in-view .flow:nth-child(3) { animation-delay: 0.6s; }
.schematic.in-view .flow:nth-child(4) { animation-delay: 0.8s; }
.schematic.in-view .flow:nth-child(5) { animation-delay: 1.0s; }
.schematic.in-view .flow:nth-child(6) { animation-delay: 1.2s; }

.schematic .leader {
    stroke: var(--margin);
    stroke-width: 0.5;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
}

.schematic.in-view .leader {
    animation: draw 0.8s var(--ease) forwards;
    animation-delay: 1.4s;
}

.schematic .anno-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.05em;
    fill: var(--margin);
    opacity: 0;
}

.schematic.in-view .anno-label {
    animation: fadeIn 0.6s var(--ease) forwards;
    animation-delay: 1.6s;
}

.schematic .dim-line,
.schematic .dim-tick {
    stroke: var(--margin);
    stroke-width: 0.5;
    opacity: 0;
}

.schematic.in-view .dim-line,
.schematic.in-view .dim-tick {
    animation: fadeIn 0.5s var(--ease) forwards;
    animation-delay: 1.7s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ----------------------------------------------------------------
   Calibration loop diagram
   ---------------------------------------------------------------- */
.calibration-loop .cal-node circle {
    fill: var(--paper);
    stroke: var(--stroke);
    stroke-width: 1.25;
}

.calibration-loop .cal-node.accent circle {
    fill: var(--gold-soft);
    stroke: var(--gold);
    stroke-width: 1.5;
}

.calibration-loop .cal-label {
    font-family: var(--serif-display);
    font-style: italic;
    font-size: 14px;
    fill: var(--ink);
    text-anchor: middle;
}

.calibration-loop .cal-sub {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    fill: var(--margin);
    text-anchor: middle;
}

.calibration-loop .edge {
    fill: none;
    stroke: var(--stroke);
    stroke-width: 1;
    stroke-dasharray: 280;
    stroke-dashoffset: 280;
}

.calibration-loop.in-view .edge {
    animation: draw 1.4s var(--ease) forwards;
}

.calibration-loop.in-view .edge:nth-child(1) { animation-delay: 0.2s; }
.calibration-loop.in-view .edge:nth-child(2) { animation-delay: 0.6s; }
.calibration-loop.in-view .edge:nth-child(3) { animation-delay: 1.0s; }
.calibration-loop.in-view .edge:nth-child(4) { animation-delay: 1.4s; }

.calibration-loop .cal-node {
    opacity: 0;
}

.calibration-loop.in-view .cal-node {
    animation: fadeIn 0.6s var(--ease) forwards;
}

.calibration-loop.in-view .cal-node:nth-of-type(1) { animation-delay: 0.0s; }
.calibration-loop.in-view .cal-node:nth-of-type(2) { animation-delay: 0.4s; }
.calibration-loop.in-view .cal-node:nth-of-type(3) { animation-delay: 0.8s; }
.calibration-loop.in-view .cal-node:nth-of-type(4) { animation-delay: 1.2s; }

/* ----------------------------------------------------------------
   Callout block
   ---------------------------------------------------------------- */
.callout {
    margin: 36px 0 36px;
    padding: 22px 26px 22px 28px;
    background: var(--gold-soft);
    border-left: 2px solid var(--gold);
    border-radius: 1px;
}

.callout-tag {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    color: var(--stroke);
    margin: 0 0 8px;
}

.callout-text {
    font-family: var(--serif-display);
    font-style: italic;
    font-weight: 400;
    font-size: 19px;
    line-height: 1.55;
    color: var(--ink);
    margin: 0;
}

/* ----------------------------------------------------------------
   Section 03 — annotated paragraphs (Tufte sidenotes)
   ---------------------------------------------------------------- */
.content.annotated {
    position: relative;
}

.content.annotated p[data-anno] {
    position: relative;
}

.anno-anchor {
    position: absolute;
    left: -8px;
    top: 0.85em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    transform: translateX(-100%) scale(0);
    transition: transform 0.5s var(--ease);
}

.content.annotated.in-view .anno-anchor {
    transform: translateX(-100%) scale(1);
}

.anno-notes {
    pointer-events: none;
}

.anno-note {
    position: absolute;
    width: 200px;
    left: -240px;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.55;
    letter-spacing: 0.02em;
    color: var(--margin);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.anno-note.visible {
    opacity: 1;
    transform: translateY(0);
}

.anno-note .anno-num {
    display: inline-block;
    color: var(--gold);
    font-weight: 500;
    margin-right: 6px;
}

.anno-note .anno-body em {
    font-style: italic;
    color: var(--stroke);
}

/* annotation leader line drawn with pseudo-element */
.anno-note::after {
    content: "";
    position: absolute;
    top: 7px;
    right: -36px;
    width: 0;
    height: 0.5px;
    background: var(--margin);
    transition: width 0.7s var(--ease) 0.1s;
}

.anno-note.visible::after {
    width: 32px;
}

/* dot at margin source */
.anno-note::before {
    content: "";
    position: absolute;
    top: 5px;
    right: -42px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--gold);
    opacity: 0;
    transition: opacity 0.4s var(--ease) 0.4s;
}

.anno-note.visible::before {
    opacity: 1;
}

/* ----------------------------------------------------------------
   Scroll-fade for paragraphs and figures
   ---------------------------------------------------------------- */
.fade-up {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
    will-change: opacity, transform;
}

.fade-up.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Title-rule path-draw */
.title-rule .draw-rule {
    stroke-dasharray: 130;
    stroke-dashoffset: 130;
    animation: drawRule 1.5s var(--ease) 0.4s forwards;
}

.title-rule.small .draw-rule {
    stroke-dasharray: 90;
    stroke-dashoffset: 90;
}

@keyframes drawRule {
    to { stroke-dashoffset: 0; }
}

/* Section circle path-draw */
.section-circle .draw-circle {
    stroke-dasharray: 150;
    stroke-dashoffset: 150;
}

.section-divider.in-view .section-circle .draw-circle {
    animation: drawRule 1.2s var(--ease) forwards;
}

.section-circle .circle-num {
    opacity: 0;
}

.section-divider.in-view .section-circle .circle-num {
    animation: fadeIn 0.6s var(--ease) 0.9s forwards;
}

/* ----------------------------------------------------------------
   Persistent left progress rail
   ---------------------------------------------------------------- */
.progress-rail {
    position: fixed;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    width: 140px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--margin);
    letter-spacing: 0.04em;
    user-select: none;
    pointer-events: none;
}

.rail-track {
    position: absolute;
    left: 6px;
    top: 0;
    width: 1px;
    height: 100%;
    background: rgba(138, 122, 106, 0.3);
}

.rail-fill {
    width: 1px;
    height: 0;
    background: var(--gold);
    transition: height 0.25s linear;
}

.rail-markers {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
    height: 240px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.rail-marker {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.marker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--paper);
    border: 1px solid var(--margin);
    transition: background 0.35s var(--ease), border-color 0.35s var(--ease), transform 0.35s var(--ease);
    flex-shrink: 0;
    margin-left: 2px;
}

.rail-marker.active .marker-dot {
    background: var(--gold);
    border-color: var(--gold);
    transform: scale(1.15);
}

.rail-marker.passed .marker-dot {
    background: var(--gold);
    border-color: var(--gold);
}

.marker-label {
    font-size: 10px;
    color: var(--margin);
    opacity: 0.65;
    transition: opacity 0.3s var(--ease), color 0.3s var(--ease);
}

.rail-marker.active .marker-label {
    opacity: 1;
    color: var(--ink);
}

.rail-current {
    position: absolute;
    left: 0;
    bottom: -56px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rail-current-label {
    font-size: 9px;
    letter-spacing: 0.16em;
    color: var(--margin);
    opacity: 0.7;
    text-transform: uppercase;
}

.rail-current-value {
    font-family: var(--serif-display);
    font-size: 22px;
    color: var(--ink);
    line-height: 1;
}

@media (max-width: 1100px) {
    .progress-rail { display: none; }
}

/* ----------------------------------------------------------------
   Colophon
   ---------------------------------------------------------------- */
.colophon {
    min-height: 30vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 0 40px;
    border-top: 1px solid rgba(200, 168, 130, 0.3);
    margin-top: 60px;
}

.colophon-line {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--margin);
    letter-spacing: 0.06em;
    margin: 0 0 6px;
}

.colophon-meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--margin);
    letter-spacing: 0.04em;
    margin: 4px 0;
}

.colophon-meta.dim {
    opacity: 0.7;
    margin-top: 16px;
}

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 880px) {
    .paper { padding: 0 28px 100px; }
    .grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .margin {
        position: relative;
        top: 0;
        border-bottom: 1px dashed rgba(138, 122, 106, 0.3);
        padding-bottom: 16px;
    }
    .anno-note {
        position: relative;
        left: 0;
        width: 100%;
        margin: 12px 0 0;
        padding-left: 12px;
        border-left: 2px solid var(--gold-soft);
        opacity: 0;
        transform: translateY(6px);
    }
    .anno-note::after,
    .anno-note::before {
        display: none;
    }
    .paper-title { font-size: 42px; }
    .section-title { font-size: 32px; }
    .lede { font-size: 17px; }
    .figure { padding: 16px; }
}

@media (max-width: 520px) {
    .paper { padding: 0 18px 80px; }
    .paper-title { font-size: 34px; }
    .section-title { font-size: 26px; }
    .callout-text { font-size: 16px; }
}
