/* ===========================================================
   haskell.monster v2 - A Field Guide to Type-Level Beasts
   Editorial / Naturalist's Bestiary
   =========================================================== */

:root {
    --parchment: #FFF8F0;
    --card-cream: #FFF4E8;
    --tinted-cream: #F0E8E0;
    --scholarly-purple: #4A3A6A;
    --gold-illum: #C4A040;
    --text-dark: #2A2030;
    --faded-ink: #8A7A90;
    --specimen-green: #4A6A4A;

    --space: "EB Garamond", "Cormorant Garamond", Georgia, serif; /* display fallback */
    --inter: "EB Garamond", "Cormorant Garamond", Georgia, serif; /* body fallback */
    --serif: "EB Garamond", "Cormorant Garamond", Georgia, serif;
    --mono: "Fira Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--serif);
    font-weight: 400;
    color: var(--text-dark);
    background: var(--parchment);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: clamp(16px, 1.05vw, 18px);
}

::selection {
    background: var(--gold-illum);
    color: var(--text-dark);
}

/* ============== Title Page ============== */
.title-page {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(40px, 6vw, 80px) clamp(20px, 5vw, 60px);
    background: var(--parchment);
    overflow: hidden;
}

.lens-flare {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vmin;
    height: 90vmin;
    background: radial-gradient(
        circle at center,
        rgba(196, 160, 64, 0.30) 0%,
        rgba(196, 160, 64, 0.18) 18%,
        rgba(196, 160, 64, 0.08) 38%,
        rgba(196, 160, 64, 0.00) 65%
    );
    filter: blur(2px);
    pointer-events: none;
    opacity: 0;
    animation: flare-in 1600ms ease-in-out 200ms forwards;
}

@keyframes flare-in {
    0%   { opacity: 0; }
    35%  { opacity: 0.30; }
    100% { opacity: 0.18; }
}

.title-frame {
    position: relative;
    z-index: 2;
    max-width: 880px;
    width: 100%;
    text-align: center;
    padding: clamp(30px, 4vw, 60px) clamp(20px, 4vw, 50px);
}

.rule-line {
    display: block;
    height: 1px;
    margin: clamp(20px, 3vw, 40px) auto;
}
.rule-line span {
    display: block;
    height: 1px;
    width: 0;
    margin: 0 auto;
    background: var(--scholarly-purple);
    animation: rule-draw 700ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.rule-top span    { animation-delay: 0ms;   }
.rule-bottom span { animation-delay: 1400ms; }

@keyframes rule-draw {
    from { width: 0; }
    to   { width: 60%; }
}

.title-eyebrow {
    font-style: italic;
    color: var(--faded-ink);
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    margin-bottom: clamp(16px, 2vw, 28px);
    opacity: 0;
    animation: fade-in 800ms ease 350ms forwards;
}

.main-title {
    font-family: var(--serif);
    font-weight: 700;
    color: var(--text-dark);
    line-height: 0.95;
    letter-spacing: -0.01em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(4px, 0.6vw, 10px);
    margin: clamp(8px, 1.5vw, 18px) 0;
}

.title-line {
    display: block;
    font-size: clamp(48px, 9vw, 120px);
    text-transform: lowercase;
    font-style: italic;
    font-weight: 600;
    opacity: 0;
    animation: title-rise 900ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.title-haskell { animation-delay: 500ms; }
.title-monster {
    font-style: normal;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-size: clamp(56px, 11vw, 140px);
    color: var(--scholarly-purple);
    animation-delay: 800ms;
}

.title-amp {
    font-family: var(--serif);
    font-style: italic;
    color: var(--gold-illum);
    font-size: clamp(36px, 6vw, 80px);
    line-height: 1;
    opacity: 0;
    animation: fade-in 700ms ease 700ms forwards;
}

@keyframes title-rise {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.title-subtitle {
    font-style: italic;
    color: var(--text-dark);
    font-size: clamp(15px, 1.3vw, 19px);
    margin: clamp(20px, 2.4vw, 32px) auto 0;
    line-height: 1.55;
    max-width: 30em;
    opacity: 0;
    animation: fade-in 900ms ease 1100ms forwards;
}

.star-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(14px, 2vw, 22px);
    margin: clamp(22px, 3vw, 38px) 0;
    opacity: 0;
    animation: fade-in 700ms ease 1300ms forwards;
}

.star-orn {
    width: 16px;
    height: 16px;
    fill: var(--gold-illum);
    stroke: var(--scholarly-purple);
    stroke-width: 0.8;
}
.star-orn.small {
    width: 12px;
    height: 12px;
}
.star-row .star-1 { transform: scale(0.85); }
.star-row .star-2 { transform: scale(1.05); }
.star-row .star-3 { transform: scale(0.85); }

.title-attribution {
    font-style: italic;
    color: var(--faded-ink);
    font-size: 0.95rem;
    line-height: 1.7;
    opacity: 0;
    animation: fade-in 900ms ease 1500ms forwards;
}
.title-attribution em {
    color: var(--scholarly-purple);
    font-weight: 500;
}

.scroll-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--faded-ink);
    font-style: italic;
    font-size: 0.85rem;
    font-variant: small-caps;
    letter-spacing: 0.18em;
    opacity: 0;
    animation: hint-pulse 2.6s ease-in-out 2100ms infinite;
}
.scroll-arrow {
    display: inline-block;
    margin-left: 6px;
}

