/* ============================================
   martiallaw.wiki — Styles
   Japanese-minimal / Gold-black-luxury / Legal decree
   Stacked-sections / Oversized-display typography
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --void-black: #0A0A0A;
    --lacquer-dark: #141414;
    --gold-primary: #C9A84C;
    --gold-bright: #E8D48B;
    --text-primary: #F0EDE4;
    --text-secondary: #8A8578;
    --seal-vermillion: #B83A2A;
    --rule-color: rgba(201, 168, 76, 0.25);
    --margin-left: 120px;
    --content-max: 640px;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--void-black);
    color: var(--text-secondary);
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    line-height: 1.8;
    overflow-x: hidden;
    /* Background grid: 64px squares at 2% opacity */
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(201, 168, 76, 0.02) 0px,
            rgba(201, 168, 76, 0.02) 1px,
            transparent 1px,
            transparent 64px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(201, 168, 76, 0.02) 0px,
            rgba(201, 168, 76, 0.02) 1px,
            transparent 1px,
            transparent 64px
        );
}

::selection {
    background: var(--gold-primary);
    color: var(--void-black);
}

/* --- Chrysanthemum Watermark (fixed behind all content, 3% opacity) --- */
.watermark-chrysanthemum {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
}

.watermark-chrysanthemum svg {
    width: 100%;
    height: 100%;
}

/* --- Navigation Mark (Chrysanthemum, top-right) --- */
.nav-mark {
    position: fixed;
    top: 32px;
    right: 32px;
    z-index: 1000;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.nav-mark:hover {
    opacity: 1;
}

.chrysanthemum {
    width: 40px;
    height: 40px;
    position: relative;
}

.chrysanthemum .petal {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--gold-primary);
    background: transparent;
}

.chrysanthemum .petal:nth-child(1) {
    top: 10px;
    left: 10px;
}

.chrysanthemum .petal:nth-child(2) {
    top: 4px;
    left: 6px;
    opacity: 0.8;
}

.chrysanthemum .petal:nth-child(3) {
    top: 4px;
    left: 14px;
    opacity: 0.7;
}

.chrysanthemum .petal:nth-child(4) {
    top: 14px;
    left: 4px;
    opacity: 0.6;
}

.chrysanthemum .petal:nth-child(5) {
    top: 14px;
    left: 16px;
    opacity: 0.5;
}

/* --- Navigation Overlay --- */
.nav-overlay {
    position: fixed;
    inset: 0;
    background: var(--void-black);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 0 2rem;
}

.nav-link {
    font-family: 'Shippori Mincho', serif;
    font-weight: 800;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--gold-primary);
    text-decoration: none;
    letter-spacing: 0.04em;
    line-height: 1.2;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.nav-link:hover {
    opacity: 1;
    color: var(--gold-bright);
}

/* --- Article Sections (100vh stacked proclamation blocks) --- */
.article-section {
    position: relative;
    min-height: 100vh;
    width: 100%;
    padding: 80px 40px 80px var(--margin-left);
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.article-section[data-bg="void"] {
    background-color: var(--void-black);
}

.article-section[data-bg="lacquer"] {
    background-color: var(--lacquer-dark);
}

/* Section divider rule (gold at 40% opacity) */
.article-section + .article-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(201, 168, 76, 0.4);
}

/* --- Section Micro-Grid Overlay (8-column, shifts per section) --- */
.section-grid-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image: repeating-linear-gradient(
        90deg,
        rgba(201, 168, 76, 0.04) 0px,
        rgba(201, 168, 76, 0.04) 1px,
        transparent 1px,
        transparent calc(100% / 8)
    );
    transform: translateX(var(--grid-offset, 0px));
}

/* --- Margin Line (vertical gold stripe, left edge, 3px) --- */
.margin-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--margin-left) - 16px);
    width: 3px;
    background: rgba(201, 168, 76, 0.25);
    z-index: 3;
}

.margin-line.ripple {
    animation: marginRipple 1.8s ease-out forwards;
}

