/* ========================================
   completengine.com - Cottagecore Engine Room
   Palette: Creamy-Pastel with Warm Metallic
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
    /* Core Palette */
    --farmhouse-linen: #FFF8EE;
    --butter-cloth: #F5E6CA;
    --dried-peony: #E8C4B8;
    --morning-garden: #B7C9A8;
    --pressed-flower: #C4A8C8;
    --honeycomb-brass: #C9A96E;
    --chimney-smoke: #4A4440;
    --aged-beam: #2E2520;

    /* Functional Colors */
    --marble-vein: #D4C5A9;
    --panel-glow: rgba(201, 169, 110, 0.12);
    --ticker-bg: rgba(46, 37, 32, 0.92);
    --ticker-text: #F5E6CA;
    --panel-bg: rgba(255, 250, 240, 0.88);

    /* Animation Timing */
    --border-breath: 0;
    --breath-duration: 3s;

    /* Typography Fluid Sizing */
    --heading-primary: clamp(2rem, 5vw + 0.5rem, 4.5rem);
    --heading-section: clamp(1.4rem, 3vw + 0.3rem, 2.8rem);
    --body-text: clamp(1rem, 1.2vw + 0.4rem, 1.25rem);
    --accent-text: clamp(0.7rem, 0.9vw + 0.2rem, 0.85rem);
}

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

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

body {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    color: var(--chimney-smoke);
    background: var(--farmhouse-linen);
    line-height: 1.7;
    letter-spacing: 0.015em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Breathing Animation (Heartbeat) --- */
@keyframes breathe {
    0%, 100% { --border-breath: 0; }
    50% { --border-breath: 1; }
}

@property --border-breath {
    syntax: '<number>';
    initial-value: 0;
    inherits: true;
}

body {
    animation: breathe var(--breath-duration) ease-in-out infinite;
}

/* ========================================
   LAYER 0: THE GREENHOUSE (Background)
   ======================================== */

#greenhouse-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    overflow: hidden;
}

.marble-base {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 120%;
    height: 140%;
    background: linear-gradient(135deg, var(--farmhouse-linen) 0%, var(--butter-cloth) 50%, var(--farmhouse-linen) 100%);
    will-change: transform;
}

.marble-veins {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 120%;
    height: 140%;
    opacity: 0.6;
    pointer-events: none;
}

.marble-veins svg {
    width: 100%;
    height: 100%;
}

.gingham-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(201, 169, 110, 0.06) 0px,
            rgba(201, 169, 110, 0.06) 1px,
            transparent 1px,
            transparent 24px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(201, 169, 110, 0.04) 0px,
            rgba(201, 169, 110, 0.04) 1px,
            transparent 1px,
            transparent 24px
        );
    pointer-events: none;
}

/* ========================================
   LAYER 1: THE TRELLIS FRAME
   ======================================== */

#trellis-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
}

#trellis-frame.visible {
    opacity: 1;
}

.trellis-border {
    position: absolute;
    background: var(--honeycomb-brass);
    animation: trellis-pulse var(--breath-duration) ease-in-out infinite;
}

@keyframes trellis-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.trellis-top {
    top: 28px;
    left: 0;
    width: 100%;
    height: 2px;
}

.trellis-bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
}

.trellis-left {
    top: 28px;
    left: 0;
    width: 2px;
    height: calc(100% - 28px);
}

.trellis-right {
    top: 28px;
    right: 0;
    width: 2px;
    height: calc(100% - 28px);
}

/* Corner Rosettes */
.corner-rosette {
    position: absolute;
    z-index: 11;
    animation: rosette-rotate 8s linear infinite;
}

@keyframes rosette-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(90deg); }
}

.corner-tl { top: 32px; left: 6px; }
.corner-tr { top: 32px; right: 6px; }
.corner-bl { bottom: 6px; left: 6px; }
.corner-br { bottom: 6px; right: 6px; }

/* ========================================
   LAYER 3: THE READOUT TICKER
   ======================================== */

#readout-ticker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 28px;
    z-index: 30;
    background: var(--ticker-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transform: translateY(-100%);
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

#readout-ticker.visible {
    transform: translateY(0);
}

.ticker-dashes {
    position: absolute;
    left: 0;
    width: 200%;
    height: 1px;
    background: repeating-linear-gradient(
        90deg,
        var(--honeycomb-brass) 0px,
        var(--honeycomb-brass) 6px,
        transparent 6px,
        transparent 12px
    );
    animation: ticker-dash-flow 2s linear infinite;
}

