/* ============================================================
   lowball.dev - Styles
   Ocean-deep + hand-drawn sketchbook aesthetic
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --primary-deep: #0B1D2E;
    --secondary-deep: #132F47;
    --teal-accent: #1B8A8E;
    --warm-sand: #F2E8D5;
    --chalk-white: #EDF3F7;
    --coral-annotation: #E07A5F;
    --depth-mid: #1B4B5A;
    --ink-blue: #2A5470;

    --font-headline: 'Caveat', cursive;
    --font-body: 'Source Sans 3', sans-serif;
    --font-code: 'JetBrains Mono', monospace;

    --mesh-x: 50%;
    --mesh-y: 50%;
    --mesh-x2: 30%;
    --mesh-y2: 70%;

    --reveal-easing: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    color: var(--primary-deep);
    background: var(--primary-deep);
    overflow-x: hidden;
}

/* --- Persistent Margin Rule --- */
#margin-rule {
    position: fixed;
    top: 0;
    left: 12vw;
    width: 2px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}

#margin-rule-svg {
    display: block;
    width: 2px;
    height: 100%;
}

.margin-marker {
    position: absolute;
    left: -11px;
    transform: translateY(-50%);
}

/* --- Section Base --- */
.section {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* --- Fade Reveal Animation --- */
.fade-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 700ms var(--reveal-easing), transform 700ms var(--reveal-easing);
}

.fade-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Draw Path Animation --- */
.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.2s var(--reveal-easing);
}

.draw-path.drawn {
    stroke-dashoffset: 0;
}

/* --- Ruled Lines (notebook effect) --- */
.ruled-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 31px,
        rgba(42, 84, 112, 0.08) 31px,
        rgba(42, 84, 112, 0.08) 32px
    );
    pointer-events: none;
    z-index: 1;
}

.ruled-lines-light {
    background-image: repeating-linear-gradient(
        transparent,
        transparent 31px,
        rgba(42, 84, 112, 0.06) 31px,
        rgba(42, 84, 112, 0.06) 32px
    );
}

/* ============================================================
   SECTION 1: SURFACE
   ============================================================ */
.surface-section {
    min-height: 100vh;
    background: var(--warm-sand);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.surface-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 0 2rem;
}

.hero-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.02em;
    color: var(--primary-deep);
    line-height: 1.1;
    margin-bottom: 0.2em;
}

.hero-subtitle {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--ink-blue);
    opacity: 0.85;
    margin-bottom: 1rem;
}

.hero-scribble {
    width: clamp(200px, 40vw, 320px);
    height: 12px;
    display: block;
    margin: 0 auto 2rem;
}

.scroll-arrow {
    margin-top: 2rem;
    animation: bobArrow 2s ease-in-out infinite;
}

@keyframes bobArrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

.surface-water-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(19, 47, 71, 0.05) 30%,
        rgba(19, 47, 71, 0.15) 60%,
        rgba(19, 47, 71, 0.35) 100%
    );
    pointer-events: none;
    z-index: 1;
}

/* ============================================================
   SECTION 2: SHALLOW WATER
   ============================================================ */
.shallow-section {
    min-height: 150vh;
    background: var(--secondary-deep);
    padding: 10vh 5vw 15vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8vh;
    position: relative;
}

.gradient-mesh-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 60% 50% at var(--mesh-x) var(--mesh-y), rgba(27, 75, 90, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse 40% 60% at var(--mesh-x2) var(--mesh-y2), rgba(27, 138, 142, 0.2) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 70% 30%, rgba(27, 75, 90, 0.15) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* --- Notebook Cards --- */
.notebook-card {
    position: relative;
    z-index: 2;
    max-width: 640px;
    width: 100%;
    background: var(--warm-sand);
    border-radius: 4px;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.25),
        0 1px 4px rgba(0, 0, 0, 0.15);
    overflow: visible;
}

.card-rotate-left {
    transform: rotate(-1.2deg) translateY(20px);
    opacity: 0;
}

