/* talegrapher.com — Kinetic Typography */

/* ============================
   CSS Custom Properties
   ============================ */
:root {
    --midnight-script: #1A1A2E;
    --silver-ink: #E8E8E8;
    --quill-gold: #F4C753;
    --manuscript-copper: #C4785B;
    --deep-inkwell: #2D2D44;
    --bright-page: #FAFAFA;
    --story-violet: #7B68EE;
    --twilight-slate: #4A4A6A;

    --font-display: 'Sora', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-accent: 'JetBrains Mono', monospace;

    --stagger-base: 0.08s;
    --anim-duration: 0.6s;
    --anim-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--midnight-script);
    color: var(--twilight-slate);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.7;
    overflow-x: hidden;
}

/* ============================
   Utility: Section Heading
   ============================ */
.section-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--silver-ink);
    letter-spacing: -0.03em;
    text-align: center;
    margin-bottom: 3rem;
}

/* ============================
   Pen-Nib SVG Icon
   ============================ */
.pen-nib {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: var(--quill-gold);
    stroke-width: 1;
    vertical-align: middle;
    margin-right: 6px;
    display: inline-block;
}

/* ============================
   HERO — Overture
   ============================ */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    overflow: hidden;
}

/* Map contour background */
.contour-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.contour {
    fill: none;
    stroke: var(--twilight-slate);
    stroke-width: 1;
    opacity: 0.1;
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
    animation: drawContour 4s ease forwards;
}

.c1 { animation-delay: 0s; }
.c2 { animation-delay: 0.3s; }
.c3 { animation-delay: 0.6s; }
.c4 { animation-delay: 0.9s; }
.c5 { animation-delay: 1.2s; }
.c6 { animation-delay: 1.5s; }
.c7 { animation-delay: 1.8s; }

@keyframes drawContour {
    to { stroke-dashoffset: 0; }
}

/* Hero Title */
.hero-title {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2rem;
}

.letter {
    font-family: var(--font-display);
    font-weight: 800;
    color: var(--silver-ink);
    letter-spacing: -0.03em;
    display: inline-block;
    opacity: 0;
    animation: letterIn var(--anim-duration) var(--anim-ease) forwards;
}

@keyframes letterIn {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.6) rotate(-8deg);
    }
    60% {
        opacity: 1;
        transform: translateY(-5px) scale(1.05) rotate(1deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
    }
}

.l1  { font-size: 72px; animation-delay: calc(var(--stagger-base) * 0); }
.l2  { font-size: 68px; animation-delay: calc(var(--stagger-base) * 1); }
.l3  { font-size: 64px; animation-delay: calc(var(--stagger-base) * 2); }
.l4  { font-size: 76px; animation-delay: calc(var(--stagger-base) * 3); color: var(--quill-gold); text-shadow: 0 0 20px rgba(244, 199, 83, 0.4); }
.l5  { font-size: 60px; animation-delay: calc(var(--stagger-base) * 4); }
.l6  { font-size: 66px; animation-delay: calc(var(--stagger-base) * 5); }
.l7  { font-size: 58px; animation-delay: calc(var(--stagger-base) * 6); }
.l8  { font-size: 74px; animation-delay: calc(var(--stagger-base) * 7); }
.l9  { font-size: 62px; animation-delay: calc(var(--stagger-base) * 8); }
.l10 { font-size: 70px; animation-delay: calc(var(--stagger-base) * 9); }
.l11 { font-size: 72px; animation-delay: calc(var(--stagger-base) * 10); }

/* Typewriter subtitle */
.typewriter {
    position: relative;
    z-index: 1;
    font-family: var(--font-accent);
    font-size: 15px;
    color: var(--twilight-slate);
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid var(--quill-gold);
    padding-right: 4px;
    width: 0;
    animation: blink 1s steps(1) infinite;
}

@keyframes blink {
    50% { border-color: transparent; }
}

/* ============================
   CHAPTERS — Featured Tales
   ============================ */
.chapters {
    max-width: 900px;
    margin: 0 auto;
    padding: 6rem 2rem;
}

.chapter-block {
    display: flex;
    gap: 2.5rem;
    align-items: flex-start;
    margin-bottom: 5rem;
    opacity: 0;
}

.chapter-block.slide-in-left {
    animation: slideFromLeft 0.7s var(--anim-ease) forwards;
}

