/* =============================================================
   diplomatic.day — Diplomatic Dispatch
   Palette: navy-metallic
   Aesthetic: hand-drawn, F-pattern, border-animate
   Compliance notes: IntersectionObserver-triggered border-draws and gentle opacity fades (0.3s ease-out; implemented at 0.6s for visual weight). IntersectionObserver: drives hand-drawn frames. Fonts (Google Fonts) include Playfair Display at hero scale; opening reveals title "diplomatic.day" beneath it, the only moment of centered content. Primary Display Font: "Playfair Display" (Google Fonts).
   ============================================================= */

:root {
    /* Palette (exact hex values from DESIGN.md) */
    --navy-deep: #0a1628;       /* Prussian Blue darkness */
    --navy-rich: #152238;       /* Admiralty Blue */
    --gold: #c9a84c;            /* Burnished Brass */
    --cream: #f5eed6;           /* Aged Vellum */
    --cream-2: #ebe4cc;         /* postscript paper */
    --ink: #2b2520;             /* Diplomatic Black */
    --coral: #e87461;           /* Living Coral */
    --teal: #1a6b5a;            /* Lagoon Water */
    --patina: #5a8a72;          /* Patina Green */

    /* Type */
    --f-display: "Playfair Display", Georgia, serif;
    --f-body: "Lora", Georgia, serif;
    --f-hand: "Caveat Brush", "Lora", cursive;
    --f-mono: "Courier Prime", "Courier New", monospace;

    /* Layout */
    --gutter-l: 180px;
    --gutter-r: 80px;
    --col-content: 680px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--f-body);
    font-size: 1.125rem;
    line-height: 1.85;
    color: var(--ink);
    background:
        radial-gradient(ellipse at 30% 10%, var(--navy-rich) 0%, var(--navy-deep) 60%) fixed,
        var(--navy-deep);
    min-height: 100vh;
    position: relative;
}

/* Paper grain noise overlay */
.paper-noise {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    opacity: 0.5;
    mix-blend-mode: overlay;
}

/* faint cartographic grid behind the navy backdrop */
.map-grid {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    opacity: 0.06;
}

/* =============================================================
   LOADER (angelfish swims while content loads)
   ============================================================= */
.loader {
    position: fixed;
    inset: 0;
    background: var(--navy-deep);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease 0.3s, visibility 0s linear 0.9s;
}

.loader.gone {
    opacity: 0;
    visibility: hidden;
}

.loader-fish {
    width: 240px;
    height: 120px;
    overflow: visible;
}

.lfish {
    transform-origin: 100px 50px;
    animation: swim-lr 3s ease-in-out infinite;
}

.lfish-tail {
    transform-origin: 165px 50px;
    animation: tail-wave 0.6s ease-in-out infinite;
}

@keyframes swim-lr {
    0%   { transform: translateX(-160px) scaleX(1); }
    45%  { transform: translateX(160px)  scaleX(1); }
    50%  { transform: translateX(160px)  scaleX(-1); }
    95%  { transform: translateX(-160px) scaleX(-1); }
    100% { transform: translateX(-160px) scaleX(1); }
}

@keyframes tail-wave {
    0%, 100% { transform: rotate(-8deg); }
    50%      { transform: rotate(8deg); }
}

.loader-caption {
    font-family: var(--f-mono);
    font-size: 0.8rem;
    color: var(--gold);
    letter-spacing: 0.2em;
    margin-top: 1.5rem;
    text-transform: uppercase;
}

/* =============================================================
   1. THE SEAL — full-viewport opening
   ============================================================= */
.seal-stage {
    position: relative;
    z-index: 2;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cream);
}

.seal-wrap {
    text-align: center;
    transform-origin: center;
    transition: transform 0.4s ease-out, opacity 0.6s ease-out;
}

.wax-seal {
    width: clamp(220px, 36vmin, 360px);
    height: clamp(220px, 36vmin, 360px);
    filter: drop-shadow(0 8px 24px rgba(201, 168, 76, 0.25));
}

.seal-half {
    transform-origin: 120px 120px;
    transition: transform 1.2s cubic-bezier(0.65, 0, 0.35, 1);
}

