/* ================================================
   penclo.com - Sketchbook Design System
   Colors: #F5F0E8, #EDE6D6, #2B2B2B, #6B6560, #C4653A, #4A7C8F, #D4C8B8, #8B7D6B
   Fonts: Caveat, Commissioner, Courier Prime
   Interactive elements styling via Sunset Terracotta accent
   ================================================ */

/* --- CSS Custom Properties --- */
:root {
    --warm-linen: #F5F0E8;
    --sketch-cream: #EDE6D6;
    --graphite-deep: #2B2B2B;
    --pencil-gray: #6B6560;
    --sunset-terracotta: #C4653A;
    --coastal-slate: #4A7C8F;
    --draft-tan: #D4C8B8;
    --smudge-umber: #8B7D6B;
    --stroke-width: 2px;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--warm-linen);
    color: var(--graphite-deep);
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

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

/* --- Graph Paper Background --- */
.graph-paper-bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(212, 200, 184, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212, 200, 184, 0.15) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

.graph-paper-dense {
    background-image:
        linear-gradient(rgba(212, 200, 184, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212, 200, 184, 0.2) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* --- Navigation --- */
#pencil-nav {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#pencil-nav-toggle {
    background: var(--warm-linen);
    border: 1px solid rgba(212, 200, 184, 0.5);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 8px rgba(139, 125, 107, 0.15);
}

#pencil-nav-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(139, 125, 107, 0.25);
}

.radial-menu {
    position: absolute;
    top: 50%;
    right: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.radial-menu.is-open {
    opacity: 1;
    pointer-events: auto;
}

.radial-item {
    position: absolute;
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--graphite-deep);
    text-decoration: none;
    padding: 6px 14px;
    background: var(--warm-linen);
    border: 1px solid var(--draft-tan);
    border-radius: 4px;
    white-space: nowrap;
    transform: translate(0, 0) scale(0.5);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    box-shadow: 0 2px 6px rgba(139, 125, 107, 0.15);
}

.radial-menu.is-open .radial-item {
    opacity: 1;
}

.radial-item:hover {
    color: var(--sunset-terracotta);
    border-color: var(--sunset-terracotta);
    animation: wobble 0.4s ease;
}

@keyframes wobble {
    0% { transform: var(--item-transform) rotate(0deg); }
    25% { transform: var(--item-transform) rotate(-2deg); }
    50% { transform: var(--item-transform) rotate(2deg); }
    75% { transform: var(--item-transform) rotate(-1deg); }
    100% { transform: var(--item-transform) rotate(0deg); }
}

/* --- Sketchbook Pages --- */
.sketchbook-page {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.section-rotation {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transform: rotate(var(--rotate, 0deg));
}

.section-rotation > * {
    position: relative;
    z-index: 1;
}

.section-rotation > .graph-paper-bg {
    position: absolute;
    z-index: 0;
}

/* --- Paper Fold Shadow --- */
.sketchbook-page::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(165deg, rgba(139, 125, 107, 0.08), transparent);
    pointer-events: none;
    z-index: 2;
}

/* --- Breathing Space Between Sections --- */
.sketchbook-page + .sketchbook-page {
    margin-top: 0;
}

.sketchbook-page + .sketchbook-page::before {
    content: '';
    position: absolute;
    top: -15vh;
    left: 10%;
    right: 10%;
    height: 30vh;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 8px,
            rgba(212, 200, 184, 0.08) 8px,
            rgba(212, 200, 184, 0.08) 9px
        );
    pointer-events: none;
    z-index: 0;
}