@keyframes hint-pulse {
    0%, 100% { opacity: 0.35; transform: translate(-50%, 0); }
    50%      { opacity: 0.75; transform: translate(-50%, 4px); }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============== Generic Section Header ============== */
.section-header {
    max-width: 880px;
    margin: 0 auto clamp(40px, 5vw, 70px);
    text-align: center;
    padding: 0 20px;
}

.section-eyebrow {
    font-variant: small-caps;
    letter-spacing: 0.22em;
    color: var(--faded-ink);
    font-size: 0.85rem;
    margin-bottom: 14px;
    font-weight: 500;
}

.section-title {
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(34px, 5vw, 60px);
    line-height: 1.05;
    color: var(--text-dark);
    margin-bottom: 10px;
    letter-spacing: -0.005em;
}
.section-title em {
    font-weight: 600;
    color: var(--scholarly-purple);
}

.section-subtitle {
    font-style: italic;
    color: var(--faded-ink);
    font-size: clamp(15px, 1.2vw, 18px);
    margin-top: 8px;
    max-width: 32em;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.55;
}

.star-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: clamp(18px, 2.5vw, 28px) auto;
    max-width: 360px;
}
.star-divider .rule-segment {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--faded-ink), transparent);
}

.section-lede {
    font-style: italic;
    color: var(--faded-ink);
    font-size: clamp(15px, 1.15vw, 17px);
    line-height: 1.6;
    max-width: 32em;
    margin: 0 auto;
}

/* ============== Bestiary Grid ============== */
.bestiary {
    padding: clamp(70px, 10vw, 130px) clamp(20px, 5vw, 60px);
    background: var(--parchment);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: clamp(24px, 3vw, 38px);
    max-width: 1240px;
    margin: 0 auto;
}

.specimen-card {
    position: relative;
    background: var(--card-cream);
    border: 1px solid var(--scholarly-purple);
    padding: clamp(24px, 2.6vw, 36px) clamp(22px, 2.4vw, 32px) clamp(28px, 3vw, 36px);
    transition: transform 380ms cubic-bezier(0.2, 0.7, 0.3, 1),
                box-shadow 380ms ease,
                border-color 380ms ease;
    box-shadow: 0 1px 0 rgba(74, 58, 106, 0.08);
    overflow: hidden;
    isolation: isolate;
}

.specimen-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 22px 44px -22px rgba(74, 58, 106, 0.45),
                0 6px 14px -8px rgba(74, 58, 106, 0.25);
}

.specimen-card .card-glow {
    position: absolute;
    inset: -10%;
    background: radial-gradient(
        circle at center,
        rgba(196, 160, 64, 0.32) 0%,
        rgba(196, 160, 64, 0.10) 35%,
        rgba(196, 160, 64, 0) 70%
    );
    opacity: 0;
    transition: opacity 380ms ease;
    pointer-events: none;
    z-index: -1;
}
.specimen-card:hover .card-glow { opacity: 0.85; }

