/* ==============================================================
   longitude.quest -- An Expedition in Coordinates
   Aesthetic: victorian decorative + sepia toned history
   ============================================================== */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f0e6d0;
    color: #2a1e10;
    font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
    font-size: 18px;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.noise-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ==============================================================
   PARCHMENT TEXTURE LAYER
   ============================================================== */
.parchment {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(107, 68, 35, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(58, 40, 24, 0.08) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 30%, rgba(201, 168, 76, 0.05) 0%, transparent 50%),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(42, 30, 16, 0.02) 2px, rgba(42, 30, 16, 0.02) 3px),
        repeating-linear-gradient(90deg, transparent, transparent 80px, rgba(74, 60, 42, 0.025) 80px, rgba(74, 60, 42, 0.025) 81px),
        linear-gradient(180deg, #f0e6d0 0%, #ece1c7 50%, #e8dcbe 100%);
    z-index: 0;
}

.parchment::before {
    content: "";
    position: absolute;
    inset: 0;
    filter: url(#parchmentNoise);
    opacity: 0.35;
    mix-blend-mode: multiply;
    background: #f0e6d0;
}

.parchment::after {
    /* Burnt edge vignette */
    content: "";
    position: absolute;
    inset: 0;
    box-shadow:
        inset 0 0 80px rgba(58, 40, 24, 0.18),
        inset 0 0 200px rgba(58, 40, 24, 0.08);
    background:
        radial-gradient(ellipse at center, transparent 60%, rgba(58, 40, 24, 0.12) 100%);
}

/* ==============================================================
   HORIZONTAL SCROLL EXPEDITION
   ============================================================== */
.expedition {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100vw;
    height: calc(100vh - 56px);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.expedition::-webkit-scrollbar { height: 0; display: none; }
.expedition { scrollbar-width: none; }

/* ==============================================================
   CHAPTER SECTIONS
   ============================================================== */
.chapter {
    position: relative;
    flex: 0 0 auto;
    min-width: 100vw;
    width: 100vw;
    height: 100%;
    scroll-snap-align: start;
    padding: 4rem 6rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #f0e6d0;
    overflow: hidden;
}

.chapter-inner {
    position: relative;
    z-index: 2;
    max-width: 880px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

.chapter-head {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.chapter-eyebrow {
    font-family: 'Cutive Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: #6b4423;
    margin-bottom: 1rem;
}

.chapter-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1.75rem, 4vw, 3.25rem);
    font-weight: 700;
    font-style: italic;
    color: #3a2818;
    line-height: 1.1;
    margin-bottom: 1.25rem;
    letter-spacing: 0.005em;
}

.chapter-title::before,
.chapter-title::after {
    content: "\2766";
    color: #6b4423;
    font-size: 0.5em;
    margin: 0 0.6em;
    vertical-align: middle;
    opacity: 0.6;
}

.chapter-body {
    position: relative;
    color: #2a1e10;
    font-size: 1.05rem;
    line-height: 1.85;
}

.chapter-body p {
    margin-bottom: 1.1rem;
    text-align: justify;
    hyphens: auto;
}

.chapter-body p::first-letter {
    /* faint old-style emphasis */
    font-feature-settings: "smcp", "onum";
}

.lead {
    font-size: 1.18rem;
    font-style: italic;
    color: #3a2818;
    border-left: 2px solid #6b4423;
    padding: 0.4rem 0 0.4rem 1.4rem;
    margin-bottom: 1.6rem !important;
}

.lead-final {
    border-left: none;
    border-top: 1px solid #6b4423;
    border-bottom: 1px solid #6b4423;
    padding: 1.2rem 0;
    text-align: center !important;
}

.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.col .sub-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #6b4423;
    margin: 1rem 0 0.6rem 0;
    font-style: italic;
}

.col .sub-title:first-child { margin-top: 0; }

.chapter-foot {
    text-align: center;
    margin-top: 2.4rem;
    color: #6b4423;
}

.foot-marker {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    letter-spacing: 0.5em;
    font-size: 0.95rem;
    opacity: 0.7;
}

.mini-compass {
    width: 48px;
    height: 48px;
    display: block;
    margin: 0.8rem auto 0;
    opacity: 0.65;
    animation: slowSpin 60s linear infinite;
}

@keyframes slowSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==============================================================
   COORDINATE STAMP
   ============================================================== */
.coord-stamp {
    display: inline-block;
    border: 2px solid #6b4423;
    padding: 0.3em 0.85em;
    font-family: 'Cutive Mono', 'Courier New', monospace;
    font-size: 0.85rem;
    color: #6b4423;
    transform: rotate(-3deg);
    background: rgba(240, 230, 208, 0.5);
    letter-spacing: 0.08em;
    margin-top: 0.3rem;
    box-shadow: 0 0 0 1px rgba(107, 68, 35, 0.2) inset;
    filter: url(#inkBleed);
}

.coord-stamp-alt {
    transform: rotate(2deg);
    margin-left: 1rem;
    border-color: #c9a84c;
    color: #6b4423;
    background: rgba(201, 168, 76, 0.12);
}

/* ==============================================================
   CHAPTER -- HERO
   ============================================================== */
.chapter-hero {
    position: relative;
}

.hero-stage {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 720px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    display: grid;
    place-items: center;
}

.hero-arc-text {
    position: absolute;
    inset: 0;
    pointer-events: none;
    animation: gentleSway 14s ease-in-out infinite;
}

.arc-svg {
    width: 100%;
    height: 100%;
}

.arc-domain {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 700;
    font-size: 28px;
    fill: #3a2818;
    letter-spacing: 0.55em;
}

.arc-motto {
    font-family: 'Cutive Mono', 'Courier New', monospace;
    font-size: 14px;
    fill: #6b4423;
    letter-spacing: 0.3em;
}

@keyframes gentleSway {
    0%, 100% { transform: rotate(-0.3deg); }
    50% { transform: rotate(0.3deg); }
}

.compass-wrap {
    position: relative;
    width: 78%;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    transform: translateY(0);
}

.compass-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.cardinal-label {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    font-variant: small-caps;
    fill: #3a2818;
    letter-spacing: 0.1em;
}

.ordinal-label {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 11px;
    font-weight: 400;
    font-style: italic;
    fill: #6b4423;
    letter-spacing: 0.1em;
}

.needle {
    transform-origin: 0 0;
    animation: needleQuiver 6s ease-in-out infinite;
}

@keyframes needleQuiver {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

.hero-credo {
    position: absolute;
    bottom: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 110%;
    text-align: center;
    color: #3a2818;
}

.credo-line {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-size: 1.05rem;
    color: #6b4423;
    margin-bottom: 0.4rem;
}

.credo-sub {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.05rem;
    color: #4a3c2a;
    margin-bottom: 1rem;
}

.hero-coords {
    margin-top: 0.4rem;
    margin-bottom: 1.2rem;
}

.hero-scroll-hint {
    font-family: 'Cutive Mono', 'Courier New', monospace;
    font-size: 0.78rem;
    color: #6b4423;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    animation: pulseHint 3s ease-in-out infinite;
}

@keyframes pulseHint {
    0%, 100% { opacity: 0.5; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(8px); }
}

/* ==============================================================
   CHAPTER DIVIDERS
   ============================================================== */
.chapter-divider {
    flex: 0 0 auto;
    width: 80px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, #ece1c7 0%, #f0e6d0 50%, #ece1c7 100%);
    border-left: 1px solid rgba(107, 68, 35, 0.15);
    border-right: 1px solid rgba(107, 68, 35, 0.15);
    flex-shrink: 0;
}

.divider-svg {
    width: 100%;
    height: 80%;
}

/* ==============================================================
   INSTRUMENT LIST
   ============================================================== */
.instrument-list {
    list-style: none;
    padding: 0;
}

.instrument-list li {
    padding: 0.9rem 0;
    border-bottom: 1px dashed rgba(107, 68, 35, 0.35);
    text-align: left;
    line-height: 1.7;
}

.instrument-list li:last-child {
    border-bottom: none;
}

.inst-label {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 700;
    color: #3a2818;
    margin-right: 0.4em;
}

/* ==============================================================
   LEDGER TABLE
   ============================================================== */
.ledger {
    width: 100%;
    border-collapse: collapse;
    font-family: 'EB Garamond', Georgia, serif;
    margin-top: 1rem;
    background: rgba(200, 184, 152, 0.18);
    border: 2px solid #6b4423;
}

.ledger thead th {
    font-family: 'Playfair Display', Georgia, serif;
    font-variant: small-caps;
    font-weight: 700;
    font-style: italic;
    color: #3a2818;
    background: rgba(107, 68, 35, 0.12);
    border-bottom: 1.5px solid #6b4423;
    padding: 0.7rem 1rem;
    text-align: left;
    letter-spacing: 0.06em;
    font-size: 0.95rem;
}

.ledger tbody td {
    padding: 0.55rem 1rem;
    border-bottom: 1px dashed rgba(107, 68, 35, 0.3);
    color: #2a1e10;
    font-size: 0.98rem;
}

.ledger tbody td:first-child {
    font-family: 'Cutive Mono', 'Courier New', monospace;
    font-size: 0.85rem;
    color: #6b4423;
    white-space: nowrap;
    width: 22%;
}

.ledger tbody td:nth-child(2) {
    font-style: italic;
    color: #4a3c2a;
}

.ledger tbody td:nth-child(4) {
    font-family: 'Cutive Mono', 'Courier New', monospace;
    text-align: right;
    color: #6b4423;
    width: 10%;
}

.ledger tbody tr:last-child td { border-bottom: none; }

.ledger tbody tr:hover td {
    background: rgba(201, 168, 76, 0.10);
    color: #2a1e10;
}

/* ==============================================================
   ENROL BLOCK (FINAL CHAPTER)
   ============================================================== */
.enrol {
    margin: 1.6rem auto;
    padding: 1.4rem 1.8rem;
    border: 1px solid #6b4423;
    background: rgba(200, 184, 152, 0.25);
    text-align: center;
    max-width: 620px;
    position: relative;
}

.enrol::before, .enrol::after {
    content: "";
    position: absolute;
    width: 24px; height: 24px;
    border: 1px solid #6b4423;
}
.enrol::before { top: -8px; left: -8px; border-right: none; border-bottom: none; }
.enrol::after { bottom: -8px; right: -8px; border-left: none; border-top: none; }

.enrol-line {
    font-family: 'Cutive Mono', 'Courier New', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #6b4423;
    margin: 0.8rem 0 0.3rem !important;
}

.enrol-line:first-child { margin-top: 0 !important; }

.enrol-line-alt { color: #4a3c2a; }

.enrol-addr {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    color: #3a2818;
    font-size: 1.05rem;
    margin: 0 !important;
    text-align: center !important;
}

.signoff {
    margin-top: 1.6rem;
    text-align: center !important;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.2rem;
    font-style: italic;
    color: #3a2818;
    letter-spacing: 0.02em;
}

.signoff em {
    color: #6b4423;
    border-bottom: 1px solid #c9a84c;
    padding-bottom: 1px;
}

/* ==============================================================
   THE LOGBOOK -- persistent footer
   ============================================================== */
.logbook {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 56px;
    background: #3a2818;
    color: #c8b898;
    font-family: 'Cutive Mono', 'Courier New', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    z-index: 100;
    border-top: 2px double #6b4423;
    box-shadow: 0 -8px 24px rgba(58, 40, 24, 0.45);
}

.logbook-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    height: 100%;
    padding: 0 1rem;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
}

.log-key {
    color: #c9a84c;
    font-weight: 700;
}

.log-coord {
    color: #f0e6d0;
    letter-spacing: 0.12em;
    min-width: 13ch;
    text-align: center;
}

.log-chapter,
.log-bearing,
.log-time {
    color: #c8b898;
}

.log-divider {
    color: #6b4423;
    margin: 0 0.2rem;
}

.logbook-track {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(107, 68, 35, 0.4);
}

.logbook-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6b4423 0%, #c9a84c 100%);
    transition: width 0.15s ease-out;
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.5);
}

/* ==============================================================
   COMPASS POINTS (generated by JS) styling
   ============================================================== */
.compass-line {
    stroke: #6b4423;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.compass-line-cardinal {
    stroke: #6b4423;
    stroke-width: 2;
}

.compass-line-ordinal {
    stroke: #6b4423;
    stroke-width: 1.2;
}

.compass-line-minor {
    stroke: #6b4423;
    stroke-width: 0.8;
    opacity: 0.7;
}

.compass-tick {
    stroke: #6b4423;
    stroke-width: 0.6;
    opacity: 0.75;
}

/* ==============================================================
   RESPONSIVE
   ============================================================== */
@media (max-width: 900px) {
    .chapter {
        padding: 2.5rem 1.5rem;
    }
    .chapter-inner {
        padding: 1rem;
    }
    .two-column {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .hero-stage {
        max-width: 92vw;
    }
    .hero-credo {
        bottom: -28%;
    }
    .arc-domain { font-size: 22px; letter-spacing: 0.4em; }
    .arc-motto { font-size: 11px; }
    .logbook-inner { gap: 0.5rem; font-size: 0.65rem; }
    .log-key { letter-spacing: 0.1em; }
    .ledger tbody td:first-child { font-size: 0.72rem; }
    .ledger thead th, .ledger tbody td { padding: 0.4rem 0.5rem; }
}

@media (max-width: 560px) {
    .chapter-divider { width: 40px; }
    .logbook { height: 48px; font-size: 0.6rem; }
    .expedition { height: calc(100vh - 48px); }
    .hero-credo .credo-line, .hero-credo .credo-sub { font-size: 0.92rem; }
    .coord-stamp-alt { display: none; }
}