.card-rotate-right {
    transform: rotate(1deg) translateY(20px);
    opacity: 0;
}

.card-rotate-left.revealed {
    transform: rotate(-1.2deg) translateY(0);
    opacity: 1;
}

.card-rotate-right.revealed {
    transform: rotate(1deg) translateY(0);
    opacity: 1;
}

.card-inner {
    padding: 2.5rem 3rem;
    position: relative;
    /* Faint ruled lines on card */
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        rgba(42, 84, 112, 0.06) 27px,
        rgba(42, 84, 112, 0.06) 28px
    );
}

.card-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    color: var(--primary-deep);
    letter-spacing: 0.02em;
    margin-bottom: 0.8rem;
}

.card-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.6vw, 1.05rem);
    line-height: 1.75;
    color: var(--primary-deep);
}

.card-body em {
    font-weight: 600;
    color: var(--teal-accent);
    font-style: normal;
}

.card-code {
    margin-top: 1.2rem;
    padding: 1rem 1.2rem;
    background: rgba(11, 29, 46, 0.06);
    border-radius: 4px;
    border-left: 3px solid var(--teal-accent);
}

.card-code code {
    font-family: var(--font-code);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--primary-deep);
    white-space: pre;
    display: block;
}

.code-comment {
    color: var(--ink-blue);
    opacity: 0.6;
}

.code-annotation {
    color: var(--coral-annotation);
    font-family: var(--font-headline);
    font-size: 1rem;
}

/* --- Card Annotations --- */
.card-annotation {
    position: absolute;
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
}

.annotation-right {
    top: 1.5rem;
    right: -120px;
    flex-direction: column;
    align-items: center;
}

.annotation-left {
    top: 1.5rem;
    left: -120px;
    flex-direction: column;
    align-items: center;
}

.annotation-text {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    color: var(--coral-annotation);
    opacity: 0.85;
    white-space: nowrap;
}

/* --- Margin Sketches --- */
.margin-sketch {
    position: absolute;
    z-index: 3;
    opacity: 0.7;
}

.margin-sketch-right {
    right: 5vw;
    top: 30vh;
}

.margin-sketch-left {
    left: 3vw;
    top: 40%;
}

/* ============================================================
   SECTION 3: MID-DEPTH
   ============================================================ */
.mid-depth-section {
    min-height: 150vh;
    background: var(--primary-deep);
    padding: 12vh 5vw 15vh;
    position: relative;
    color: var(--chalk-white);
}

.gradient-mesh-deep {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 55% 45% at var(--mesh-x) 30%, rgba(27, 75, 90, 0.35) 0%, transparent 65%),
        radial-gradient(ellipse 45% 55% at var(--mesh-x2) 70%, rgba(27, 138, 142, 0.2) 0%, transparent 55%),
        radial-gradient(ellipse 35% 35% at 80% var(--mesh-y), rgba(27, 75, 90, 0.15) 0%, transparent 50%),
        linear-gradient(180deg, var(--primary-deep) 0%, var(--secondary-deep) 40%, var(--depth-mid) 70%, var(--primary-deep) 100%);
    pointer-events: none;
    z-index: 0;
}

.tech-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(42, 84, 112, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(42, 84, 112, 0.05) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 1;
}

.tech-grid-dense {
    background-size: 40px 40px;
    background-image:
        linear-gradient(rgba(42, 84, 112, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(42, 84, 112, 0.07) 1px, transparent 1px);
}

.depth-content {
    position: relative;
    z-index: 2;
    max-width: 720px;
    margin: 0 auto;
    padding-left: 6vw;
}

.depth-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.2rem);
    letter-spacing: 0.02em;
    color: var(--chalk-white);
    margin-bottom: 0.5rem;
}

.depth-scribble {
    width: clamp(160px, 30vw, 240px);
    height: 10px;
    margin-bottom: 6vh;
}