/* --- Watercolor Wash --- */
.watercolor-wash {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

.wash-top-right {
    width: 600px;
    height: 600px;
    top: -100px;
    right: -100px;
    background: radial-gradient(circle, rgba(196, 101, 58, 0.12) 0%, transparent 70%);
}

/* --- Eraser Smudge Overlays --- */
.eraser-smudge-overlay {
    position: absolute;
    width: 120px;
    height: 60px;
    background: rgba(245, 240, 232, 0.8);
    filter: blur(20px);
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
    top: var(--smudge-top);
    left: var(--smudge-left);
}

.eraser-smudge {
    position: absolute;
    width: 100px;
    height: 50px;
    background: rgba(245, 240, 232, 0.8);
    filter: blur(20px);
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
}

.smudge-1 {
    top: 30%;
    right: 10%;
}

/* --- Margin Annotations --- */
.margin-annotation {
    position: absolute;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
}

.annotation-text {
    font-family: 'Courier Prime', monospace;
    font-size: 0.8rem;
    font-weight: 400;
    text-transform: uppercase;
    color: var(--pencil-gray);
    letter-spacing: 0.05em;
    opacity: 0.7;
}

.annotation-arrow {
    opacity: 0.5;
}

/* --- Skeleton Loading / Reveal Animation --- */
.skeleton-reveal {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* --- Draw Line Animation --- */
.draw-line {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.draw-line.is-drawn {
    stroke-dashoffset: 0;
}

/* ================================================
   PAGE 1: THE COVER (HERO)
   ================================================ */

.page-cover {
    flex-direction: column;
    background-color: var(--warm-linen);
}

.cover-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 10vw;
    margin-top: -5vh;
}

.hero-title-container {
    width: clamp(300px, 70vw, 800px);
}

.hero-title-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.hero-text-stroke {
    font-family: 'Caveat', cursive;
    font-size: 160px;
    font-weight: 700;
    fill: none;
    stroke: var(--graphite-deep);
    stroke-width: 1.5;
    letter-spacing: -0.01em;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 3s ease-in-out, fill 0.8s ease 2.5s;
}

.hero-text-stroke.is-drawn {
    stroke-dashoffset: 0;
    fill: var(--graphite-deep);
}

.hero-line-container {
    width: clamp(200px, 50vw, 600px);
    margin-top: 10px;
    margin-left: 5%;
}

.hero-underline {
    width: 100%;
    height: auto;
}

.hero-line-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s ease-in-out 2.8s;
}

.hero-line-path.is-drawn {
    stroke-dashoffset: 0;
}

.pencil-tip-icon {
    opacity: 0;
    transition: opacity 0.5s ease 4s;
}

.hero-line-path.is-drawn ~ .pencil-tip-icon {
    opacity: 1;
}

/* ================================================
   PAGE 2: THE FIRST SKETCH
   ================================================ */

.page-first-sketch {
    background-color: var(--warm-linen);
}

.sketch-circle-container {
    position: relative;
    width: clamp(300px, 50vw, 500px);
    height: clamp(300px, 50vw, 500px);
}

.sketch-circle-svg {
    width: 100%;
    height: 100%;
}

.sketch-circle-path {
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
}

.construction-line {
    opacity: 0.3;
}

/* Concept Labels positioned around the circle */
.concept-label {
    position: absolute;
    font-family: 'Courier Prime', monospace;
    font-size: 0.8rem;
    font-weight: 400;
    text-transform: uppercase;
    color: var(--pencil-gray);
    white-space: nowrap;
}

.label-n     { top: -8%;  left: 50%; transform: translateX(-50%); }
.label-ne    { top: 10%;  right: -15%; }
.label-e     { top: 50%;  right: -18%; transform: translateY(-50%); }
.label-se    { bottom: 5%; right: -12%; }
.label-s     { bottom: -8%; left: 50%; transform: translateX(-50%); }
.label-sw    { bottom: 5%; left: -15%; }
.label-w     { top: 50%;  left: -18%; transform: translateY(-50%); }
.label-nw    { top: 10%;  left: -12%; }

/* ================================================
   PAGE 3: THE WORKING NOTES
   ================================================ */

.page-working-notes {
    background-color: var(--warm-linen);
    padding: 10vh 5vw;
}

.section-heading {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: var(--graphite-deep);
    margin-bottom: 6vh;
    text-align: center;
}

.card-cluster {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    max-width: 60vw;
    margin: 0 auto;
    position: relative;
}

.index-card {
    position: relative;
    width: 290px;
    min-height: 200px;
    background: var(--sketch-cream);
    padding: 0;
    transform: rotate(var(--card-rotate, 0deg)) translate(var(--card-x, 0), var(--card-y, 0));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 2px 3px 12px rgba(139, 125, 107, 0.15);
}

.index-card:hover {
    transform: rotate(0deg) translate(0, -5px);
    box-shadow: 4px 6px 20px rgba(139, 125, 107, 0.25);
    z-index: 10;
}

.card-border {
    position: absolute;
    inset: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    pointer-events: none;
    z-index: 2;
}

.card-border-path {
    stroke-dasharray: 1100;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.4s ease;
}

.index-card:hover .card-border-path {
    stroke-dashoffset: 1100;
    animation: redraw-border 0.8s ease forwards;
}

@keyframes redraw-border {
    0% { stroke-dashoffset: 1100; }
    100% { stroke-dashoffset: 0; }
}

.card-content {
    padding: 24px 20px;
    position: relative;
    z-index: 1;
}

.card-content h3 {
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--graphite-deep);
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

.card-content p {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--pencil-gray);
}