.chapter-block.slide-in-right {
    animation: slideFromRight 0.7s var(--anim-ease) forwards;
}

@keyframes slideFromLeft {
    from { opacity: 0; transform: translateX(-80px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideFromRight {
    from { opacity: 0; transform: translateX(80px); }
    to   { opacity: 1; transform: translateX(0); }
}

.chapter-number {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 220px;
    letter-spacing: -0.03em;
    color: var(--silver-ink);
    mix-blend-mode: difference;
    opacity: 0.12;
    line-height: 0.85;
    min-width: 160px;
    user-select: none;
    transition: opacity 0.4s ease;
}

.chapter-block:hover .chapter-number {
    opacity: 0.25;
}

.chapter-content {
    flex: 1;
    padding-top: 1.5rem;
}

.chapter-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--quill-gold);
    text-shadow: 0 0 20px rgba(244, 199, 83, 0.2);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    transition: color 0.3s ease;
}

.chapter-title:hover {
    color: var(--story-violet);
}

.chapter-desc {
    font-size: 17px;
    color: var(--silver-ink);
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.chapter-meta {
    font-family: var(--font-accent);
    font-size: 13px;
    color: var(--twilight-slate);
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Pull quote */
.chapter-pullquote {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    color: var(--manuscript-copper);
    text-align: center;
    padding: 3rem 2rem;
    margin-bottom: 5rem;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.6s ease, transform 0.6s var(--anim-ease);
}

.chapter-pullquote.bounced {
    opacity: 1;
    transform: scale(1);
    animation: elasticBounce 0.8s var(--anim-ease);
}

@keyframes elasticBounce {
    0%   { transform: scale(0.6); }
    40%  { transform: scale(1.08); }
    60%  { transform: scale(0.96); }
    80%  { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.pullquote-mark {
    color: var(--quill-gold);
    font-size: 2.5rem;
    vertical-align: text-top;
}

/* ============================
   TIMELINE — Story Timeline
   ============================ */
.timeline {
    max-width: 900px;
    margin: 0 auto;
    padding: 6rem 2rem;
}

.timeline-track {
    position: relative;
    padding-left: 3rem;
}

.timeline-track::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--deep-inkwell);
}

.timeline-event {
    position: relative;
    margin-bottom: 3.5rem;
    opacity: 0;
}

.timeline-event.slide-in-left {
    animation: slideFromLeft 0.7s var(--anim-ease) forwards;
}

.timeline-event.slide-in-right {
    animation: slideFromRight 0.7s var(--anim-ease) forwards;
}

.timeline-connector {
    position: absolute;
    left: -3rem;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--quill-gold);
    box-shadow: 0 0 12px rgba(244, 199, 83, 0.4);
}

.timeline-connector::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 12px;
    width: 2px;
    height: 0;
    background: var(--twilight-slate);
    opacity: 0.3;
    transition: height 0.6s ease;
}

.timeline-event.slide-in-left .timeline-connector::after,
.timeline-event.slide-in-right .timeline-connector::after {
    height: 40px;
}

.timeline-date {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 48px;
    letter-spacing: -0.03em;
    color: var(--silver-ink);
    opacity: 0.2;
    display: block;
    line-height: 1;
    margin-bottom: 0.25rem;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.timeline-event:hover .timeline-date {
    opacity: 0.5;
    color: var(--story-violet);
}

.timeline-label {
    font-family: var(--font-body);
    font-size: 17px;
    color: var(--silver-ink);
    line-height: 1.5;
}

/* ============================
   CARTOGRAPHY — Word Map
   ============================ */
.word-map {
    max-width: 900px;
    margin: 0 auto;
    padding: 6rem 2rem;
}

.map-panel {
    position: relative;
    background: var(--deep-inkwell);
    border-radius: 16px;
    min-height: 420px;
    padding: 2.5rem;
    overflow: hidden;
}

.map-contour-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.mc1, .mc2, .mc3 {
    stroke: var(--twilight-slate);
    stroke-width: 0.8;
    opacity: 0.12;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.map-panel.visible .mc1,
.map-panel.visible .mc2,
.map-panel.visible .mc3 {
    animation: drawContour 3s ease forwards;
}

.map-panel.visible .mc1 { animation-delay: 0s; }
.map-panel.visible .mc2 { animation-delay: 0.4s; }
.map-panel.visible .mc3 { animation-delay: 0.8s; }

.map-word {
    position: absolute;
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--manuscript-copper);
    cursor: default;
    z-index: 1;
    transition: transform 0.3s ease, color 0.3s ease, text-shadow 0.3s ease;
    user-select: none;
}

.map-word:hover {
    transform: scale(1.15);
    color: var(--story-violet);
    text-shadow: 0 0 16px rgba(123, 104, 238, 0.4);
}

.mw1  { top: 12%;  left: 8%;   font-size: 1.15rem; }
.mw2  { top: 22%;  left: 52%;  font-size: 0.95rem; color: var(--story-violet); }
.mw3  { top: 42%;  left: 18%;  font-size: 1.35rem; color: var(--quill-gold); text-shadow: 0 0 20px rgba(244, 199, 83, 0.2); }
.mw4  { top: 8%;   left: 62%;  font-size: 1.05rem; }
.mw5  { top: 58%;  left: 48%;  font-size: 1.15rem; color: var(--story-violet); }
.mw6  { top: 32%;  left: 38%;  font-size: 0.85rem; }
.mw7  { top: 68%;  left: 12%;  font-size: 1.25rem; color: var(--quill-gold); text-shadow: 0 0 20px rgba(244, 199, 83, 0.2); }
.mw8  { top: 52%;  left: 72%;  font-size: 0.95rem; }
.mw9  { top: 78%;  left: 58%;  font-size: 1.0rem;  color: var(--story-violet); }
.mw10 { top: 38%;  left: 78%;  font-size: 0.9rem; }
.mw11 { top: 18%;  left: 30%;  font-size: 0.88rem; color: var(--manuscript-copper); }
.mw12 { top: 72%;  left: 38%;  font-size: 0.92rem; color: var(--manuscript-copper); }

/* Tooltip */
.map-tooltip {
    position: absolute;
    background: var(--midnight-script);
    color: var(--silver-ink);
    font-family: var(--font-accent);
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--twilight-slate);
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10;
    max-width: 260px;
    line-height: 1.4;
    white-space: normal;
}

.map-tooltip.active {
    opacity: 1;
    transform: translateY(0);
}

/* ============================
   FOOTER — Invitation
   ============================ */
.footer {
    max-width: 900px;
    margin: 0 auto;
    padding: 6rem 2rem 4rem;
    text-align: center;
    border-top: 1px solid var(--deep-inkwell);
}

.featured-tales {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.tale-link {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--manuscript-copper);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    transform: translateY(16px);
    transition: color 0.3s ease, transform 0.3s ease;
}

.tale-link.cascaded {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease, color 0.3s ease;
}

.tale-link:hover {
    color: var(--story-violet);
    transform: translateY(-2px);
}

.tale-link:hover .pen-nib {
    stroke: var(--story-violet);
}

.footer-cta {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2.5rem;
    color: var(--quill-gold);
    text-shadow: 0 0 20px rgba(244, 199, 83, 0.25);
    letter-spacing: -0.02em;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.6s ease, transform 0.6s ease;
    cursor: default;
}

.footer-cta.scaled {
    opacity: 1;
    transform: scale(1);
}

.footer-cta:hover {
    transform: scale(1.06);
    text-shadow: 0 0 40px rgba(244, 199, 83, 0.4);
}

/* ============================
   Scroll-triggered: Scale-in
   ============================ */
.anim-scale {
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.6s ease, transform 0.6s var(--anim-ease);
}

.anim-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 768px) {
    .hero-title {
        gap: 3px;
    }

    .l1, .l2, .l3, .l4, .l5, .l6, .l7, .l8, .l9, .l10, .l11 {
        font-size: 36px;
    }

    .l4 {
        font-size: 42px;
    }

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

    .chapter-number {
        font-size: 120px;
        min-width: auto;
    }

    .chapter-content {
        padding-top: 0;
    }

    .chapter-pullquote {
        font-size: 1.4rem;
    }

    .timeline-date {
        font-size: 32px;
    }

    .map-panel {
        min-height: 350px;
    }

    .footer-cta {
        font-size: 1.8rem;
    }

    .typewriter {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .l1, .l2, .l3, .l4, .l5, .l6, .l7, .l8, .l9, .l10, .l11 {
        font-size: 28px;
    }

    .l4 {
        font-size: 34px;
    }

    .chapter-number {
        font-size: 80px;
    }

    .footer-cta {
        font-size: 1.4rem;
    }
}