.depth-block {
    display: flex;
    gap: 2rem;
    margin-bottom: 6vh;
}

.depth-block-margin {
    flex: 0 0 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
}

.margin-note {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    color: var(--coral-annotation);
    opacity: 0.85;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    white-space: nowrap;
}

.depth-block-content {
    flex: 1;
}

.depth-subtitle {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: var(--chalk-white);
    letter-spacing: 0.02em;
    margin-bottom: 0.6rem;
}

.depth-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
    line-height: 1.75;
    color: var(--chalk-white);
    opacity: 0.9;
}

/* --- Pseudocode Blocks --- */
.pseudocode-block {
    background: rgba(11, 29, 46, 0.6);
    border: 1px solid rgba(27, 138, 142, 0.25);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 1rem;
}

.pseudocode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.2rem;
    background: rgba(27, 138, 142, 0.1);
    border-bottom: 1px solid rgba(27, 138, 142, 0.15);
}

.pseudocode-label {
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: var(--teal-accent);
}

.pseudocode-comment {
    font-family: var(--font-headline);
    font-size: 0.9rem;
    color: var(--coral-annotation);
    opacity: 0.8;
}

.pseudocode {
    padding: 1.2rem;
    overflow-x: auto;
}

.pseudocode code {
    font-family: var(--font-code);
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--chalk-white);
    font-variant-ligatures: none;
}

.pseudocode .code-comment {
    color: var(--ink-blue);
    opacity: 0.7;
}

.pseudocode .code-annotation {
    color: var(--coral-annotation);
    font-family: var(--font-headline);
    font-size: 1rem;
}

/* ============================================================
   SECTION 4: THE DEEP
   ============================================================ */
.deep-section {
    min-height: 150vh;
    background: var(--primary-deep);
    padding: 12vh 5vw 15vh;
    position: relative;
    color: var(--chalk-white);
}

.gradient-mesh-abyss {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 50% 40% at var(--mesh-x) 25%, rgba(27, 75, 90, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse 40% 50% at var(--mesh-x2) 75%, rgba(27, 138, 142, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse 60% 30% at 20% var(--mesh-y2), rgba(27, 75, 90, 0.2) 0%, transparent 55%),
        radial-gradient(ellipse 30% 40% at 80% 50%, rgba(27, 138, 142, 0.1) 0%, transparent 45%);
    pointer-events: none;
    z-index: 0;
}

.deep-content {
    position: relative;
    z-index: 2;
    max-width: 680px;
    margin: 0 auto;
}

.deep-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.2rem);
    letter-spacing: 0.02em;
    color: var(--chalk-white);
    margin-bottom: 0.5rem;
}

.deep-scribble {
    width: clamp(120px, 20vw, 160px);
    height: 10px;
    margin-bottom: 6vh;
}

.deep-block {
    margin-bottom: 6vh;
}

.deep-subtitle {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: var(--chalk-white);
    letter-spacing: 0.02em;
    margin-bottom: 0.6rem;
}

.deep-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
    line-height: 1.75;
    color: var(--chalk-white);
    opacity: 0.9;
}

/* --- Concept Highlight --- */
.concept-highlight {
    position: relative;
    display: inline-block;
    margin-top: 1.5rem;
    padding: 0.8rem 2rem;
}

.concept-circle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.concept-text {
    font-family: var(--font-code);
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--teal-accent);
    position: relative;
    z-index: 1;
}

/* --- Algorithm Frame --- */
.algorithm-frame {
    display: flex;
    align-items: stretch;
    margin-top: 1rem;
}

.frame-bracket {
    flex: 0 0 20px;
    min-height: 100%;
}

.frame-bracket svg {
    width: 20px;
    height: 100%;
}

