/* =============================================
   LegalDebug.com - Styles
   Scandinavian Zen / Hexagonal Honeycomb
   ============================================= */

:root {
    --primary-terracotta: #C1694F;
    --deep-umber: #3D2B1F;
    --warm-parchment: #F5EDE3;
    --dusty-rose: #D4A59A;
    --honey-amber: #D4A843;
    --soft-clay: #B8866B;
    --deep-forest: #2E3830;
    --linen-white: #FAF7F2;
    --warm-brown: #5B3A29;

    --shadow-close: 0 1px 3px rgba(61,43,31,0.08);
    --shadow-medium: 0 4px 12px rgba(61,43,31,0.05);
    --shadow-far: 0 12px 36px rgba(61,43,31,0.03);

    --ease-default: cubic-bezier(0.25, 0.1, 0.25, 1.0);
    --ease-draw: cubic-bezier(0.4, 0, 0.2, 1);

    --font-heading: 'Commissioner', sans-serif;
    --font-label: 'Inter', sans-serif;
    --font-body: 'Source Serif 4', serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.75;
    color: var(--deep-umber);
    background-color: var(--warm-parchment);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Background Hex Pattern ---- */
.bg-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ---- Scroll Progress ---- */
#scroll-progress {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background-color: var(--primary-terracotta);
    z-index: 1000;
    transition: width 0.1s linear;
}

/* ---- Navigation ---- */
#nav-hex-trigger {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    z-index: 1001;
    transition: transform 0.3s var(--ease-default);
}

#nav-hex-trigger:hover {
    transform: scale(1.1);
}

.nav-hex-icon {
    width: 100%;
    height: 100%;
}

.nav-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-menu.hidden {
    pointer-events: none;
    visibility: hidden;
}

.nav-menu.hidden .nav-petal {
    opacity: 0;
    transform: translate(0, 0) scale(0.3);
}

.nav-menu.hidden .nav-menu-backdrop {
    opacity: 0;
}

.nav-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 237, 227, 0.92);
    backdrop-filter: blur(6px);
    transition: opacity 0.4s var(--ease-default);
}

.nav-petal {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-label);
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--deep-umber);
    background: var(--linen-white);
    border: 1px solid var(--dusty-rose);
    clip-path: polygon(10% 0%, 90% 0%, 100% 50%, 90% 100%, 10% 100%, 0% 50%);
    cursor: pointer;
    transition: all 0.5s var(--ease-default);
    transform: translate(
        calc(-50% + cos(var(--petal-angle)) * 160px),
        calc(-50% + sin(var(--petal-angle)) * 160px)
    );
    z-index: 1;
}

.nav-petal:hover {
    background: var(--primary-terracotta);
    color: var(--linen-white);
    border-color: var(--primary-terracotta);
}

/* ---- Connection SVG Overlay ---- */
.connection-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ---- Section Base ---- */
.section {
    position: relative;
    z-index: 2;
}

/* ---- HERO ---- */
.hero-section {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--warm-parchment);
    overflow: hidden;
}

.hero-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-hex-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero-hex-svg polygon {
    fill: none;
    stroke: var(--dusty-rose);
    stroke-width: 1;
    opacity: 0;
    transition: opacity 0.6s var(--ease-default);
}

.hero-hex-svg polygon.visible {
    opacity: 0.35;
}

.hero-text {
    position: relative;
    z-index: 2;
    text-align: center;
    opacity: 0;
    transition: opacity 1s var(--ease-default);
}

.hero-text.visible {
    opacity: 1;
}

.hero-title {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(2.5rem, 8vw, 7rem);
    color: var(--deep-umber);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 0.3em;
}

.hero-tagline {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.3rem);
    color: var(--soft-clay);
    opacity: 0;
    transition: opacity 0.8s var(--ease-default) 0.5s;
}

.hero-text.visible .hero-tagline {
    opacity: 1;
}

/* ---- ACT Sections ---- */
.act {
    padding: 8rem 5vw 6rem;
    min-height: 100vh;
}