.card-label {
    font-family: 'Courier Prime', monospace;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--pencil-gray);
    display: block;
    text-align: center;
    margin-top: 8px;
}

/* Swatch Grid */
.swatch-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 3px;
    border: 1px solid rgba(43, 43, 43, 0.15);
    transition: transform 0.2s ease;
}

.swatch:hover {
    transform: scale(1.15);
}

/* Card Illustration */
.card-illustration {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

.card-geo-svg {
    width: 120px;
    height: 120px;
}

/* ================================================
   PAGE 4: THE REFINED DRAWING
   ================================================ */

.page-refined-drawing {
    background-color: var(--warm-linen);
}

.refined-illustration {
    width: 90vw;
    max-width: 1000px;
    height: 80vh;
    position: relative;
}

.refined-svg {
    width: 100%;
    height: 100%;
}

.refined-path {
    stroke-dasharray: var(--path-length, 2000);
    stroke-dashoffset: var(--path-length, 2000);
    transition: stroke-dashoffset 2s ease-in-out;
}

.refined-path.is-drawn {
    stroke-dashoffset: 0;
}

.refined-caption {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    font-weight: 400;
    color: var(--graphite-deep);
    position: absolute;
    bottom: 12%;
    left: 8%;
    max-width: 400px;
    z-index: 2;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.refined-caption.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ================================================
   PAGE 5: THE SIGNATURE
   ================================================ */

.page-signature {
    flex-direction: column;
    background-color: var(--warm-linen);
    gap: 20px;
}

.signature-spiral-container {
    position: relative;
    z-index: 1;
    width: 300px;
    height: 450px;
}

.signature-spiral-svg {
    width: 100%;
    height: 100%;
}

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

.signature-text-container {
    position: relative;
    z-index: 2;
}

.signature-fin {
    font-family: 'Caveat', cursive;
    font-size: 3rem;
    font-weight: 400;
    color: var(--graphite-deep);
    opacity: 0;
    transition: opacity 0.8s ease 0.5s;
}

.signature-fin.is-revealed {
    opacity: 1;
}

.signature-pencil-icon {
    position: relative;
    z-index: 2;
    margin-top: 20px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.signature-pencil-icon:hover {
    transform: scale(1.08);
}

/* --- Footer --- */
.sketchbook-footer {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 30px;
    z-index: 5;
}

.footer-item {
    font-family: 'Courier Prime', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    color: var(--pencil-gray);
    opacity: 0.6;
    letter-spacing: 0.05em;
}

/* ================================================
   REDUCED MOTION
   ================================================ */

@media (prefers-reduced-motion: reduce) {
    .draw-line,
    .hero-text-stroke,
    .hero-line-path,
    .refined-path,
    .spiral-path,
    .card-border-path {
        stroke-dashoffset: 0 !important;
        transition: none !important;
    }

    .skeleton-reveal {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .hero-text-stroke {
        fill: var(--graphite-deep) !important;
    }

    .signature-fin {
        opacity: 1 !important;
        transition: none !important;
    }

    .refined-caption {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .pencil-tip-icon {
        opacity: 1 !important;
        transition: none !important;
    }
}

/* ================================================
   RESPONSIVE
   ================================================ */

@media (max-width: 768px) {
    .cover-content {
        margin-left: 5vw;
    }

    .card-cluster {
        max-width: 90vw;
        flex-direction: column;
        align-items: center;
    }

    .index-card {
        width: 85vw;
        max-width: 320px;
    }

    .concept-label {
        font-size: 0.65rem;
    }

    .label-ne, .label-e, .label-se { right: -10%; }
    .label-sw, .label-w, .label-nw { left: -10%; }

    .margin-annotation {
        display: none;
    }

    .refined-illustration {
        width: 95vw;
        height: 60vh;
    }

    .refined-caption {
        left: 5%;
        bottom: 8%;
        max-width: 80%;
    }

    .signature-spiral-container {
        width: 200px;
        height: 300px;
    }

    .radial-item {
        font-size: 0.95rem;
        padding: 4px 10px;
    }

    .sketchbook-footer {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}