@keyframes ticker-dash-flow {
    from { transform: translateX(0); }
    to { transform: translateX(-12px); }
}

.ticker-dashes-top { top: 0; }
.ticker-dashes-bottom { bottom: 0; }

.ticker-content {
    display: flex;
    width: max-content;
    animation: ticker-scroll 60s linear infinite;
}

@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

.ticker-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: var(--accent-text);
    color: var(--ticker-text);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    white-space: nowrap;
    padding: 0 2rem;
    line-height: 28px;
}

/* ========================================
   SCROLL CONTAINER
   ======================================== */

#scroll-container {
    position: relative;
    z-index: 5;
    width: 100%;
}

.scroll-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    position: relative;
}

.scroll-end-spacer {
    height: 30vh;
}

/* ========================================
   LAYER 2: INSTRUMENT PANELS
   ======================================== */

.instrument-panel {
    position: relative;
    background: var(--panel-bg);
    border: 1px solid var(--butter-cloth);
    border-radius: 12px;
    padding: clamp(2rem, 4vw, 3.5rem);
    box-shadow: inset 0 0 30px rgba(201, 169, 110, 0.08);
    max-width: 60vw;
    width: 100%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    /* Dormant state (before intersection) */
    opacity: 0;
    transition:
        opacity 800ms cubic-bezier(0.22, 1, 0.36, 1),
        transform 800ms cubic-bezier(0.22, 1, 0.36, 1),
        border-color 1s ease,
        box-shadow 0.5s ease;
}

/* Panel border color cycling */
@keyframes panel-border-cycle {
    0%, 100% { border-color: var(--butter-cloth); }
    25% { border-color: var(--dried-peony); }
    50% { border-color: var(--morning-garden); }
    75% { border-color: var(--pressed-flower); }
}

.instrument-panel.active {
    opacity: 1;
    transform: translate(0, 0) scale(1) !important;
    border-width: 2px;
    box-shadow:
        inset 0 0 30px rgba(201, 169, 110, 0.08),
        0 0 12px rgba(201, 169, 110, 0.2);
    animation: panel-border-cycle 12s ease-in-out infinite;
}

.instrument-panel.dimmed {
    opacity: 0.4;
    transform: scale(0.95) !important;
    transition:
        opacity 600ms ease,
        transform 600ms ease;
}

/* --- Panel Entry Directions --- */
.panel-garden {
    transform: translateY(-60px);
}
.panel-kitchen {
    transform: translateX(-60px);
    margin-right: auto;
    margin-left: 5vw;
}
.panel-loom {
    transform: scale(0.9);
}
.panel-apiary {
    transform: translateX(60px);
    margin-left: auto;
    margin-right: 5vw;
}
.panel-porch {
    transform: translateY(60px);
}

/* --- Panel Label (Monospace Station ID) --- */
.panel-label {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: var(--accent-text);
    color: var(--honeycomb-brass);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 1rem;
}

/* --- Panel Headings --- */
.panel-heading {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: var(--heading-primary);
    color: var(--aged-beam);
    line-height: 1.2;
    letter-spacing: 0.01em;
    margin-bottom: 1.5rem;
    position: relative;
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
}

h2.panel-heading {
    font-size: var(--heading-section);
}

/* Heading underline wave */
.heading-wave {
    display: block;
    width: 100%;
    height: 8px;
    margin-top: 0.4rem;
    animation: wave-flow 20s linear infinite;
}

@keyframes wave-flow {
    from { transform: translateX(0); }
    to { transform: translateX(-20px); }
}

/* --- Panel Body Text --- */
.panel-body {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: var(--body-text);
    color: var(--chimney-smoke);
    line-height: 1.7;
    letter-spacing: 0.015em;
    margin-bottom: 1.5rem;
}

.panel-body em {
    font-style: italic;
    color: var(--aged-beam);
    font-weight: 500;
}

.panel-body-secondary {
    color: var(--honeycomb-brass);
    font-weight: 500;
    font-size: calc(var(--body-text) * 0.95);
}