.act-1 {
    background: var(--linen-white);
}

.act-2 {
    background: var(--warm-parchment);
}

.act-3 {
    background: var(--linen-white);
}

.act-4 {
    background: var(--warm-parchment);
    min-height: 80vh;
}

/* ---- Section Labels ---- */
.section-label {
    text-align: center;
    margin-bottom: 5rem;
}

.label-tag {
    display: inline-block;
    font-family: var(--font-label);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--primary-terracotta);
    border: 1px solid var(--dusty-rose);
    padding: 0.25em 1em;
    margin-bottom: 1rem;
}

.section-heading {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    color: var(--deep-umber);
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.section-subtext {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 1rem;
    color: var(--soft-clay);
}

/* ---- Honeycomb Clusters ---- */
.honeycomb-cluster {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    max-width: 1100px;
    margin: 0 auto 4rem;
    padding: 0 1rem;
}

.cluster-left {
    transform: translateX(-3vw);
}

.cluster-right {
    transform: translateX(3vw);
}

.cluster-center {
    max-width: 700px;
}

.dense .hex-cell {
    margin: -0.5rem;
}

.overlap .hex-cell {
    margin: -0.8rem;
}

/* ---- Hexagonal Cells ---- */
.hex-cell {
    width: 280px;
    min-height: 280px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--linen-white);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: default;
    opacity: 0;
    transform: translateY(20px);
    transition:
        opacity 0.6s var(--ease-default),
        transform 0.6s var(--ease-default),
        box-shadow 0.3s var(--ease-default);
}

.hex-cell.in-view {
    opacity: 1;
    transform: translateY(0);
}

.act-2 .hex-cell {
    background: var(--linen-white);
}

.act-3 .hex-cell {
    background: var(--warm-parchment);
}

.hex-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border: 2px solid var(--dusty-rose);
    pointer-events: none;
    transition: border-color 0.3s var(--ease-default);
}

.hex-cell:hover::before {
    border-color: var(--primary-terracotta);
}

.hex-cell:hover {
    transform: translateY(0) scale(1.05);
    z-index: 10;
    filter: drop-shadow(0 8px 24px rgba(61,43,31,0.12));
}

.hex-cell-inner {
    padding: 3.5rem 2rem 3rem;
    text-align: center;
    max-width: 220px;
}

.cell-tag {
    display: inline-block;
    font-family: var(--font-label);
    font-weight: 500;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary-terracotta);
    margin-bottom: 0.75rem;
}

.hex-cell h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--deep-umber);
    margin-bottom: 0.6rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.hex-cell p {
    font-family: var(--font-body);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--soft-clay);
}

/* ---- Clarity Section ---- */
.clarity-field {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    padding: 4rem 2rem;
}

.clarity-cell {
    width: 360px;
    min-height: 360px;
}

.clarity-cell .hex-cell-inner {
    padding: 4rem 2.5rem;
    max-width: 280px;
}

.clarity-cell h3 {
    font-family: var(--font-heading);
    font-weight: 400;
    font-size: 1.2rem;
    font-style: italic;
    color: var(--deep-umber);
    margin-bottom: 1rem;
}

.clarity-cell p {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--deep-umber);
}

.clarity-svg {
    display: block;
    width: 100%;
    max-width: 1000px;
    height: 200px;
    margin: 0 auto;
    opacity: 0.3;
}

/* ---- Breathing Spaces ---- */
.breathing-space {
    width: 100%;
    height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--warm-parchment);
    position: relative;
    z-index: 2;
    overflow: hidden;
}

.breath-symbol {
    width: 260px;
    height: 260px;
    opacity: 0;
    transition: opacity 1s var(--ease-default);
}

.breath-symbol.wide {
    width: 420px;
    height: 210px;
}

.breath-symbol.in-view {
    opacity: 1;
}

.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s var(--ease-draw);
}

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

.flow-label {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--soft-clay);
    opacity: 0;
    transition: opacity 1s var(--ease-default) 2s;
}

