/* ===================================================
   gabs.bar — Forensic examination of value
   Split-ledger with specimen margin
   =================================================== */

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

:root {
    --bg-primary: #FAF6ED;
    --bg-secondary: #F0E8D8;
    --text-primary: #1C1917;
    --text-secondary: #6B5E50;
    --accent-red-brown: #8B3A3A;
    --accent-copper: #5C3D2E;
    --accent-verdigris: #2E6B62;
    --ghost-white: #F5F0E6;
    --ledger-line: #E8E0D0;

    --col-left: 38%;
    --col-margin: 60px;
    --col-right: calc(62% - 60px);
    --content-offset: 8%;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Literata', Georgia, serif;
    font-size: 18px;
    font-weight: 350;
    line-height: 1.8;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Vertical Dividing Rule --- */
.dividing-rule {
    position: fixed;
    left: calc(var(--col-left) - var(--content-offset) / 2);
    top: 0;
    width: 2px;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
}

.dividing-rule line {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: none;
}

.dividing-rule.animate line {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.2s ease-out;
}

.dividing-rule.visible {
    opacity: 1;
}

/* --- CJK Watermarks --- */
.watermark {
    position: fixed;
    right: 2vw;
    font-family: 'Noto Sans KR', 'Noto Sans JP', 'Noto Sans SC', sans-serif;
    font-size: 20vw;
    color: var(--ghost-white);
    pointer-events: none;
    z-index: 1;
    user-select: none;
    line-height: 1;
    opacity: 0;
}

.watermark-1 {
    top: 10vh;
}

.watermark-2 {
    top: 110vh;
}

.watermark-3 {
    top: 210vh;
}

@media (max-width: 1400px) {
    .watermark {
        display: none;
    }
}

@media (min-width: 1401px) {
    .watermark {
        opacity: 1;
    }
}

/* --- Entry Arrow --- */
.entry-arrow {
    position: fixed;
    top: 30px;
    left: calc(var(--col-left) - var(--content-offset) / 2 - 12px);
    z-index: 20;
    opacity: 0;
    transition: opacity 0.6s ease-out 2s;
    cursor: pointer;
}

body.loaded .entry-arrow {
    opacity: 1;
}

body.scrolled .entry-arrow {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-out;
}

/* --- Document Container --- */
.document {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    margin-left: var(--content-offset);
    padding: 120px 40px 80px;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

body.loaded .document {
    opacity: 1;
}

/* --- Specimen Breaks --- */
.specimen-break {
    position: relative;
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    margin: 20px 0;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.specimen-break.visible {
    opacity: 1;
    transform: translateY(0);
}

.specimen-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-right: 16px;
    flex-shrink: 0;
}

.specimen-rule {
    flex: 1;
    height: 4px;
    background-color: var(--accent-copper);
    transition: background-color 0.3s ease;
}

.specimen-break:hover .specimen-rule {
    background-color: #4A3020;
}

/* --- Specimen Section (Split-Ledger) --- */
.specimen-section {
    display: grid;
    grid-template-columns: var(--col-left) var(--col-margin) 1fr;
    gap: 0;
    min-height: 200px;
    padding: 40px 0;
    position: relative;
}

/* --- Price Column (Left) --- */
.price-column {
    position: relative;
    padding-right: 20px;
    line-height: 1.3;
}

.ledger-lines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent calc(1.3 * 3rem - 1px),
        var(--ledger-line) calc(1.3 * 3rem - 1px),
        var(--ledger-line) calc(1.3 * 3rem)
    );
    opacity: 0.6;
}

.price-figure {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(3rem, 8vw, 9rem);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.4s ease-out;
    font-variant-numeric: tabular-nums;
}

.price-figure.visible {
    opacity: 1;
}

.currency {
    font-size: 0.5em;
    vertical-align: super;
    margin-right: 0.05em;
    color: var(--text-secondary);
}

/* --- Stamp Marks --- */
.stamp {
    display: inline-block;
    border: 1.5px solid var(--accent-red-brown);
    border-radius: 4px;
    padding: 4px 12px;
    margin-top: 16px;
    transform: rotate(-2.5deg);
    opacity: 0;
    transition: opacity 0.6s ease-out 0.4s;
    position: relative;
    z-index: 2;
}