/* Corner flourishes */
.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    pointer-events: none;
    transition: filter 320ms ease;
}
.corner::before,
.corner::after {
    content: '';
    position: absolute;
    background: var(--scholarly-purple);
    transition: background 320ms ease;
}
.corner::before {
    width: 18px;
    height: 1.5px;
}
.corner::after {
    width: 1.5px;
    height: 18px;
}

.corner-tl { top: 6px;    left: 6px; }
.corner-tl::before { top: 0; left: 0; }
.corner-tl::after  { top: 0; left: 0; }

.corner-tr { top: 6px;    right: 6px; }
.corner-tr::before { top: 0; right: 0; }
.corner-tr::after  { top: 0; right: 0; }

.corner-bl { bottom: 6px; left: 6px; }
.corner-bl::before { bottom: 0; left: 0; }
.corner-bl::after  { bottom: 0; left: 0; }

.corner-br { bottom: 6px; right: 6px; }
.corner-br::before { bottom: 0; right: 0; }
.corner-br::after  { bottom: 0; right: 0; }

.specimen-card:hover .corner::before,
.specimen-card:hover .corner::after {
    background: var(--gold-illum);
}

/* Illustration area */
.illustration-area {
    position: relative;
    border: 1px dashed var(--faded-ink);
    background: var(--tinted-cream);
    aspect-ratio: 4 / 3;
    margin-bottom: 18px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.creature-art {
    width: 78%;
    height: 78%;
    stroke: var(--scholarly-purple);
    fill: none;
    transition: stroke 320ms ease, transform 600ms cubic-bezier(0.2, 0.7, 0.3, 1);
}
.specimen-card:hover .creature-art {
    stroke: var(--specimen-green);
    transform: scale(1.04);
}

.creature-art .art-path {
    stroke: inherit;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 600;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1200ms ease;
}
.specimen-card[data-anim="true"] .creature-art .art-path {
    stroke-dashoffset: 600;
}
.specimen-card[data-anim="true"]:hover .creature-art .art-path {
    stroke-dashoffset: 0;
}

.creature-art .art-eye {
    fill: var(--gold-illum);
    stroke: none;
}

.plate-no {
    position: absolute;
    bottom: 6px;
    right: 10px;
    font-style: italic;
    color: var(--faded-ink);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

/* Card text */
.creature-name {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(22px, 1.8vw, 28px);
    color: var(--scholarly-purple);
    line-height: 1.15;
    margin-bottom: 8px;
}

.classification {
    font-variant: small-caps;
    letter-spacing: 0.1em;
    color: var(--faded-ink);
    font-size: 0.82rem;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(74, 58, 106, 0.22);
    padding-bottom: 10px;
}

.field-notes {
    font-size: clamp(15px, 1.05vw, 16.5px);
    line-height: 1.7;
    color: var(--text-dark);
    margin-bottom: 16px;
}
.field-notes em {
    color: var(--scholarly-purple);
}

.type-sig {
    display: block;
    background: var(--tinted-cream);
    border-left: 2px solid var(--gold-illum);
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 13.5px;
    color: var(--text-dark);
    line-height: 1.5;
    word-break: break-word;
}

/* ============== Scholarly Treatise ============== */
.scholarly {
    padding: clamp(80px, 11vw, 140px) clamp(20px, 5vw, 60px);
    background: var(--parchment);
    position: relative;
}
.scholarly::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(80%, 1000px);
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--scholarly-purple), transparent);
    opacity: 0.3;
}

.treatise {
    max-width: 660px;
    margin: 0 auto;
    font-size: clamp(16px, 1.15vw, 18px);
    line-height: 1.85;
    color: var(--text-dark);
}

.treatise p {
    margin-bottom: 1.4em;
    text-align: justify;
    hyphens: auto;
}

.treatise em {
    color: var(--scholarly-purple);
    font-weight: 500;
}