.flow-label.drawn {
    opacity: 1;
}

/* ---- Debug Console ---- */
.debug-console {
    max-width: 680px;
    margin: 4rem auto 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-close), var(--shadow-medium), var(--shadow-far);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s var(--ease-default), transform 0.8s var(--ease-default);
}

.debug-console.in-view {
    opacity: 1;
    transform: translateY(0);
}

.console-header {
    background: #2a2520;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.console-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.console-dot.red { background: #E25E52; }
.console-dot.yellow { background: #E5C02A; }
.console-dot.green { background: #54B648; }

.console-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--soft-clay);
    margin-left: 8px;
}

.console-body {
    background: var(--deep-forest);
    padding: 1.25rem 0;
    overflow-x: auto;
}

.code-line {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.8;
    color: var(--warm-brown);
    padding: 0 1.5rem;
    white-space: pre;
    display: flex;
    gap: 1rem;
}

.code-line:hover {
    background: rgba(212,168,67,0.06);
}

.line-no {
    display: inline-block;
    width: 2ch;
    text-align: right;
    color: var(--soft-clay);
    opacity: 0.4;
    user-select: none;
    flex-shrink: 0;
}

.code-keyword {
    color: var(--primary-terracotta);
    font-weight: 500;
}

.code-term {
    color: var(--honey-amber);
}

.code-reference {
    color: var(--primary-terracotta);
}

.code-condition {
    color: var(--dusty-rose);
}

.code-comment {
    color: var(--soft-clay);
    opacity: 0.6;
    font-style: italic;
}

/* ---- Footer ---- */
.site-footer {
    background: var(--deep-forest);
    padding: 4rem 2rem;
    text-align: center;
    position: relative;
    z-index: 2;
}

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

.footer-hex {
    width: 40px;
    height: 40px;
    margin: 0 auto 1.5rem;
    opacity: 0.5;
}

.footer-hex svg {
    width: 100%;
    height: 100%;
}

.footer-text {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--dusty-rose);
    letter-spacing: -0.01em;
    margin-bottom: 0.3rem;
}

.footer-sub {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.8rem;
    color: var(--soft-clay);
    opacity: 0.6;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .honeycomb-cluster {
        gap: 1.5rem;
    }

    .cluster-left,
    .cluster-right {
        transform: translateX(0);
    }

    .hex-cell {
        width: 240px;
        min-height: 240px;
    }

    .hex-cell-inner {
        padding: 3rem 1.5rem 2.5rem;
    }

    .debug-console {
        margin-left: 1rem;
        margin-right: 1rem;
    }
}

@media (max-width: 768px) {
    .act {
        padding: 5rem 4vw 4rem;
    }

    .hex-cell {
        width: 100%;
        max-width: 320px;
        min-height: 260px;
        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    }

    .honeycomb-cluster {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }

    .dense .hex-cell,
    .overlap .hex-cell {
        margin: 0;
    }

    .clarity-cell {
        width: 300px;
        min-height: 300px;
    }

    .breathing-space {
        height: 60vh;
    }

    .breath-symbol {
        width: 200px;
        height: 200px;
    }

    .breath-symbol.wide {
        width: 300px;
        height: 150px;
    }

    .nav-petal {
        width: 110px;
        height: 48px;
        font-size: 0.7rem;
        transform: translate(
            calc(-50% + cos(var(--petal-angle)) * 110px),
            calc(-50% + sin(var(--petal-angle)) * 110px)
        );
    }
}

@media (max-width: 480px) {
    .hex-cell {
        max-width: 280px;
        min-height: 240px;
    }

    .hex-cell-inner {
        padding: 2.8rem 1.2rem 2.2rem;
    }

    .hex-cell h3 {
        font-size: 0.95rem;
    }

    .hex-cell p {
        font-size: 0.78rem;
    }

    .hero-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .debug-console {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    .code-line {
        font-size: 0.7rem;
        padding: 0 0.75rem;
    }
}
