/* ===========================================
   scriptgrapher.com - Styles
   Hand-drawn aesthetic, high-contrast palette
   =========================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(16px, 1.5vw, 18px);
    line-height: 1.75;
    color: #1A1A1A;
    background-color: #FAFAFA;
    overflow-x: hidden;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* =============================================
   THE WORKSPACE (Hero - 100vh)
   ============================================= */
#workspace {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.paper-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #FAFAFA;
    filter: url(#paper-texture);
    z-index: 0;
    pointer-events: none;
}

/* Squiggles */
.squiggle {
    position: absolute;
    width: 250px;
    height: auto;
    z-index: 1;
    opacity: 0;
}

.squiggle path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
}

.squiggle.animate path {
    animation: drawSquiggle 1.5s ease-out forwards;
}

.squiggle.animate {
    opacity: 1;
}

.squiggle-top-left {
    top: 40px;
    left: 20px;
}

.squiggle-top-right {
    top: 60px;
    right: 20px;
    transform: scaleX(-1);
}

.squiggle-bottom-left {
    bottom: 80px;
    left: 30px;
}

.squiggle-bottom-right {
    bottom: 60px;
    right: 30px;
    transform: scaleX(-1);
}

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

/* Wordmark */
.wordmark-container {
    position: relative;
    z-index: 2;
    width: 90%;
    max-width: 900px;
    text-align: center;
}

.wordmark {
    width: 100%;
    height: auto;
    overflow: visible;
}

#wordmark-text {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    fill: none;
    stroke: #1A1A1A;
    stroke-width: 1.5;
    transition: fill 0.4s ease;
}

#wordmark-text.drawing {
    animation: drawWordmark 2.5s ease-out forwards;
}

#wordmark-text.filled {
    fill: #1A1A1A;
}

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

/* Pen cursor */
.pen-cursor {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #1A1A1A;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    z-index: 3;
    transition: opacity 0.2s;
}

.pen-cursor.visible {
    opacity: 1;
}

/* Workspace subtitle */
.workspace-subtitle {
    font-family: 'Caveat', cursive;
    font-size: clamp(20px, 3vw, 32px);
    font-weight: 400;
    color: #6B7280;
    margin-top: 20px;
    z-index: 2;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.workspace-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Glitch flash on workspace */
@keyframes glitchFlash {
    0% { filter: none; }
    25% { filter: url(#glitch); }
    50% { filter: none; }
    75% { filter: url(#glitch); }
    100% { filter: none; }
}

.glitch-flash {
    animation: glitchFlash 0.15s linear;
}

/* =============================================
   SECTION DIVIDER
   ============================================= */
.section-divider {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 0;
}

.section-divider svg {
    width: 100%;
    height: 40px;
}

.section-divider path {
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
}

.section-divider.animate path {
    animation: drawSquiggle 2s ease-out forwards;
}

/* =============================================
   SCRIPT CARDS
   ============================================= */
#script-cards {
    position: relative;
    padding: 40px 24px 80px;
    background-color: #FAFAFA;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

.script-card {
    background-color: #F5F0E8;
    border: 2px solid #1A1A1A;
    padding: 24px;
    position: relative;
    filter: url(#hand-drawn);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.script-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.script-card:hover {
    box-shadow: 4px 4px 0px #1A1A1A;
    transition: box-shadow 0.2s ease;
}

/* Glitch effect on card borders */
.script-card.glitch-border {
    animation: cardGlitch 0.1s linear;
}

@keyframes cardGlitch {
    0% { border-color: #1A1A1A; }
    33% { border-color: #EF4444; transform: translate(1px, 0); }
    66% { border-color: #1A1A1A; transform: translate(-1px, 0); }
    100% { border-color: #1A1A1A; transform: translate(0, 0); }
}

.card-illustration {
    width: 80px;
    height: 60px;
    margin-bottom: 16px;
}

.card-illustration svg {
    width: 100%;
    height: 100%;
}

.card-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 700;
    color: #1A1A1A;
    margin-bottom: 8px;
    position: relative;
}

.card-body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(14px, 1.2vw, 16px);
    line-height: 1.75;
    color: #6B7280;
    margin-bottom: 16px;
}

.card-code {
    display: block;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    font-weight: 400;
    color: #1A1A1A;
    background-color: #FAFAFA;
    padding: 8px 12px;
    border: 1px solid #1A1A1A;
    border-radius: 2px;
    filter: url(#hand-drawn);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Highlight marker effect */
.card-code::selection {
    background-color: #FEF08A;
}

/* =============================================
   THE FLOW
   ============================================= */
#the-flow {
    position: relative;
    padding: 40px 24px 80px;
    background-color: #FAFAFA;
    overflow: hidden;
}

.flow-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(32px, 5vw, 56px);
    font-weight: 700;
    color: #1A1A1A;
    text-align: center;
    margin-bottom: 60px;
}

.flowchart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: 1100px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.flow-node {
    position: relative;
    width: 160px;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.flow-node.visible {
    opacity: 1;
    transform: translateY(0);
}

.flow-node-shape {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.flow-label {
    font-family: 'Caveat', cursive;
    font-size: 28px;
    font-weight: 700;
    color: #1A1A1A;
    z-index: 1;
    position: relative;
    margin-top: -6px;
}

.flow-desc {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #6B7280;
    z-index: 1;
    position: relative;
    margin-top: 2px;
}

.flow-arrow {
    width: 60px;
    height: 40px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.flow-arrow.visible {
    opacity: 1;
}

.flow-loop-arrow {
    display: block;
    width: 600px;
    max-width: 90%;
    height: 60px;
    margin: -10px auto 0;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.flow-loop-arrow.visible {
    opacity: 1;
}

/* =============================================
   FOOTER
   ============================================= */
#footer {
    position: relative;
    padding: 60px 24px 80px;
    background-color: #FAFAFA;
    text-align: center;
}

.footer-border {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 40px;
}

.footer-border svg {
    width: 100%;
    height: 40px;
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
}

.signature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.signature-flourish {
    width: 200px;
    height: 60px;
}

.signature-flourish path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
}

.signature-flourish.animate path {
    animation: drawSquiggle 1.5s ease-out forwards;
}

.footer-text {
    font-family: 'Caveat', cursive;
    font-size: clamp(24px, 4vw, 36px);
    font-weight: 700;
    color: #1A1A1A;
}

.footer-tagline {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #6B7280;
}

/* =============================================
   KINETIC TEXT ANIMATION
   ============================================= */
.kinetic-text {
    position: relative;
    display: inline-block;
}

.kinetic-text .char {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.05s ease;
}

.kinetic-text .char.visible {
    opacity: 1;
}

/* Highlight marker underline (yellow) for emphasized words */
.highlight-marker {
    background: linear-gradient(to top, #FEF08A 40%, transparent 40%);
    padding: 0 2px;
}

/* Eraser/revision strikethrough (pink) */
.eraser-strike {
    text-decoration: line-through;
    text-decoration-color: #FECDD3;
    text-decoration-thickness: 3px;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .flowchart {
        flex-direction: column;
        gap: 12px;
    }

    .flow-arrow {
        transform: rotate(90deg);
        width: 40px;
        height: 30px;
    }

    .flow-loop-arrow {
        display: none;
    }

    .squiggle {
        width: 150px;
    }
}

@media (max-width: 600px) {
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .wordmark-container {
        width: 95%;
    }

    .squiggle-top-right,
    .squiggle-bottom-right {
        display: none;
    }
}
