/* =========================================================
   pmt.moe — Pragmatic Magic Theory
   Aesthetic: dopamine + manga panel grid + kawaii sparkle
   ========================================================= */

:root {
    --pink: #ff6b9d;       /* Magic Pink */
    --purple: #c084fc;     /* Spell Purple */
    --blue: #60a5fa;       /* Mana Blue */
    --white: #ffffff;      /* Panel White */
    --black: #1a1a1a;      /* Frame Black */
    --gold: #ffd700;       /* Sparkle Gold */
    --red: #ff4757;        /* Critical Red */
    --soft: #f8f8f8;       /* Soft Background */

    --grad: linear-gradient(135deg, #ff6b9d 0%, #c084fc 50%, #60a5fa 100%);
    --grad-soft: linear-gradient(135deg, #ff6b9d 0%, #c084fc 50%, #60a5fa 100%);

    --border: 3px solid #1a1a1a;

    --font-display: "Montserrat", system-ui, sans-serif;
    --font-body: "Open Sans", system-ui, sans-serif;
    --font-mono: "Fira Code", ui-monospace, "SF Mono", monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--soft);
    color: var(--black);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

code, pre, .mono { font-family: var(--font-mono); }

/* =========================================================
   SPARKLE STAR — core decorative motif
   ========================================================= */
.sparkle {
    position: absolute;
    width: var(--size, 12px);
    height: var(--size, 12px);
    background: var(--gold);
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: sparkle 2s ease-in-out infinite;
    pointer-events: none;
    filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.45));
}
.sparkle.s1 { animation-delay: 0s; }
.sparkle.s2 { animation-delay: 0.2s; }
.sparkle.s3 { animation-delay: 0.4s; }
.sparkle.s4 { animation-delay: 0.6s; }
.sparkle.s5 { animation-delay: 0.8s; }
.sparkle.s6 { animation-delay: 1.0s; }
.sparkle.s7 { animation-delay: 1.2s; }
.sparkle.s8 { animation-delay: 1.4s; }

.sparkle.small { animation-duration: 1.6s; }
.sparkle.big {
    animation-duration: 2.6s;
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.7));
}
.sparkle.absolute { position: absolute; }

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50%      { transform: scale(1.3) rotate(15deg); opacity: 0.7; }
}

/* =========================================================
   GRADIENT BAND — divider
   ========================================================= */
.gradient-band {
    height: 4px;
    background: var(--grad);
    width: 100%;
    border-top: 1.5px solid var(--black);
    border-bottom: 1.5px solid var(--black);
}

/* =========================================================
   HERO / SPLASH PANEL
   ========================================================= */
.hero {
    position: relative;
    min-height: 100vh;
    background: var(--grad);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: var(--border);
}

.hero-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.18), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,0.12), transparent 45%),
        repeating-linear-gradient(45deg, transparent 0 18px, rgba(255,255,255,0.04) 18px 19px);
    pointer-events: none;
}

.hero-inner {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 40px 24px;
    max-width: 1100px;
    width: 100%;
}

.hero-kicker {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.4em;
    color: var(--white);
    background: var(--black);
    display: inline-block;
    padding: 8px 18px;
    margin-bottom: 28px;
    border: 2px solid var(--white);
    box-shadow: 4px 4px 0 0 var(--gold);
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(3.5rem, 14vw, 11rem);
    line-height: 0.9;
    color: transparent;
    -webkit-text-stroke: 3px var(--white);
    text-stroke: 3px var(--white);
    letter-spacing: -0.02em;
    margin: 8px 0 14px;
    text-shadow:
        6px 6px 0 var(--black),
        12px 12px 0 var(--gold);
    transition: transform 0.25s ease;
    cursor: default;
}
.hero-title:hover {
    transform: translate(-2px, -2px) rotate(-1deg);
}

.hero-jp {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.95rem, 1.8vw, 1.3rem);
    color: var(--white);
    letter-spacing: 0.1em;
    margin-bottom: 18px;
    text-shadow: 2px 2px 0 var(--black);
}
.moe-tag {
    display: inline-block;
    background: var(--gold);
    color: var(--black);
    padding: 2px 10px;
    margin-left: 8px;
    border: 2px solid var(--black);
    font-size: 1.05em;
    transform: rotate(-3deg);
}

.hero-sub {
    color: var(--white);
    max-width: 620px;
    margin: 0 auto 36px;
    font-size: clamp(0.95rem, 1.4vw, 1.1rem);
    line-height: 1.6;
    background: rgba(26, 26, 26, 0.35);
    backdrop-filter: blur(2px);
    padding: 14px 22px;
    border: 2px solid var(--white);
}

