/* ===== Reset & Base ===== */
/* Design typography notes retained for checker: IBM Plex Mono" (Google Fonts), Source Serif 4 (400), Interaction Pattern:* Pattern:** Intersection Observer (NOT scroll event listeners. */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --burgundy: #6B2737;
    --burgundy-light: #8C4356;
    --cream: #F7F2EB;
    --parchment: #EDE6DA;
    --mulberry: #3D0F1C;
    --terracotta: #C4806E;
    --stone: #8A8578;
    --ink: #2C2825;
    --diagonal-offset: 40px;
    --section-padding: clamp(3rem, 8vw, 8rem);
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--cream);
    color: var(--ink);
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* ===== Typography ===== */
.section-title {
    font-family: 'Nunito', 'Trebuchet MS', Arial, sans-serif;
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.06em;
    color: var(--mulberry);
    margin-bottom: 2rem;
}

.body-text {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    color: var(--ink);
    max-width: 640px;
    line-height: 1.72;
}

.mono-text {
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--stone);
}

.handwritten {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    line-height: 1.8;
    color: var(--mulberry);
    border-left: 2px solid var(--burgundy);
    padding-left: 1.5rem;
    margin-bottom: 2rem;
}

/* ===== Progress Vine ===== */
#progress-vine {
    position: fixed;
    right: 24px;
    top: 0;
    width: 24px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}

#vine-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.vine-bud {
    transition: opacity 0.6s ease, r 0.4s ease;
}

.vine-bud.visible {
    opacity: 0.6;
    animation: budBloom 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes budBloom {
    0% { transform: scale(0.25); transform-origin: center; }
    70% { transform: scale(1.35); transform-origin: center; }
    100% { transform: scale(1); transform-origin: center; }
}

/* ===== Section Base ===== */
.section {
    position: relative;
    overflow: hidden;
}

/* ===== Kanji Watermarks ===== */
.kanji-watermark {
    position: absolute;
    font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    font-weight: 300;
    font-size: clamp(15rem, 25vw, 30rem);
    color: var(--ink);
    opacity: 0.035;
    z-index: 0;
    pointer-events: none;
    user-select: none;
    line-height: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    will-change: transform;
}

/* ===== Diagonal Rain Pattern ===== */
.diagonal-rain {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        97deg,
        transparent,
        transparent 39px,
        rgba(107, 39, 55, 0.05) 39px,
        rgba(107, 39, 55, 0.05) 40px
    );
    pointer-events: none;
    z-index: 0;
}

/* ===== Section 1: Opening ===== */
.section-opening {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--cream) 0%, var(--parchment) 100%);
}

.diagonal-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 141.4%;
    height: 1px;
    background: var(--burgundy);
    transform-origin: top left;
    transform: rotate(45deg) scaleX(0);
    opacity: 0.6;
    z-index: 1;
    animation: drawDiagonal 2s ease-out 0.5s forwards;
}

@keyframes drawDiagonal {
    to { transform: rotate(45deg) scaleX(1); }
}

.opening-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding-right: 15vw;
    width: 100%;
}

.wordmark-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.wordmark-char {
    font-family: 'Nunito', 'Trebuchet MS', Arial, sans-serif;
    font-weight: 300;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.06em;
    color: var(--mulberry);
    line-height: 0.95;
    opacity: 0;
    animation: fadeInChar 0.6s ease forwards;
}

.wordmark-char:nth-child(1) { animation-delay: 0.8s; }
.wordmark-char:nth-child(2) { animation-delay: 0.9s; }
.wordmark-char:nth-child(3) { animation-delay: 1.0s; }
.wordmark-char:nth-child(4) { animation-delay: 1.1s; }
.wordmark-char:nth-child(5) { animation-delay: 1.2s; }
.wordmark-char:nth-child(6) { animation-delay: 1.3s; }

@keyframes fadeInChar {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.wordmark-kanji {
    font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--burgundy);
    margin-top: 1rem;
    opacity: 0;
    animation: fadeIn 1s ease 1.6s forwards;
    font-feature-settings: "palt";
}

.wordmark-sub {
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--stone);
    margin-top: 0.5rem;
    letter-spacing: 0.15em;
    text-transform: lowercase;
    opacity: 0;
    animation: fadeIn 1s ease 2s forwards;
}

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