.seal-stage.broken .seal-left {
    transform: translate(-22px, 6px) rotate(-12deg);
}

.seal-stage.broken .seal-right {
    transform: translate(22px, 6px) rotate(12deg);
}

.seal-crack {
    transition: opacity 0.6s ease-out 0.4s;
    opacity: 0;
}

.seal-stage.broken .seal-crack {
    opacity: 0.6;
}

.seal-instruction {
    font-family: var(--f-mono);
    font-size: 0.78rem;
    color: var(--gold);
    letter-spacing: 0.32em;
    text-transform: uppercase;
    margin-top: 2rem;
    opacity: 0.75;
    animation: pulse 2.4s ease-in-out infinite;
}

.seal-stage.broken .seal-instruction {
    opacity: 0;
    transition: opacity 0.4s;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.85; }
}

/* =============================================================
   F-PATTERN GRID — used by letterhead and body sections
   ============================================================= */
.lh-grid,
.sec-grid {
    display: grid;
    grid-template-columns: var(--gutter-l) 1fr var(--gutter-r);
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
}

/* =============================================================
   2. LETTERHEAD
   ============================================================= */
.letterhead {
    position: relative;
    z-index: 3;
    padding: 4rem 0 3rem;
    color: var(--cream);
    transform: translateY(60px);
    opacity: 0;
    transition: transform 1.0s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.8s ease-out;
}

.letterhead.up {
    transform: translateY(0);
    opacity: 1;
}

.lh-margin,
.sec-margin {
    padding-top: 1rem;
}

.lh-margin-left {
    border-right: 1px solid rgba(201, 168, 76, 0.18);
    padding-right: 18px;
}

.lh-margin-right {
    padding-left: 18px;
}

.compass-rose {
    width: 100%;
    max-width: 130px;
    height: auto;
    display: block;
    margin: 0 auto 1.5rem;
}

.margin-note {
    font-family: var(--f-hand);
    font-size: 1rem;
    color: var(--gold);
    line-height: 1.3;
    margin-top: 0.6rem;
    letter-spacing: 0.02em;
}

.rotate-1 { transform: rotate(-1.5deg); }
.rotate-2 { transform: rotate(2deg); }

/* The seal-dot navigation column */
.seal-nav {
    margin-top: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 22px;
    align-items: center;
}

.seal-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #f5d97c, var(--gold) 55%, #7d6420 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.3), inset 0 2px 2px rgba(255, 240, 180, 0.3);
    cursor: pointer;
    position: relative;
    transition: transform 0.25s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seal-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #5a4416;
    opacity: 0.7;
}

.seal-dot:hover {
    transform: scale(1.18);
}

.seal-dot.active {
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.35), 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.3);
}

/* tooltip (populated by JS) */
.seal-tooltip {
    position: fixed;
    pointer-events: none;
    background: var(--cream);
    color: var(--ink);
    padding: 6px 14px;
    font-family: var(--f-hand);
    font-size: 1.05rem;
    border-radius: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    transform: translate(0, -50%) rotate(-2deg);
    opacity: 0;
    transition: opacity 0.18s ease;
    z-index: 50;
    white-space: nowrap;
}

.seal-tooltip.show {
    opacity: 1;
}

.seal-tooltip::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid var(--cream);
    transform: translateY(-50%);
}

.lh-content {
    padding: 1rem 28px 0;
    max-width: var(--col-content);
}