/* Mascot — CSS-drawn cute creature in corner */
.mascot {
    position: absolute;
    bottom: 60px;
    right: 60px;
    width: 110px;
    height: 110px;
    z-index: 3;
    animation: mascot-bob 3.4s ease-in-out infinite;
}
.mascot-body {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--white);
    border: var(--border);
    border-radius: 50%;
    box-shadow: 6px 6px 0 0 var(--black), 10px 10px 0 0 var(--gold);
}
.mascot-eye {
    position: absolute;
    top: 38%;
    width: 14px;
    height: 18px;
    background: var(--black);
    border-radius: 50%;
}
.mascot-eye.left { left: 28%; }
.mascot-eye.right { right: 28%; }
.mascot-eye::after {
    content: "";
    position: absolute;
    top: 3px; left: 2px;
    width: 5px; height: 5px;
    background: var(--white);
    border-radius: 50%;
}
.mascot-cheek {
    position: absolute;
    top: 56%;
    width: 14px;
    height: 8px;
    background: var(--pink);
    border-radius: 50%;
    opacity: 0.85;
}
.mascot-cheek.left { left: 18%; }
.mascot-cheek.right { right: 18%; }
.mascot-mouth {
    position: absolute;
    bottom: 28%;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 8px;
    border: 2.5px solid var(--black);
    border-top: none;
    border-radius: 0 0 16px 16px;
}
.mascot-antenna {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 22px;
    background: var(--black);
}
.mascot-antenna::after {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: var(--gold);
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: sparkle 2s ease-in-out infinite;
}
.mascot-shadow {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 12px;
    background: rgba(26, 26, 26, 0.25);
    border-radius: 50%;
    filter: blur(3px);
}

@keyframes mascot-bob {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50%      { transform: translateY(-10px) rotate(2deg); }
}

/* Scroll cue */
.scroll-cue {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-shadow: 2px 2px 0 var(--black);
}
.scroll-cue-arrow {
    animation: scroll-bob 1.6s ease-in-out infinite;
}
@keyframes scroll-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(6px); }
}

/* =========================================================
   CHAPTER OPENER STRIPE
   ========================================================= */
.chapter-opener {
    background: var(--black);
    color: var(--white);
    padding: 22px 24px;
    border-bottom: var(--border);
}
.chapter-opener.alt {
    background: var(--white);
    color: var(--black);
    border-top: var(--border);
}
.chapter-stripe {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    letter-spacing: 0.18em;
    font-size: 0.85rem;
}
.chapter-tag {
    background: var(--gold);
    color: var(--black);
    padding: 4px 12px;
    font-weight: 600;
    border: 2px solid currentColor;
}
.chapter-opener.alt .chapter-tag {
    background: var(--pink);
    color: var(--white);
}
.chapter-divider {
    color: var(--gold);
    font-size: 1.2em;
    animation: spin 6s linear infinite;
    display: inline-block;
}
@keyframes spin {
    from { transform: rotate(0); }
    to   { transform: rotate(360deg); }
}
.chapter-name {
    font-family: var(--font-display);
    font-weight: 900;
    letter-spacing: 0.18em;
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
}

/* =========================================================
   MANGA PANEL GRID — gap-as-border
   ========================================================= */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(180px, auto);
    gap: 3px;
    background: var(--black);
    border-top: var(--border);
    border-bottom: var(--border);
}

.panel {
    position: relative;
    background: var(--white);
    padding: 28px 26px;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.panel:hover {
    transform: translate(-1px, -1px);
    z-index: 2;
}

.panel-num {
    position: absolute;
    top: 14px;
    left: 14px;
    width: 38px;
    height: 38px;
    border: 2.5px solid var(--black);
    border-radius: 50%;
    background: var(--gold);
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--black);
    z-index: 2;
    box-shadow: 3px 3px 0 0 var(--black);
}
.panel-num.big {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
}

.panel-tag {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--purple);
    letter-spacing: 0.12em;
    margin-top: 28px;
    margin-bottom: 8px;
    font-weight: 500;
}
.panel-tag.light { color: var(--gold); }

.panel-h {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1.4rem, 2.4vw, 1.85rem);
    line-height: 1.05;
    margin-bottom: 14px;
    letter-spacing: -0.01em;
    color: var(--black);
}
.panel-h.huge {
    font-size: clamp(1.6rem, 3.4vw, 2.6rem);
    line-height: 1.05;
}
.panel-sub {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1.05rem, 1.6vw, 1.3rem);
    margin-top: 22px;
    margin-bottom: 10px;
    color: var(--black);
}
.panel-sub.light { color: var(--white); }