.treatise code {
    font-family: var(--mono);
    background: var(--tinted-cream);
    color: var(--text-dark);
    padding: 1px 6px;
    border-radius: 2px;
    font-size: 0.88em;
}

.dropcap-paragraph {
    margin-top: 0.6em;
}

.dropcap {
    float: left;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 5.4em;
    line-height: 0.85;
    margin: 0.05em 0.12em -0.05em 0;
    color: var(--scholarly-purple);
    background: linear-gradient(180deg, var(--scholarly-purple), var(--scholarly-purple));
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 0 18px rgba(196, 160, 64, 0.35);
}

.code-block {
    background: var(--tinted-cream);
    border-left: 3px solid var(--gold-illum);
    padding: 18px 22px;
    margin: 1.6em 0;
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-dark);
    overflow-x: auto;
    border-radius: 1px;
}

.pullquote {
    margin: 2.4em -10% 2.4em;
    padding: 28px 12% 28px;
    text-align: center;
    font-family: var(--serif);
    font-style: italic;
    font-size: clamp(20px, 2vw, 26px);
    line-height: 1.45;
    color: var(--scholarly-purple);
    position: relative;
    border-top: 1px solid rgba(74, 58, 106, 0.25);
    border-bottom: 1px solid rgba(74, 58, 106, 0.25);
}
.pullquote p { margin: 16px 0; }

.pq-star {
    width: 14px;
    height: 14px;
    fill: var(--gold-illum);
    stroke: var(--scholarly-purple);
    stroke-width: 0.8;
    display: inline-block;
}

/* Footnote markers */
.footnote-marker {
    color: var(--gold-illum);
    font-weight: 600;
    cursor: help;
    padding: 0 1px;
    font-size: 0.78em;
    transition: color 200ms ease;
    position: relative;
}
.footnote-marker:hover {
    color: var(--scholarly-purple);
}

.footnote-tooltip {
    position: absolute;
    background: var(--card-cream);
    border: 1px solid var(--scholarly-purple);
    color: var(--text-dark);
    padding: 12px 16px;
    max-width: 320px;
    font-size: 0.88rem;
    font-style: italic;
    line-height: 1.55;
    box-shadow: 0 14px 30px -14px rgba(74, 58, 106, 0.5);
    z-index: 1000;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
    border-radius: 1px;
}
.footnote-tooltip::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--card-cream);
    border-left: 1px solid var(--scholarly-purple);
    border-top: 1px solid var(--scholarly-purple);
    transform: rotate(45deg);
    top: -5px;
    left: 24px;
}
.footnote-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.footnote-tooltip em {
    color: var(--scholarly-purple);
}

.closing-flourish {
    text-align: center;
    font-style: italic;
    color: var(--faded-ink);
    margin-top: 2.4em !important;
}

/* ============== Sightings Log ============== */
.sightings {
    padding: clamp(80px, 11vw, 140px) clamp(20px, 5vw, 60px);
    background: var(--card-cream);
    position: relative;
}

.sighting-list {
    list-style: none;
    max-width: 880px;
    margin: 0 auto;
    position: relative;
    padding-left: clamp(20px, 4vw, 56px);
}

.sighting-list::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: clamp(8px, 1.5vw, 18px);
    width: 1px;
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--scholarly-purple) 6%,
        var(--scholarly-purple) 94%,
        transparent 100%
    );
}

.sighting {
    position: relative;
    padding: clamp(18px, 2vw, 26px) clamp(20px, 2.4vw, 30px);
    margin-bottom: clamp(20px, 2.5vw, 32px);
    background: var(--parchment);
    border: 1px solid rgba(74, 58, 106, 0.4);
    transition: transform 300ms ease, box-shadow 300ms ease, border-color 300ms ease;
    cursor: default;
}

.sighting::before {
    content: '';
    position: absolute;
    left: calc(-1 * clamp(20px, 4vw, 56px) + clamp(8px, 1.5vw, 18px) - 4px);
    top: 30px;
    width: 9px;
    height: 9px;
    background: var(--gold-illum);
    border: 1px solid var(--scholarly-purple);
    border-radius: 50%;
    transition: transform 300ms ease, background 300ms ease;
}