/* --- Gingham Divider --- */
.gingham-divider {
    width: 80%;
    height: 1px;
    margin: 2rem auto;
    background:
        repeating-linear-gradient(
            90deg,
            var(--honeycomb-brass) 0px,
            var(--honeycomb-brass) 4px,
            transparent 4px,
            transparent 8px
        );
    opacity: 0.4;
}

/* --- Panel Corner Rosettes --- */
.panel-rosette {
    position: absolute;
    z-index: 2;
    animation: rosette-rotate 8s linear infinite;
}

.panel-rosette-tl { top: 8px; left: 8px; }
.panel-rosette-tr { top: 8px; right: 8px; }
.panel-rosette-bl { bottom: 8px; left: 8px; }
.panel-rosette-br { bottom: 8px; right: 8px; }

/* ========================================
   PANEL 2: THE KITCHEN - Specifics
   ======================================== */

.gingham-texture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(201, 169, 110, 0.04) 0px,
            rgba(201, 169, 110, 0.04) 1px,
            transparent 1px,
            transparent 16px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(201, 169, 110, 0.03) 0px,
            rgba(201, 169, 110, 0.03) 1px,
            transparent 1px,
            transparent 16px
        );
    pointer-events: none;
    z-index: 0;
}

/* Wheat icon list */
.wheat-list {
    list-style: none;
    margin: 1.5rem 0;
    padding: 0;
}

.wheat-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: var(--body-text);
    color: var(--chimney-smoke);
    line-height: 1.6;
}

.wheat-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    margin-top: 0.2em;
}

/* Herringbone Progress Bar */
.herringbone-progress {
    position: relative;
    width: 100%;
    height: 24px;
    margin-top: 2rem;
    border-radius: 4px;
    overflow: hidden;
    background: var(--farmhouse-linen);
    border: 1px solid var(--butter-cloth);
}

.herringbone-bar {
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            45deg,
            var(--dried-peony) 0px,
            var(--dried-peony) 8px,
            var(--butter-cloth) 8px,
            var(--butter-cloth) 16px
        ),
        repeating-linear-gradient(
            -45deg,
            var(--dried-peony) 0px,
            var(--dried-peony) 8px,
            var(--butter-cloth) 8px,
            var(--butter-cloth) 16px
        );
    background-size: 22px 22px;
    animation: herringbone-flow 3s linear infinite;
}

@keyframes herringbone-flow {
    from { background-position: 0 0, 0 0; }
    to { background-position: 22px 0, 22px 0; }
}

.progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: var(--accent-text);
    color: var(--aged-beam);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-shadow: 0 0 4px rgba(255, 248, 238, 0.8);
}

/* ========================================
   PANEL 3: THE LOOM - Specifics
   ======================================== */

.herringbone-texture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background:
        repeating-linear-gradient(
            45deg,
            rgba(201, 169, 110, 0.04) 0px,
            rgba(201, 169, 110, 0.04) 6px,
            transparent 6px,
            transparent 12px
        ),
        repeating-linear-gradient(
            -45deg,
            rgba(201, 169, 110, 0.03) 0px,
            rgba(201, 169, 110, 0.03) 6px,
            transparent 6px,
            transparent 12px
        );
    pointer-events: none;
    z-index: 0;
}

/* Loom border cycles faster (8s) */
.panel-loom.active {
    animation: panel-border-cycle 8s ease-in-out infinite;
}

/* Loom Readouts Grid */
.loom-readouts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 248, 238, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(201, 169, 110, 0.2);
}

.readout-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.readout-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: calc(var(--accent-text) * 0.9);
    color: var(--honeycomb-brass);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.readout-value {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.1rem, 1.5vw + 0.3rem, 1.5rem);
    color: var(--aged-beam);
    letter-spacing: 0.05em;
}

/* ========================================
   PANEL 4: THE APIARY - Specifics
   ======================================== */

.honeycomb-texture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    pointer-events: none;
    z-index: 0;
    /* CSS-only honeycomb approximation */
    background-image:
        radial-gradient(circle at 50% 50%, rgba(201, 169, 110, 0.03) 30%, transparent 31%),
        radial-gradient(circle at 0% 50%, rgba(201, 169, 110, 0.03) 30%, transparent 31%),
        radial-gradient(circle at 100% 50%, rgba(201, 169, 110, 0.03) 30%, transparent 31%);
    background-size: 40px 24px;
    background-position: 0 0, 20px 12px, 20px 12px;
}

.bee-icon {
    vertical-align: middle;
    margin: 0 0.15em;
}