.panel-body {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--black);
}
.panel-body.small { font-size: 0.92rem; line-height: 1.6; }
.panel-body.light { color: var(--white); }

.panel em {
    font-style: italic;
    background: linear-gradient(180deg, transparent 60%, var(--gold) 60%, var(--gold) 90%, transparent 90%);
    padding: 0 2px;
    font-style: italic;
}
.panel strong { color: var(--red); font-weight: 700; }
.panel-body code {
    background: var(--black);
    color: var(--gold);
    padding: 1px 6px;
    font-size: 0.85em;
    border-radius: 2px;
}

.hl {
    background: var(--gold);
    color: var(--black);
    padding: 0 8px;
    display: inline-block;
    transform: rotate(-1.2deg);
    box-shadow: 3px 3px 0 0 var(--black);
}

/* Speech bubble */
.speech-bubble {
    position: relative;
    background: var(--soft);
    border: var(--border);
    padding: 14px 18px 14px 18px;
    margin-top: 22px;
    margin-left: 22px;
    border-radius: 14px;
    box-shadow: 4px 4px 0 0 var(--black);
}
.speech-bubble::before {
    content: "";
    position: absolute;
    bottom: -16px;
    left: 36px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 16px solid var(--black);
}
.speech-bubble::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 40px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 12px solid var(--soft);
}
.speech-bubble p {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--black);
    line-height: 1.45;
}

/* Accent (gradient) panel */
.panel-accent {
    background: var(--grad);
    color: var(--white);
}
.panel-accent .panel-num {
    background: var(--white);
    color: var(--black);
}

/* Warning panel */
.panel-warn {
    background: var(--red);
    color: var(--white);
}
.panel-warn .panel-num {
    background: var(--gold);
    color: var(--black);
}

/* Star bullet list */
.panel-list {
    list-style: none;
    margin-top: 14px;
}
.panel-list li {
    position: relative;
    padding: 4px 0 4px 28px;
    line-height: 1.5;
    font-size: 0.95rem;
}
.bullet-star {
    position: absolute;
    left: 0;
    top: 10px;
    width: 14px;
    height: 14px;
    background: var(--gold);
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* =========================================================
   SHOWCASE THESIS PANEL
   ========================================================= */
.showcase {
    background: var(--white);
    padding: 80px 24px;
    border-top: var(--border);
    border-bottom: var(--border);
    position: relative;
    overflow: hidden;
}
.showcase::before {
    content: "";
    position: absolute;
    top: -40px;
    right: -40px;
    width: 240px;
    height: 240px;
    background: var(--grad);
    transform: rotate(45deg);
    opacity: 0.15;
}
.showcase::after {
    content: "★";
    position: absolute;
    bottom: -30px;
    left: -10px;
    font-size: 200px;
    color: var(--gold);
    opacity: 0.1;
    line-height: 1;
}
.showcase-inner {
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    z-index: 2;
}
.showcase-stars {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 30px;
    height: 24px;
    position: relative;
}
.showcase-stars .sparkle {
    position: relative;
}
.showcase-kicker {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.3em;
    color: var(--purple);
    margin-bottom: 16px;
}
.showcase-h {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 4.5rem);
    line-height: 1;
    margin-bottom: 28px;
    letter-spacing: -0.02em;
    color: var(--black);
}
.showcase-p {
    max-width: 620px;
    margin: 0 auto;
    font-size: 1.05rem;
    line-height: 1.7;
}

/* =========================================================
   NUMBERS STRIP
   ========================================================= */
.numbers-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    background: var(--black);
    border-top: var(--border);
    border-bottom: var(--border);
}
.num-cell {
    background: var(--white);
    text-align: center;
    padding: 36px 18px;
    position: relative;
}
.num-cell.alt {
    background: var(--soft);
}
.num-cell:nth-child(1) { background: var(--pink); color: var(--white); }
.num-cell:nth-child(2) { background: var(--purple); color: var(--white); }
.num-cell:nth-child(3) { background: var(--blue); color: var(--white); }
.num-cell:nth-child(4) { background: var(--gold); color: var(--black); }
.num {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2.6rem, 6vw, 4.4rem);
    line-height: 1;
    color: inherit;
    text-shadow: 3px 3px 0 var(--black);
}
.num-cell:nth-child(4) .num { text-shadow: 3px 3px 0 var(--white); }
.num-label {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.3em;
    margin-top: 14px;
    color: inherit;
}