.dispatch-meta,
.dispatch-tag {
    font-family: var(--f-mono);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    color: var(--gold);
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.title {
    font-family: var(--f-display);
    font-weight: 900;
    font-size: clamp(2.8rem, 5vw, 5rem);
    line-height: 1.05;
    letter-spacing: 0.08em;
    color: var(--cream);
    margin-bottom: 1.2rem;
    text-shadow: 0 2px 0 rgba(10, 22, 40, 0.4);
}

.title-dot {
    color: var(--gold);
    display: inline-block;
    transform: translateY(-4px);
}

.subtitle {
    font-family: var(--f-body);
    font-style: italic;
    font-size: 1.2rem;
    line-height: 1.55;
    color: rgba(245, 238, 214, 0.78);
    max-width: 580px;
    margin-bottom: 2.5rem;
}

/* fish frieze beneath letterhead */
.fish-frieze {
    width: 100%;
    height: auto;
    margin-top: 1.5rem;
    overflow: visible;
}

.frieze-1 {
    max-width: 700px;
}

.swim-fish {
    transform-origin: center;
    transition: transform 0.3s ease;
}

.swim-fish:hover {
    animation: fin-flutter 0.6s ease-in-out infinite;
}

@keyframes fin-flutter {
    0%, 100% { transform: translateY(0); }
    25%      { transform: translateY(-1.5px) rotate(-1deg); }
    75%      { transform: translateY(1.5px) rotate(1deg); }
}

/* Postage stamps */
.stamp {
    width: 64px;
    height: 76px;
    background: linear-gradient(135deg, var(--navy-rich) 0%, var(--navy-deep) 100%);
    color: var(--gold);
    font-family: var(--f-mono);
    font-size: 0.65rem;
    text-align: center;
    padding: 8px 4px;
    margin: 0 auto 0.6rem;
    transform: rotate(-4deg);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    clip-path: polygon(
        4% 6%, 12% 2%, 22% 5%, 32% 1%, 44% 4%, 56% 1%, 68% 5%, 80% 2%, 92% 5%, 98% 8%,
        96% 18%, 99% 28%, 95% 40%, 99% 52%, 95% 64%, 99% 76%, 95% 88%, 96% 96%,
        88% 99%, 76% 95%, 64% 99%, 52% 95%, 40% 99%, 28% 95%, 16% 99%, 6% 96%,
        2% 88%, 6% 76%, 2% 64%, 6% 52%, 2% 40%, 6% 28%, 2% 16%
    );
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px dashed rgba(201, 168, 76, 0.35);
    letter-spacing: 0.1em;
}

.stamp-2  { transform: rotate(3deg); }
.stamp-3  { transform: rotate(-6deg); }
.stamp-4  { transform: rotate(5deg); }
.stamp-5  { transform: rotate(-3deg); }

.stamp-cnr {
    font-size: 0.6rem;
    text-transform: uppercase;
}

.stamp-val {
    font-size: 0.7rem;
    color: var(--cream);
}

/* =============================================================
   3. BODY SECTIONS
   ============================================================= */
.body {
    position: relative;
    z-index: 3;
    padding-bottom: 2rem;
}

.section {
    padding: 4.5rem 0 1rem;
}

.sec-margin {
    padding-top: 3.5rem;
    padding-right: 18px;
    text-align: center;
}

.sec-margin-r {
    padding-top: 3.5rem;
    padding-left: 18px;
}

.margin-anno {
    font-family: var(--f-hand);
    font-size: 1.1rem;
    color: var(--gold);
    line-height: 1.25;
    margin-bottom: 1.5rem;
    transform-origin: left top;
}

.specimen {
    width: 100%;
    max-width: 110px;
    height: auto;
    display: block;
    margin: 0 auto 0.4rem;
}

.specimen-label {
    font-family: var(--f-hand);
    font-size: 0.95rem;
    color: var(--cream);
    font-style: italic;
    letter-spacing: 0.02em;
    transform: rotate(-1deg);
}

.tide-chart {
    width: 80px;
    height: auto;
    display: block;
    margin: 1rem auto 0;
    background: rgba(245, 238, 214, 0.08);
    padding: 4px;
    border-radius: 2px;
}

/* Paper card */
.paper-card {
    position: relative;
    background: var(--cream);
    color: var(--ink);
    padding: 3rem 3rem 3.5rem;
    margin: 0 28px;
    max-width: var(--col-content);
    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.05) inset,
        0 14px 38px rgba(0, 0, 0, 0.45),
        0 4px 8px rgba(0, 0, 0, 0.25);
    /* slightly rough edges via clip-path */
    clip-path: polygon(
        0.4% 0.8%, 4% 0.2%, 12% 1%, 22% 0.4%, 35% 1%, 48% 0.3%, 60% 1%, 72% 0.5%, 84% 0.9%, 96% 0.4%, 99.6% 1.2%,
        99.4% 12%, 99.8% 28%, 99.3% 44%, 99.8% 60%, 99.4% 76%, 99.7% 90%, 99.4% 99%,
        92% 99.6%, 80% 99.2%, 66% 99.7%, 50% 99.3%, 36% 99.7%, 22% 99.3%, 10% 99.7%, 0.6% 99.4%,
        0.6% 86%, 0.2% 70%, 0.5% 56%, 0.2% 40%, 0.5% 24%, 0.2% 12%
    );
}