@keyframes marginRipple {
    0% {
        background: linear-gradient(
            to top,
            rgba(201, 168, 76, 0.25) 0%,
            rgba(201, 168, 76, 0.25) 100%
        );
    }
    10% {
        background: linear-gradient(
            to top,
            rgba(201, 168, 76, 1) 0%,
            rgba(201, 168, 76, 0.6) 8%,
            rgba(201, 168, 76, 0.25) 20%,
            rgba(201, 168, 76, 0.25) 100%
        );
    }
    30% {
        background: linear-gradient(
            to top,
            rgba(201, 168, 76, 0.25) 0%,
            rgba(201, 168, 76, 0.25) 18%,
            rgba(201, 168, 76, 0.6) 28%,
            rgba(201, 168, 76, 1) 35%,
            rgba(201, 168, 76, 0.6) 42%,
            rgba(201, 168, 76, 0.25) 55%,
            rgba(201, 168, 76, 0.25) 100%
        );
    }
    55% {
        background: linear-gradient(
            to top,
            rgba(201, 168, 76, 0.25) 0%,
            rgba(201, 168, 76, 0.25) 45%,
            rgba(201, 168, 76, 0.6) 55%,
            rgba(201, 168, 76, 1) 62%,
            rgba(201, 168, 76, 0.6) 70%,
            rgba(201, 168, 76, 0.25) 82%,
            rgba(201, 168, 76, 0.25) 100%
        );
    }
    80% {
        background: linear-gradient(
            to top,
            rgba(201, 168, 76, 0.25) 0%,
            rgba(201, 168, 76, 0.25) 75%,
            rgba(201, 168, 76, 0.6) 85%,
            rgba(201, 168, 76, 1) 95%,
            rgba(201, 168, 76, 0.6) 100%
        );
    }
    100% {
        background: rgba(201, 168, 76, 0.25);
    }
}

/* --- Section Content --- */
.section-content {
    position: relative;
    z-index: 2;
    max-width: var(--content-max);
}

/* --- Hero Section (Article 0) --- */
.hero-content {
    text-align: left;
    max-width: none;
}

.hero-title {
    font-family: 'Shippori Mincho', serif;
    font-weight: 800;
    font-size: clamp(4rem, 12vw, 10rem);
    color: var(--gold-primary);
    letter-spacing: 0.04em;
    line-height: 0.95;
    margin-bottom: 2rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

.hero-subtitle {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 500;
    font-size: clamp(0.875rem, 1.5vw, 1.125rem);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-secondary);
}

/* --- Barbed Wire (SVG pattern) --- */
.barbed-wire {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    opacity: 0.4;
}

.barbed-wire-top {
    bottom: auto;
    top: 0;
}

.barbed-wire svg {
    width: 100%;
    height: 100%;
}

/* --- Article Header --- */
.article-header {
    display: flex;
    align-items: baseline;
    gap: 2rem;
    margin-bottom: 2rem;
}

.article-label {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 500;
    font-size: clamp(0.875rem, 1.5vw, 1.125rem);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--gold-primary);
}

.article-timestamp {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* --- Section Headlines (oversized Shippori Mincho) --- */
.section-headline {
    font-family: 'Shippori Mincho', serif;
    font-weight: 800;
    font-size: clamp(4rem, 12vw, 10rem);
    color: var(--text-primary);
    letter-spacing: 0.04em;
    line-height: 0.95;
    margin-bottom: 3rem;
}

/* --- Article Body --- */
.article-body {
    max-width: var(--content-max);
}

.article-body p {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.125rem);
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.article-body p:last-child {
    margin-bottom: 0;
}

.article-body p em {
    font-style: italic;
    color: var(--text-primary);
}

/* --- Margin Annotation (monospace in gutter, vertical text) --- */
.margin-annotation {
    position: absolute;
    right: 40px;
    bottom: 80px;
}

.annotation-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.5;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* --- Grid Fragment (bottom-right decorative grid cluster, 12x12 cells at 16px) --- */
.grid-fragment {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 192px;
    height: 192px;
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(201, 168, 76, 0.15) 0px,
            rgba(201, 168, 76, 0.15) 1px,
            transparent 1px,
            transparent 16px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(201, 168, 76, 0.15) 0px,
            rgba(201, 168, 76, 0.15) 1px,
            transparent 1px,
            transparent 16px
        );
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

/* --- Timeline (Article II) --- */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-left: 1rem;
    border-left: none;
    max-width: 720px;
}