.sighting::after {
    content: '';
    position: absolute;
    left: calc(-1 * clamp(20px, 4vw, 56px) + clamp(8px, 1.5vw, 18px) + 5px);
    top: 35px;
    width: clamp(8px, 1.5vw, 18px);
    height: 1px;
    background: var(--scholarly-purple);
    opacity: 0.5;
}

.sighting:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 30px -18px rgba(74, 58, 106, 0.4);
    border-color: var(--scholarly-purple);
}
.sighting:hover::before {
    transform: scale(1.4);
    background: var(--scholarly-purple);
}

.sighting-meta {
    display: flex;
    gap: 16px;
    align-items: baseline;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.sighting-date {
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(22px, 2vw, 30px);
    color: var(--scholarly-purple);
    letter-spacing: -0.01em;
}
.sighting-version {
    font-variant: small-caps;
    letter-spacing: 0.16em;
    color: var(--faded-ink);
    font-size: 0.85rem;
    border-left: 1px solid var(--faded-ink);
    padding-left: 14px;
}

.sighting-title {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(20px, 1.7vw, 26px);
    color: var(--text-dark);
    margin-bottom: 6px;
}

.sighting-creature {
    font-style: italic;
    color: var(--specimen-green);
    font-size: 0.95rem;
    margin-bottom: 8px;
}
.sighting-creature em {
    color: var(--faded-ink);
    font-variant: small-caps;
    letter-spacing: 0.1em;
    font-size: 0.85rem;
    margin-right: 6px;
    font-style: normal;
}

.sighting-detail {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-dark);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 420ms cubic-bezier(0.2, 0.7, 0.3, 1),
                opacity 360ms ease,
                margin-top 320ms ease;
    margin-top: 0;
}

.sighting.is-open .sighting-detail,
.sighting:hover .sighting-detail {
    max-height: 240px;
    opacity: 1;
    margin-top: 8px;
}

/* ============== Footer ============== */
.field-footer {
    background: var(--parchment);
    padding: clamp(60px, 8vw, 100px) clamp(20px, 5vw, 60px) clamp(40px, 5vw, 60px);
    border-top: 1px solid var(--scholarly-purple);
    position: relative;
}

.footer-rule {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 6px;
    background: var(--parchment);
    display: flex;
    justify-content: center;
    align-items: center;
}
.footer-rule::after {
    content: '\2756';
    color: var(--gold-illum);
    background: var(--parchment);
    padding: 0 8px;
    font-size: 16px;
    line-height: 1;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: clamp(28px, 3vw, 50px);
    max-width: 1100px;
    margin: 0 auto clamp(32px, 4vw, 50px);
}

.footer-col {
    text-align: left;
}

.footer-eyebrow {
    font-variant: small-caps;
    letter-spacing: 0.22em;
    color: var(--gold-illum);
    font-size: 0.85rem;
    margin-bottom: 14px;
    font-weight: 600;
    border-bottom: 1px solid rgba(74, 58, 106, 0.3);
    padding-bottom: 8px;
}

.footer-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text-dark);
    font-size: 0.95rem;
    line-height: 1.5;
}
.footer-list span {
    font-style: italic;
}

.footer-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    color: var(--faded-ink);
    font-style: italic;
    font-size: 0.85rem;
    text-align: center;
    padding-top: clamp(20px, 2.5vw, 30px);
    border-top: 1px solid rgba(74, 58, 106, 0.2);
}

/* ============== Reveal-on-scroll ============== */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 700ms ease, transform 700ms cubic-bezier(0.2, 0.7, 0.3, 1);
}
.reveal.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* ============== Responsive ============== */
@media (max-width: 720px) {
    .title-line { font-size: clamp(40px, 13vw, 80px); }
    .title-monster { font-size: clamp(48px, 16vw, 100px); }
    .pullquote { margin-left: 0; margin-right: 0; padding-left: 6%; padding-right: 6%; }
    .treatise p { text-align: left; }
    .footer-bottom { flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