/* Hive Outputs Grid */
.hive-outputs {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(201, 169, 110, 0.06);
    border-radius: 8px;
    border: 1px solid rgba(201, 169, 110, 0.15);
}

.output-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.output-value {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    color: var(--honeycomb-brass);
    line-height: 1.1;
    font-variation-settings: 'WONK' 0, 'SOFT' 50;
}

.output-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: calc(var(--accent-text) * 0.85);
    color: var(--chimney-smoke);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* ========================================
   PANEL 5: THE PORCH - Specifics
   ======================================== */

.panel-porch {
    /* Slowest breathing border */
}

.panel-porch.active {
    animation: panel-border-cycle-slow 5s ease-in-out infinite;
}

@keyframes panel-border-cycle-slow {
    0%, 100% { border-color: var(--butter-cloth); }
    25% { border-color: var(--dried-peony); }
    50% { border-color: var(--morning-garden); }
    75% { border-color: var(--pressed-flower); }
}

.porch-contact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    margin: 2rem 0 1.5rem;
    padding: 1.5rem;
    background: rgba(255, 248, 238, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(201, 169, 110, 0.2);
}

.contact-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: var(--accent-text);
    color: var(--honeycomb-brass);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.contact-value {
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: var(--body-text);
    color: var(--aged-beam);
    letter-spacing: 0.02em;
}

/* Cross-stitch footer */
.cross-stitch-footer {
    margin-top: 2rem;
    text-align: center;
    overflow: hidden;
}

.cross-stitch-footer svg {
    display: block;
    opacity: 0.7;
}

/* ========================================
   DOTTED SWISS OVERLAY (for secondary elements)
   ======================================== */

.dotted-swiss {
    background-image: radial-gradient(
        circle,
        rgba(201, 169, 110, 0.03) 1px,
        transparent 1px
    );
    background-size: 16px 16px;
}

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

@media (max-width: 900px) {
    .instrument-panel {
        max-width: 90vw;
    }

    .panel-kitchen {
        margin-left: auto;
        margin-right: auto;
    }

    .panel-apiary {
        margin-left: auto;
        margin-right: auto;
    }

    .loom-readouts {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .hive-outputs {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .corner-rosette {
        display: none;
    }
}

@media (max-width: 600px) {
    .instrument-panel {
        max-width: 95vw;
        padding: clamp(1.2rem, 3vw, 2rem);
    }

    .loom-readouts {
        grid-template-columns: 1fr;
    }

    .scroll-section {
        padding: 40px 12px;
    }

    .panel-rosette {
        display: none;
    }
}

/* ========================================
   VARIABLE FONT AXIS CLASSES
   (Applied via JS based on scroll position)
   ======================================== */

.wonk-full {
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
}

.wonk-high {
    font-variation-settings: 'WONK' 0.7, 'SOFT' 80;
}

.wonk-mid {
    font-variation-settings: 'WONK' 0.4, 'SOFT' 50;
}

.wonk-low {
    font-variation-settings: 'WONK' 0.2, 'SOFT' 30;
}

.wonk-none {
    font-variation-settings: 'WONK' 0, 'SOFT' 0;
}

/* ========================================
   LOADING / HERRINGBONE TRANSITION
   ======================================== */

@keyframes herringbone-loading {
    from { background-position: 0 0; }
    to { background-position: 44px 0; }
}

.loading-herringbone {
    background:
        repeating-linear-gradient(
            45deg,
            var(--dried-peony) 0px,
            var(--dried-peony) 8px,
            var(--butter-cloth) 8px,
            var(--butter-cloth) 16px
        );
    background-size: 22px 22px;
    animation: herringbone-loading 1s linear infinite;
}

/* ========================================
   CROSS-STITCH LOADING ANIMATION
   ======================================== */

@keyframes cross-stitch-appear {
    0% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0.7; transform: scale(1); }
}

/* ========================================
   SELECTION STYLING
   ======================================== */

::selection {
    background: rgba(201, 169, 110, 0.3);
    color: var(--aged-beam);
}

::-moz-selection {
    background: rgba(201, 169, 110, 0.3);
    color: var(--aged-beam);
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--farmhouse-linen);
}

::-webkit-scrollbar-thumb {
    background: var(--honeycomb-brass);
    border-radius: 4px;
    opacity: 0.6;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--chimney-smoke);
}