.paper-postscript {
    background: var(--cream-2);
}

.hand-border {
    position: absolute;
    inset: 14px;
    width: calc(100% - 28px);
    height: calc(100% - 28px);
    pointer-events: none;
    overflow: visible;
}

.hand-border path {
    --path-length: 3000;
    stroke-dasharray: var(--path-length);
    stroke-dashoffset: var(--path-length);
    transition: stroke-dashoffset 1.8s cubic-bezier(0.65, 0, 0.35, 1);
    opacity: 0.85;
}

.hand-border.visible path {
    stroke-dashoffset: 0;
}

.lede {
    font-family: var(--f-display);
    font-style: italic;
    font-size: 1.45rem;
    line-height: 1.5;
    color: var(--ink);
    margin-bottom: 1.5rem;
    padding-left: 1.2rem;
    border-left: 2px solid var(--gold);
}

.sec-title {
    font-family: var(--f-display);
    font-weight: 700;
    font-size: 2.4rem;
    line-height: 1.15;
    letter-spacing: 0.04em;
    color: var(--ink);
    margin: 0.4rem 0 1.6rem;
}

.sec-title-sm {
    font-size: 1.85rem;
}

.paper-card p {
    margin-bottom: 1.2rem;
    text-indent: 1.4rem;
}

.paper-card p.lede,
.paper-card p:first-of-type {
    text-indent: 0;
}

.paper-card em {
    font-style: italic;
    color: var(--teal);
    font-weight: 500;
}

/* folded corner */
.folded-corner {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, transparent 50%, var(--navy-rich) 50%);
    box-shadow: -3px -3px 6px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

/* =============================================================
   DIVIDERS
   ============================================================= */
.divider-wrap {
    position: relative;
    padding: 2.4rem 24px 1rem;
    max-width: 1140px;
    margin: 0 auto;
}

.divider-wrap .fish-frieze {
    max-width: 940px;
    margin: 0 auto;
    display: block;
}

.divider-wrap .swim-fish path:first-child {
    stroke: var(--cream);
    opacity: 0.85;
}

.divider-wrap .swim-fish circle {
    fill: var(--cream);
}

.divider-wrap .swim-fish path[fill="#0a1628"] {
    fill: var(--cream);
}

.divider-wrap .swim-fish path[stroke="#0a1628"] {
    stroke: var(--cream);
    opacity: 0.85;
}

.tide-mark {
    height: 2px;
    margin-top: 1.2rem;
    background: linear-gradient(90deg, transparent, rgba(26, 107, 90, 0.55), transparent);
    opacity: 0.6;
}

/* =============================================================
   POSTSCRIPT
   ============================================================= */
.postscript {
    position: relative;
    z-index: 3;
    padding: 3rem 0 2rem;
}

.postscript .paper-card p {
    margin-bottom: 1rem;
}

.quick-sketch {
    width: 60%;
    max-width: 240px;
    height: auto;
    margin: 1.4rem auto 0.4rem;
    display: block;
    transform: rotate(-2deg);
}

.sketch-caption {
    font-family: var(--f-hand);
    font-size: 1rem;
    color: var(--ink);
    text-align: center;
    margin-top: 0.4rem;
    opacity: 0.85;
}

/* =============================================================
   SIGN-OFF
   ============================================================= */
.sign-off {
    position: relative;
    z-index: 3;
    padding: 4rem 0 5rem;
    color: var(--cream);
    text-align: center;
}

.signoff-inner {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 24px;
}

