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

/* === Base === */
html {
    scroll-behavior: smooth;
}

body {
    background-color: #F5EDE0;
    color: #2C2C2C;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
    line-height: 1.75;
    overflow-x: hidden;
    /* Ben-Day dot grid */
    background-image: radial-gradient(circle, #C4956A 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: 0 0;
}

/* Faint dot grid at 5% opacity via pseudo-element so we can control opacity */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle 6px, #C4956A 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
}

/* === Grain Overlay === */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.08;
    mix-blend-mode: multiply;
    filter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E#n");
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Remove body::before since we handle dots differently */
body {
    background-image: none;
}

/* === Content Column === */
.hero-content,
.panel-content,
.speech-bubble {
    max-width: 640px;
    margin-left: 45%;
    transform: translateX(-50%);
    position: relative;
    z-index: 1;
}

/* === Hero === */
#hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

#site-title {
    font-family: 'Special Elite', cursive;
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 400;
    min-height: 1.2em;
    position: relative;
}

.subtitle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 0.5em;
}

#site-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
    font-weight: 400;
    min-height: 1.5em;
}

/* Blinking cursor */
.typewriter-cursor::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #2C2C2C;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 530ms step-end infinite;
}

.typewriter-cursor.cursor-hidden::after {
    display: none;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Scroll indicator */
#scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 45%;
    transform: translateX(-50%);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.2rem;
    opacity: 0;
    animation: pulse-opacity 2s ease-in-out infinite;
    animation-delay: 9s;
    z-index: 1;
}

@keyframes pulse-opacity {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* === Panels === */
.panel {
    padding: 120px 24px;
    position: relative;
    z-index: 1;
}

/* === Speech Bubbles === */
.speech-bubble {
    display: inline-block;
    background: #F5EDE0;
    border: 4px solid #1A1A1A;
    border-radius: 24px;
    padding: 16px 32px;
    position: relative;
    margin-bottom: 40px;
    /* Ben-Day dots inside */
    background-image: radial-gradient(circle, #C4956A 1px, transparent 1px);
    background-size: 10px 10px;
    background-color: #F5EDE0;
    opacity: 0;
    transform: scale(0.85) rotate(-2deg);
    transition: opacity 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.speech-bubble.visible {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Dot opacity inside bubble */
.speech-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 20px;
    background-image: radial-gradient(circle, #C4956A 1px, transparent 1px);
    background-size: 10px 10px;
    opacity: 0.2;
    transition: opacity 200ms ease;
    pointer-events: none;
}

.speech-bubble:hover::before {
    opacity: 0.4;
}

/* Remove the double dot pattern on the bubble itself */
.speech-bubble {
    background-image: none;
}

/* Tail */
.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 40px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 20px solid #1A1A1A;
}

.bubble-text {
    font-family: 'Bangers', cursive;
    font-size: clamp(1.2rem, 3vw, 2.5rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #2C2C2C;
    position: relative;
    z-index: 1;
}

/* === Fade-in elements === */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === Typewriter headings === */
.panel h2 {
    font-family: 'Special Elite', cursive;
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-weight: 400;
    margin-bottom: 1em;
    min-height: 1.2em;
}

.panel p {
    margin-bottom: 1.2em;
}

/* === Strikethrough === */
del {
    text-decoration: line-through;
    text-decoration-color: #A0522D;
    color: #A0522D;
    opacity: 0.7;
}

/* === Tech Diagrams === */
.tech-diagram {
    border: 4px solid #2C2C2C;
    margin: 2em 0;
    padding: 1em;
    background: #F5EDE0;
}

.tech-diagram svg {
    width: 100%;
    height: auto;
}

.diagram-line {
    transition: stroke-dashoffset 3s ease-in-out;
}

.tech-diagram.animate .diagram-line {
    stroke-dashoffset: 0 !important;
}

.diagram-node {
    transition: fill 150ms ease;
}

.diagram-node:hover {
    fill: #C4956A;
}

/* === Links === */
a {
    color: #2C2C2C;
    text-decoration: none;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: #C4956A;
    transition: width 300ms ease-out;
}

a:hover::after {
    width: 100%;
}

/* === Teardrop === */
.teardrop {
    display: inline-block;
    position: relative;
    opacity: 0;
    transition: opacity 400ms ease;
}

.teardrop.visible {
    opacity: 1;
}

.teardrop::before {
    content: '';
    display: block;
    border-radius: 0 50% 50% 50%;
    transform: rotate(45deg);
    border: 3px solid #1A1A1A;
    background: linear-gradient(135deg, #C4956A, #A0522D);
    /* Ben-Day dot pattern inside */
    background-image: radial-gradient(circle, rgba(26,26,26,0.15) 1px, transparent 1px), linear-gradient(135deg, #C4956A, #A0522D);
    background-size: 4px 4px, 100% 100%;
}

.teardrop-small::before {
    width: 16px;
    height: 16px;
}

.teardrop-large {
    display: block;
    margin: 0 auto 1em;
}

.teardrop-large::before {
    width: 48px;
    height: 48px;
}

/* === Code === */
code {
    background: #3B3631;
    color: #E8D5B7;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9em;
}

/* === Selection === */
::selection {
    background: #D4B896;
    color: #2C2C2C;
}

/* === Colophon === */
.colophon {
    text-align: center;
    padding-bottom: 200px;
}

.colophon .panel-content {
    text-align: center;
}

.colophon .speech-bubble {
    margin-left: 45%;
    transform-origin: center;
}

/* === Responsive === */
@media (max-width: 768px) {
    .hero-content,
    .panel-content,
    .speech-bubble {
        margin-left: auto;
        margin-right: auto;
        transform: translateX(0);
        padding-left: 24px;
        padding-right: 24px;
        max-width: 100%;
    }

    .speech-bubble {
        transform: scale(0.85) rotate(-2deg);
    }

    .speech-bubble.visible {
        transform: scale(1) rotate(0deg);
    }

    #scroll-indicator {
        left: 50%;
        transform: translateX(-50%);
    }

    .colophon .speech-bubble {
        margin-left: auto;
    }
}

@media (max-width: 480px) {
    .bubble-text {
        font-size: clamp(1rem, 5vw, 1.5rem);
    }
}