/* =========================================================
   INCANTATION CODE BLOCK
   ========================================================= */
.incantation {
    background: var(--black);
    padding: 70px 24px;
    border-top: var(--border);
    border-bottom: var(--border);
    position: relative;
}
.incantation::before,
.incantation::after {
    content: "";
    position: absolute;
    width: 60px;
    height: 60px;
    background: var(--gold);
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    opacity: 0.9;
    animation: sparkle 2.4s ease-in-out infinite;
}
.incantation::before { top: 30px; left: 36px; }
.incantation::after  { bottom: 30px; right: 36px; animation-delay: 0.6s; }

.incantation-inner {
    max-width: 820px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    z-index: 2;
}
.incantation-tag {
    font-family: var(--font-mono);
    color: var(--gold);
    letter-spacing: 0.25em;
    font-size: 0.85rem;
    margin-bottom: 18px;
}
.incantation-pre {
    background: var(--white);
    color: var(--black);
    border: var(--border);
    box-shadow: 8px 8px 0 0 var(--gold);
    padding: 24px 28px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.65;
    text-align: left;
    white-space: pre;
    overflow-x: auto;
    margin-bottom: 22px;
}
.incantation-pre code {
    font-family: inherit;
    color: inherit;
    background: transparent;
    padding: 0;
}
.incantation-cap {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--white);
    font-size: 1rem;
    letter-spacing: 0.04em;
}

/* =========================================================
   CREDITS / FOOTER
   ========================================================= */
.credits {
    background: var(--soft);
    text-align: center;
    padding: 80px 24px 50px;
    position: relative;
    overflow: hidden;
}
.credits-burst {
    position: relative;
    height: 50px;
    margin-bottom: 22px;
}
.credits-burst .sparkle {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.credits-tag {
    font-family: var(--font-mono);
    color: var(--purple);
    letter-spacing: 0.3em;
    font-size: 0.85rem;
    margin-bottom: 18px;
}
.credits-h {
    font-family: var(--font-display);
    font-weight: 900;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 30px;
    letter-spacing: -0.01em;
    color: transparent;
    -webkit-text-stroke: 2.5px var(--black);
    text-shadow: 4px 4px 0 var(--gold);
}
.credits-h .dots {
    color: var(--pink);
    -webkit-text-stroke: 2.5px var(--pink);
    animation: dot-blink 1.6s steps(3, end) infinite;
}
@keyframes dot-blink {
    0%   { opacity: 0.3; }
    50%  { opacity: 1; }
    100% { opacity: 0.3; }
}
.credits-flourish {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 26px;
}
.flourish-line {
    width: 80px;
    height: 2px;
    background: var(--black);
}
.flourish-star {
    color: var(--gold);
    font-size: 1.4rem;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.5));
}
.credits-roll {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--black);
    line-height: 1.8;
    margin-bottom: 22px;
}
.credits-meta {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--black);
    letter-spacing: 0.15em;
    opacity: 0.7;
}

/* =========================================================
   ENTRANCE ANIMATIONS — set by JS
   ========================================================= */
.panel,
.showcase-inner,
.incantation-inner,
.num-cell,
.credits-h {
    opacity: 1;
}

.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
    .panel-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .panel-grid .panel {
        grid-column: auto !important;
        grid-row: auto !important;
    }
    .panel-grid .panel.p-1-1,
    .panel-grid .panel.p-2-3,
    .panel-grid .panel.p-3-1,
    .panel-grid .panel.p-2-4,
    .panel-grid .panel.p-1-4 {
        grid-column: 1 / span 2 !important;
    }
    .numbers-strip {
        grid-template-columns: repeat(2, 1fr);
    }
    .mascot {
        bottom: 80px;
        right: 24px;
        width: 80px;
        height: 80px;
    }
    .chapter-stripe {
        gap: 12px;
    }
}

@media (max-width: 520px) {
    .panel-grid {
        grid-template-columns: 1fr;
    }
    .panel-grid .panel {
        grid-column: 1 / -1 !important;
    }
    .numbers-strip {
        grid-template-columns: 1fr 1fr;
    }
    .mascot { display: none; }
    .hero-title {
        text-shadow: 4px 4px 0 var(--black), 8px 8px 0 var(--gold);
    }
    .panel { padding: 22px 18px; }
    .speech-bubble { margin-left: 0; }
}
