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

:root {
    --aged-parchment: #f2ece3;
    --specimen-cream: #faf7f2;
    --bookcloth-brown: #2d2a26;
    --foxed-gray: #7a7168;
    --dried-rose: #b8847c;
    --pressed-sage: #8a9e8b;
    --herbarium-indigo: #4a5568;
    --pollen-gold: #d4a843;
    --pressed-leaf: #c4b9a8;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--bookcloth-brown);
    background-color: var(--aged-parchment);
    background-image:
        repeating-linear-gradient(0deg, rgba(45,42,38,0.03) 0px, rgba(45,42,38,0.03) 1px, transparent 1px, transparent 4px),
        repeating-linear-gradient(90deg, rgba(45,42,38,0.03) 0px, rgba(45,42,38,0.03) 1px, transparent 1px, transparent 4px);
    background-attachment: fixed;
    padding-bottom: 48px;
}

/* === FRONTISPIECE === */
.frontispiece {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.frontispiece-content {
    text-align: center;
    padding: 2rem;
}

.site-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bookcloth-brown);
    margin-bottom: 1rem;
}

.site-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.site-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
}

.site-subtitle {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 1.25rem;
    color: var(--foxed-gray);
    opacity: 0;
    transition: opacity 0.8s ease;
}

.site-subtitle.visible {
    opacity: 1;
}

.hero-illustration {
    width: min(400px, 80vw);
    height: auto;
    margin-top: 2rem;
}

.hero-illustration .branch {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.8s ease;
}

.hero-illustration .branch.drawn {
    stroke-dashoffset: 0;
}

.hero-illustration .node {
    transition: fill-opacity 0.6s ease 0.2s;
}

.hero-illustration .node.visible {
    fill-opacity: 0.35;
}

.hero-illustration .node-point {
    transition: opacity 0.4s ease;
}

.hero-illustration .node-point.visible {
    opacity: 1;
}

.scroll-sentinel {
    position: absolute;
    bottom: 20vh;
    height: 1px;
    width: 100%;
}

/* === MASONRY GRID === */
.masonry-grid {
    column-count: 3;
    column-gap: 2rem;
    padding: 4rem 3rem;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 1024px) {
    .masonry-grid {
        column-count: 2;
        padding: 3rem 2rem;
    }
}

@media (max-width: 640px) {
    .masonry-grid {
        column-count: 1;
        padding: 2rem 1.5rem;
    }
}

/* === SPECIMEN CARDS === */
.specimen-card {
    break-inside: avoid;
    background: var(--specimen-cream);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(45, 42, 38, 0.12);
    padding: 2rem;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out, box-shadow 0.3s ease;
}

.specimen-card.revealed {
    opacity: 1;
    transform: translateY(0);
}

.specimen-card:hover {
    box-shadow: 0 4px 16px rgba(45, 42, 38, 0.15);
}

.card-illustration {
    width: 100%;
    height: auto;
    margin-bottom: 1.5rem;
}

.specimen-card:hover .card-illustration path,
.specimen-card:hover .card-illustration ellipse,
.specimen-card:hover .card-illustration circle {
    filter: drop-shadow(0 0 3px rgba(184, 132, 124, 0.3));
}

.card-rule {
    height: 1px;
    background: var(--pressed-leaf);
    margin-bottom: 1.5rem;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease 0.5s;
}

.specimen-card.revealed .card-rule {
    transform: scaleX(1);
}

.card-content {
    opacity: 0;
    transition: opacity 0.3s ease 0.9s;
}

.specimen-card.revealed .card-content {
    opacity: 1;
}

.card-content h2 {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    color: var(--bookcloth-brown);
}

.card-content p {
    margin-bottom: 0.75rem;
    color: var(--bookcloth-brown);
}

.card-content p:last-child {
    margin-bottom: 0;
}

.mono-accent {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--pollen-gold);
}

/* === QUOTE CARDS === */
.card-quote blockquote {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-style: italic;
    font-size: 1.3rem;
    line-height: 1.5;
    border-left: 2px solid var(--dried-rose);
    padding-left: 1.5rem;
    margin-bottom: 1rem;
    color: var(--bookcloth-brown);
}

.card-quote cite {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--foxed-gray);
}

/* === PATTERN CARD === */
.card-with-pattern {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='10' cy='15' r='2' fill='%23c4b9a8' opacity='0.2'/%3E%3Cellipse cx='30' cy='30' rx='1.5' ry='3' fill='%23c4b9a8' opacity='0.2'/%3E%3C/svg%3E");
    background-color: var(--specimen-cream);
}

/* === DICE CARD === */
.dice-grid {
    display: grid;
    grid-template-columns: repeat(3, 32px);
    gap: 8px;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.dice-face {
    width: 32px;
    height: 32px;
}

/* === COIN FLIP === */
.coin-flip-container {
    text-align: center;
    margin-top: 1.5rem;
}

.coin {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.coin.flipped {
    transform: rotateY(180deg);
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 1.5rem;
    backface-visibility: hidden;
    border: 1.5px solid var(--bookcloth-brown);
    color: var(--bookcloth-brown);
}

.coin-heads {
    background: var(--specimen-cream);
}

.coin-tails {
    background: var(--pressed-leaf);
    transform: rotateY(180deg);
}

.flip-button {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: none;
    border: 1px solid var(--pressed-leaf);
    padding: 0.5rem 1.5rem;
    cursor: pointer;
    color: var(--bookcloth-brown);
    transition: border-color 0.3s ease;
}

.flip-button:hover {
    border-color: var(--dried-rose);
}

.flip-result {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--foxed-gray);
    margin-top: 0.75rem;
}

/* === LINKS === */
a {
    color: var(--dried-rose);
    text-decoration: none;
    background-image: linear-gradient(var(--pollen-gold), var(--pollen-gold));
    background-size: 0% 1.5px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.4s ease;
}

a:hover {
    background-size: 100% 1.5px;
}

/* === COLOPHON BAR === */
.colophon-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--bookcloth-brown);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 100;
    transition: height 0.3s ease;
    overflow: hidden;
}

.colophon-bar:hover {
    height: 120px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Ccircle cx='8' cy='8' r='1' fill='%23c4b9a8' opacity='0.15'/%3E%3C/svg%3E");
    background-color: var(--bookcloth-brown);
}

.colophon-name {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--pressed-sage);
    letter-spacing: 0.04em;
}

.colophon-nav {
    display: flex;
    gap: 2rem;
    opacity: 0;
    transition: opacity 0.3s ease 0.1s;
}

.colophon-bar:hover .colophon-nav {
    opacity: 1;
}

.colophon-link {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pressed-sage);
    background-image: linear-gradient(var(--pollen-gold), var(--pollen-gold));
    background-size: 0% 1px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.4s ease;
}

.colophon-link:hover {
    background-size: 100% 1px;
}

.colophon-probability {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--pollen-gold);
    letter-spacing: 0.04em;
    transition: opacity 0.2s ease;
}