.timeline-entry {
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
    padding-left: 1.5rem;
    position: relative;
}

/* Gold bullet */
.timeline-entry::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold-primary);
}

/* Vertical timeline connector using the gold margin stripe concept */
.timeline-entry::after {
    content: '';
    position: absolute;
    left: 2.5px;
    top: calc(0.55em + 6px);
    bottom: -1.5rem;
    width: 1px;
    background: rgba(201, 168, 76, 0.2);
}

.timeline-entry:last-child::after {
    display: none;
}

.timeline-date {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--gold-primary);
    min-width: 4ch;
    flex-shrink: 0;
}

.timeline-location {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    min-width: 200px;
    flex-shrink: 0;
}

.timeline-desc {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* --- Legal Clauses (Article III) --- */
.legal-clauses {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.clause {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.clause-number {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.875rem;
    color: var(--gold-primary);
    flex-shrink: 0;
    padding-top: 0.2em;
    min-width: 2ch;
}

.clause-text {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.125rem);
    line-height: 1.8;
    color: var(--text-secondary);
}

.clause-text strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* --- Quill Illustration (Article IV, right margin) --- */
.quill-illustration {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    z-index: 2;
}

.quill-illustration svg {
    width: 80px;
    height: 220px;
}

/* --- Final Section (Article V) --- */
.final-content {
    text-align: left;
    max-width: var(--content-max);
}

.final-text {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.125rem);
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 4rem;
}

/* --- Seal Stamp (Article V -- single vermillion accent on entire page) --- */
.seal-stamp {
    width: 120px;
    height: 120px;
    margin: 0 0 2rem 0;
    transform: rotate(15deg);
    opacity: 0;
    transition: none;
}

.seal-stamp.visible {
    animation: sealFade 3s ease-out forwards;
}

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

.seal-stamp svg {
    width: 100%;
    height: 100%;
}

/* --- Final Date (IBM Plex Mono) --- */
.final-date {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.875rem;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
}

/* --- Responsive: Tablet --- */
@media (max-width: 768px) {
    :root {
        --margin-left: 24px;
    }

    .article-section {
        padding: 60px 24px;
        min-height: 100vh;
    }

    .margin-line {
        left: 8px;
        width: 2px;
    }

    .hero-title {
        font-size: clamp(2.5rem, 10vw, 5rem);
    }

    .section-headline {
        font-size: clamp(2.5rem, 10vw, 5rem);
    }

    .nav-mark {
        top: 20px;
        right: 20px;
    }

    .timeline {
        max-width: 100%;
    }

    .timeline-entry {
        flex-direction: column;
        gap: 0.25rem;
    }

    .timeline-entry::after {
        display: none;
    }

    .timeline-location {
        min-width: unset;
    }

    .margin-annotation {
        position: relative;
        right: auto;
        bottom: auto;
        margin-top: 3rem;
    }

    .annotation-text {
        writing-mode: horizontal-tb;
    }

    .quill-illustration {
        display: none;
    }

    .grid-fragment {
        width: 100px;
        height: 100px;
    }

    .article-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .watermark-chrysanthemum {
        width: 300px;
        height: 300px;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2rem, 12vw, 3.5rem);
    }

    .section-headline {
        font-size: clamp(2rem, 12vw, 3.5rem);
        margin-bottom: 2rem;
    }

    .nav-link {
        font-size: 1.25rem;
    }

    .clause {
        flex-direction: column;
        gap: 0.5rem;
    }

    .grid-fragment {
        width: 64px;
        height: 64px;
    }
}