.algorithm-content {
    flex: 1;
    background: rgba(11, 29, 46, 0.6);
    border: 1px solid rgba(27, 138, 142, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.algorithm-content .pseudocode-header {
    border-bottom-color: rgba(27, 138, 142, 0.12);
}

.algorithm-content .pseudocode {
    padding: 1rem 1.2rem;
}

/* --- Deep Annotation --- */
.deep-annotation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    margin-left: 1rem;
}

/* ============================================================
   SECTION 5: RESURFACE
   ============================================================ */
.resurface-section {
    min-height: 100vh;
    padding: 12vh 5vw 10vh;
    position: relative;
    background: var(--warm-sand);
}

.resurface-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(180deg,
        var(--secondary-deep) 0%,
        var(--depth-mid) 20%,
        rgba(27, 75, 90, 0.3) 50%,
        var(--warm-sand) 100%
    );
    pointer-events: none;
    z-index: 0;
}

.resurface-content {
    position: relative;
    z-index: 2;
    max-width: 640px;
    margin: 0 auto;
    text-align: center;
    padding-top: 30vh;
}

.resurface-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.02em;
    color: var(--primary-deep);
    margin-bottom: 0.5rem;
}

.resurface-scribble {
    width: clamp(160px, 28vw, 220px);
    height: 10px;
    margin: 0 auto 4vh;
}

/* --- Summary Sketch --- */
.summary-sketch {
    margin-bottom: 5vh;
}

.summary-diagram {
    width: 100%;
    max-width: 400px;
    height: auto;
}

/* --- Resurface Message --- */
.resurface-message {
    margin-bottom: 4vh;
}

.resurface-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.2rem);
    line-height: 1.8;
    color: var(--primary-deep);
    opacity: 0.9;
}

/* --- CTA --- */
.resurface-cta {
    position: relative;
    display: inline-block;
    margin-bottom: 6vh;
}

.cta-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 60px;
    pointer-events: none;
}

.cta-link {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    color: var(--teal-accent);
    text-decoration: none;
    position: relative;
    z-index: 1;
    padding: 0.5rem 1.5rem;
    display: inline-block;
    transition: color 400ms ease;
}

.cta-link:hover {
    color: var(--coral-annotation);
}

/* --- Notebook Footer --- */
.notebook-footer {
    margin-top: 4vh;
    padding-top: 3vh;
    border-top: 1px dashed rgba(42, 84, 112, 0.2);
}

.footer-text {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    color: var(--ink-blue);
    opacity: 0.6;
}

.dot-matrix {
    margin-top: 1.5rem;
    height: 30px;
    background-image: radial-gradient(circle, rgba(42, 84, 112, 0.15) 1px, transparent 1px);
    background-size: 8px 8px;
    opacity: 0.5;
}

/* ============================================================
   SCRIBBLE UNDERLINES (shared)
   ============================================================ */
.scribble-underline {
    display: block;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    #margin-rule {
        display: none;
    }

    .card-annotation {
        display: none;
    }

    .margin-sketch {
        display: none;
    }

    .card-inner {
        padding: 1.5rem 1.8rem;
    }

    .depth-block {
        flex-direction: column;
        gap: 0.5rem;
    }

    .depth-block-margin {
        flex-direction: row;
        writing-mode: horizontal-tb;
        gap: 0.5rem;
        padding-top: 0;
    }

    .margin-note {
        writing-mode: horizontal-tb;
        text-orientation: initial;
    }

    .depth-content {
        padding-left: 2vw;
    }

    .annotation-arrow-vertical {
        display: none;
    }

    .algorithm-frame .frame-bracket {
        display: none;
    }

    .shallow-section {
        padding: 8vh 4vw 12vh;
        gap: 5vh;
    }

    .mid-depth-section,
    .deep-section {
        padding: 8vh 4vw 12vh;
    }

    .resurface-content {
        padding-top: 20vh;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2.5rem, 12vw, 3.5rem);
    }

    .card-inner {
        padding: 1.2rem 1.4rem;
    }

    .pseudocode code {
        font-size: 0.78rem;
    }

    .concept-highlight {
        padding: 0.5rem 1rem;
    }
}