.stamp span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-red-brown);
}

.stamp-verified {
    opacity: 0;
}

.stamp-disputed {
    transform: rotate(2deg);
    opacity: 0;
}

.stamp-provisional {
    transform: rotate(-1.5deg);
    opacity: 0;
}

.specimen-section.active .stamp {
    opacity: 0.6;
}

/* --- Specimen Margin (Caliper Marks) --- */
.specimen-margin {
    position: relative;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.caliper-marks {
    width: 100%;
    height: 100%;
    min-height: 180px;
    opacity: 0.4;
    transition: opacity 0.6s ease-out;
}

.caliper-marks .tick {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    transition: stroke-dashoffset 0.8s ease-out;
}

.specimen-section.active .caliper-marks .tick {
    stroke-dashoffset: 0;
}

.caliper-annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    fill: var(--accent-red-brown);
    opacity: 0;
    transition: opacity 0.6s ease-out 0.3s;
}

.specimen-section.active .caliper-annotation {
    opacity: 1;
}

/* Value exceeds price: verdigris */
.specimen-section[data-exceeds="true"].active .caliper-marks .tick {
    stroke: var(--accent-verdigris);
}

.specimen-section[data-exceeds="true"].active .caliper-annotation {
    fill: var(--accent-verdigris);
}

/* Caliper pulse animation */
.specimen-section.active .caliper-marks {
    animation: caliperPulse 1.5s ease-in-out 0.5s 1 forwards;
}

@keyframes caliperPulse {
    0% { opacity: 0.4; }
    40% { opacity: 1.0; }
    100% { opacity: 0.6; }
}

/* --- Value Column (Right) --- */
.value-column {
    padding-left: 20px;
    display: flex;
    align-items: flex-start;
}

.analysis-text {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.specimen-section.active .analysis-text {
    opacity: 1;
    transform: translateY(0);
}

.analysis-text p {
    font-family: 'Literata', Georgia, serif;
    font-size: 18px;
    font-weight: 350;
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 540px;
}

/* --- Price hover reveals caliper marks --- */
.price-figure:hover ~ .caliper-marks,
.specimen-section:hover .caliper-marks {
    opacity: 1;
}

/* --- Closing --- */
.closing {
    text-align: center;
    padding: 80px 0 60px;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.closing.visible {
    opacity: 1;
}

.closing-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.8;
}

/* --- Final specimen break --- */
.specimen-break-final {
    margin-top: 60px;
}

/* ===================================================
   RESPONSIVE: below 768px
   =================================================== */
@media (max-width: 768px) {
    :root {
        --content-offset: 0%;
    }

    .dividing-rule {
        display: none;
    }

    .entry-arrow {
        left: calc(50% - 12px);
    }

    .document {
        margin-left: 0;
        padding: 100px 20px 60px;
    }

    .specimen-section {
        display: block;
    }

    .price-column {
        padding-right: 0;
        padding-bottom: 20px;
        border-left: 2px solid var(--accent-copper);
        padding-left: 16px;
    }

    .price-figure {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }

    .ledger-lines {
        display: none;
    }

    .specimen-margin {
        display: none;
    }

    .value-column {
        padding-left: 0;
        position: relative;
    }

    .analysis-text {
        position: relative;
        padding-left: 0;
    }

    .analysis-text p {
        font-size: 16px;
        max-width: 100%;
    }

    /* Inline caliper annotations on mobile */
    .value-column::before {
        content: attr(data-ratio-label);
        font-family: 'IBM Plex Mono', monospace;
        font-size: 10px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--accent-red-brown);
        display: block;
        margin-bottom: 8px;
    }
}

/* ===================================================
   Parallax for specimen margin (desktop)
   =================================================== */
@media (min-width: 769px) {
    .specimen-margin {
        will-change: transform;
    }
}

/* ===================================================
   Initial load state
   =================================================== */
body {
    opacity: 1;
}

body:not(.loaded) .document,
body:not(.loaded) .entry-arrow,
body:not(.loaded) .dividing-rule {
    opacity: 0;
}