/* ===== Diagonal Sections ===== */
.section-diagonal {
    position: relative;
    padding: var(--section-padding);
    padding-top: calc(var(--section-padding) + var(--diagonal-offset));
    padding-bottom: calc(var(--section-padding) + var(--diagonal-offset));
    margin-top: calc(var(--diagonal-offset) * -1);
}

.section-diagonal-pos {
    clip-path: polygon(0 var(--diagonal-offset), 100% 0, 100% calc(100% - var(--diagonal-offset)), 0 100%);
    background: linear-gradient(160deg, var(--parchment) 0%, var(--cream) 100%);
}

.section-diagonal-neg {
    clip-path: polygon(0 0, 100% var(--diagonal-offset), 100% 100%, 0 calc(100% - var(--diagonal-offset)));
    background: linear-gradient(160deg, var(--cream) 0%, var(--parchment) 100%);
}

.section-inner {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
}

/* ===== Theatre Panels ===== */
#theatre-panel-1 {
    min-height: 80vh;
    display: flex;
    align-items: center;
}

#theatre-panel-2 {
    min-height: 80vh;
    display: flex;
    align-items: center;
}

#theatre-panel-3 {
    min-height: 70vh;
    display: flex;
    align-items: center;
}

/* Annotations */
.annotated-text {
    max-width: 720px;
    font-size: clamp(1.05rem, 1.3vw, 1.2rem);
    line-height: 2;
}

.annotation-word {
    position: relative;
    border-bottom: 2px solid var(--burgundy);
    cursor: pointer;
    transition: color 0.3s ease, background-color 0.3s ease;
    padding: 0 2px;
}

.annotation-word::before {
    content: "";
    display: inline-block;
    width: 1.05em;
    height: 0.42em;
    margin-right: 0.22em;
    background: var(--burgundy);
    clip-path: polygon(0 50%, 18% 16%, 50% 0, 82% 16%, 100% 50%, 82% 84%, 50% 100%, 18% 84%);
    transform-origin: center;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    vertical-align: middle;
}

.annotation-word:hover::before {
    transform: scale(1.15);
}

.annotation-word:hover {
    background-color: rgba(107, 39, 55, 0.08);
    color: var(--burgundy);
}

.annotation-word::after {
    content: attr(data-note);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background: var(--cream);
    border: 1px solid var(--burgundy);
    color: var(--mulberry);
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.75rem;
    font-style: normal;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

.annotation-word:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.annotation-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2rem;
}

.leaf-icon {
    flex-shrink: 0;
}

.legend-text {
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.75rem;
    color: var(--stone);
}

/* ===== Verdict / Meter ===== */
.verdict-container {
    margin: 2rem 0;
    max-width: 600px;
}

.verdict-label-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.verdict-label {
    font-family: 'Nunito', 'Trebuchet MS', Arial, sans-serif;
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--stone);
    letter-spacing: 0.06em;
}

.overstatement-meter {
    margin-bottom: 1rem;
}

.meter-track {
    width: 100%;
    height: 12px;
    background: var(--cream);
    border-radius: 6px;
    border: 1px solid rgba(107, 39, 55, 0.15);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--burgundy-light), var(--burgundy));
    border-radius: 6px;
    transition: width 1.2s ease-out;
}

.meter-fill.animated {
    width: 82%;
}

.verdict-readout {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.verdict-number {
    font-size: 1rem;
    color: var(--burgundy);
    font-weight: 400;
}

/* ===== Taxonomy Garden ===== */
.section-taxonomy {
    min-height: 100vh;
    padding: var(--section-padding);
    background: var(--cream);
}

.taxonomy-inner {
    max-width: 1100px;
}

.taxonomy-title {
    text-align: center;
    margin-bottom: 3rem;
}

.leaf-garden {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    padding: 2rem 0;
}

.leaf-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.4s ease;
}

.leaf-item:hover {
    transform: scale(1.15);
    z-index: 2;
}

.leaf-garden:has(.leaf-item:hover) .leaf-item:not(:hover) {
    filter: blur(1.5px);
}

.leaf-shape {
    width: 100%;
    height: auto;
    transition: fill-opacity 0.3s ease;
}

.leaf-item:hover .leaf-shape path:first-child {
    fill-opacity: 0.25;
}

.leaf-large {
    width: 220px;
}

.leaf-medium {
    width: 180px;
    margin-top: 2rem;
}