.closing {
    font-family: var(--f-display);
    font-style: italic;
    font-size: 1.4rem;
    color: rgba(245, 238, 214, 0.85);
    margin-bottom: 1.4rem;
}

.signature {
    width: 100%;
    max-width: 520px;
    height: auto;
    margin: 0 auto;
    display: block;
    overflow: visible;
}

.signature path {
    stroke: var(--cream);
}

#sigPath {
    --sig-length: 1600;
    stroke-dasharray: var(--sig-length);
    stroke-dashoffset: var(--sig-length);
    transition: stroke-dashoffset 2.6s cubic-bezier(0.65, 0, 0.35, 1);
}

.sign-off.draw #sigPath {
    stroke-dashoffset: 0;
}

.signed-name {
    font-family: var(--f-hand);
    font-size: 1.4rem;
    color: var(--gold);
    margin-top: 0.6rem;
    letter-spacing: 0.04em;
}

.closing-meta {
    font-family: var(--f-mono);
    font-size: 0.78rem;
    color: var(--gold);
    letter-spacing: 0.22em;
    margin-top: 1rem;
    text-transform: uppercase;
    opacity: 0.7;
}

.closing-seal-wrap {
    margin: 3rem auto 1rem;
    width: 200px;
    height: 200px;
    position: relative;
}

.closing-seal {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 6px 18px rgba(201, 168, 76, 0.25));
}

.cseal-half {
    transform-origin: 100px 100px;
    transition: transform 1.4s cubic-bezier(0.65, 0, 0.35, 1);
}

/* start broken; reform when in view */
.cseal-left  { transform: translate(-22px, 6px) rotate(-12deg); }
.cseal-right { transform: translate(22px, 6px) rotate(12deg); }

.sign-off.reform .cseal-left,
.sign-off.reform .cseal-right {
    transform: translate(0, 0) rotate(0deg);
}

.closing-coda {
    font-family: var(--f-mono);
    font-size: 0.7rem;
    color: var(--gold);
    letter-spacing: 0.4em;
    text-transform: uppercase;
    margin-top: 1.5rem;
    opacity: 0.5;
}

/* =============================================================
   GOLD SHIMMER on hover (on metallic accents)
   ============================================================= */
.title-dot,
.dispatch-tag,
.dispatch-meta,
.signed-name {
    background: linear-gradient(120deg, var(--gold) 30%, #f5d97c 50%, var(--gold) 70%);
    background-size: 200% 100%;
    background-position: 100% 0;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transition: background-position 1.2s ease;
}

.title-dot:hover,
.signed-name:hover,
.dispatch-tag:hover,
.dispatch-meta:hover {
    background-position: 0 0;
}

/* =============================================================
   SECTION ENTER ANIMATIONS (gentle opacity)
   ============================================================= */
.section,
.postscript,
.sign-off {
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.section.in-view,
.postscript.in-view,
.sign-off.in-view {
    opacity: 1;
}

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 880px) {
    :root {
        --gutter-l: 90px;
        --gutter-r: 28px;
    }
    .lh-content {
        padding: 1rem 12px 0;
    }
    .compass-rose { max-width: 80px; }
    .stamp { width: 50px; height: 60px; font-size: 0.55rem; }
    .paper-card {
        padding: 2rem 1.5rem 2.5rem;
        margin: 0 8px;
    }
    .sec-title { font-size: 1.85rem; }
}

@media (max-width: 620px) {
    :root {
        --gutter-l: 56px;
        --gutter-r: 0px;
    }
    body { font-size: 1rem; line-height: 1.7; }
    .lh-grid,
    .sec-grid {
        grid-template-columns: var(--gutter-l) 1fr;
        padding: 0 12px;
    }
    .lh-margin-right,
    .sec-margin-r {
        display: none;
    }
    .lede { font-size: 1.15rem; padding-left: 0.8rem; }
    .sec-title { font-size: 1.5rem; }
    .compass-rose { max-width: 60px; }
    .specimen { max-width: 70px; }
    .specimen-label { font-size: 0.78rem; }
    .margin-anno { font-size: 0.95rem; }
}