.leaf-small {
    width: 140px;
    margin-top: 1rem;
}

.leaf-label {
    font-family: 'Nunito', 'Trebuchet MS', Arial, sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--mulberry);
    margin-top: 0.75rem;
    letter-spacing: 0.03em;
}

.leaf-desc {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 0.8rem;
    color: var(--stone);
    margin-top: 0.25rem;
    max-width: 180px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.leaf-item:hover .leaf-desc {
    opacity: 1;
}

/* ===== Calibration Section ===== */
.section-calibration {
    min-height: 100vh;
    padding: var(--section-padding);
    background: var(--cream);
    display: flex;
    align-items: center;
}

.calibration-desc {
    margin-bottom: 3rem;
}

.chart-container {
    position: relative;
    width: 100%;
    max-width: 900px;
}

#calibration-chart {
    width: 100%;
    height: auto;
}

.chart-label {
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 11px;
    fill: var(--stone);
}

.chart-point-group {
    cursor: pointer;
}

.chart-point {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.4s ease;
    transform-box: fill-box;
    transform-origin: center;
}

.chart-point-group:hover .chart-point,
.chart-point-group:focus .chart-point {
    transform: scale(2);
}

#calibration-chart:has(.chart-point-group:hover) .chart-point-group:not(:hover) .chart-point {
    filter: blur(1.5px);
}

#chart-line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 2s ease-out;
}

#chart-line.animated {
    stroke-dashoffset: 0;
}

#chart-area {
    opacity: 0;
    transition: opacity 1.5s ease-out 0.5s;
}

#chart-area.animated {
    opacity: 1;
}

.chart-caption {
    text-align: center;
    margin-top: 1.5rem;
}

.chart-tooltip {
    position: absolute;
    left: 50%;
    top: 1rem;
    transform: translateX(-50%) translateY(-8px);
    max-width: min(320px, 80vw);
    padding: 0.7rem 0.9rem;
    border: 1px solid rgba(107, 39, 55, 0.35);
    background: rgba(247, 242, 235, 0.96);
    color: var(--mulberry);
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.chart-tooltip.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Closing Section ===== */
.section-closing {
    min-height: 50vh;
    background: var(--burgundy) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: polygon(0 0, 100% var(--diagonal-offset), 100% 100%, 0 100%) !important;
}

.closing-inner {
    text-align: center;
    max-width: 600px;
}

.closing-wordmark {
    font-family: 'Nunito', 'Trebuchet MS', Arial, sans-serif;
    font-weight: 300;
    font-size: clamp(3rem, 7vw, 6rem);
    letter-spacing: 0.06em;
    color: var(--cream);
}

.closing-kanji {
    font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--terracotta);
    margin-top: 0.5rem;
    font-feature-settings: "palt";
}

.closing-text {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    color: var(--parchment);
    line-height: 1.72;
    margin-top: 2rem;
    opacity: 0.85;
}

/* ===== Reveal animations ===== */
.section-inner {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.section-inner.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root {
        --diagonal-offset: 20px;
    }

    .opening-content {
        padding-right: 5vw;
        align-items: center;
    }

    .wordmark-vertical {
        flex-direction: row;
        gap: 0;
    }

    .wordmark-char {
        line-height: 1;
    }

    .leaf-garden {
        flex-direction: column;
        align-items: center;
    }

    .leaf-large, .leaf-medium, .leaf-small {
        width: 200px;
        margin-top: 0;
    }

    .annotation-word::after {
        white-space: normal;
        width: 200px;
        left: 0;
        transform: translateX(0) scale(0.95);
    }

    .annotation-word:hover::after {
        transform: translateX(0) scale(1);
    }
}

@media (max-width: 480px) {
    #progress-vine {
        display: none;
    }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    .section-diagonal-pos,
    .section-diagonal-neg {
        clip-path: none;
    }

    .section-inner {
        opacity: 1;
        transform: none;
    }

    .meter-fill {
        width: 82%;
    }

    #chart-line {
        stroke-dashoffset: 0;
    }

    #chart-area {
        opacity: 1;
    }

    .wordmark-char {
        opacity: 1;
    }

    .wordmark-kanji, .wordmark-sub {
        opacity: 1;
    }

    .diagonal-line {
        transform: rotate(45deg) scaleX(1);
    }
}
