/* ============================================
   BBOTTL.com - Styles
   Honeyed Neutral Terminal + Bottle Label
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --terminal-bg: #1C1914;
    --sidebar-bg: #F2E8D5;
    --text-honey: #E8C87A;
    --text-dusty: #B8956A;
    --accent-caramel: #D4843E;
    --highlight-gold: #F5C842;
    --sidebar-text: #3B2F20;
    --border-smoked: #4A3F32;
    --error-copper: #C45D3E;
    --success-verdigris: #6B9E7A;
    --code-bg: #141110;
    --noise-dark: #241E17;

    --font-mono: 'IBM Plex Mono', monospace;
    --font-display: 'Fraunces', serif;
    --font-handwritten: 'Caveat', cursive;

    --sidebar-width: 280px;

    --spring-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-honey);
    background: var(--terminal-bg);
    display: flex;
    flex-direction: row;
}

/* --- Sidebar --- */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    border-right: 3px solid var(--border-smoked);
    overflow: hidden;
}

#sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px 16px;
    position: relative;
    z-index: 2;
    overflow-y: auto;
}

/* Paper texture overlay */
#sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 28px,
            rgba(59, 47, 32, 0.04) 28px,
            rgba(59, 47, 32, 0.04) 29px
        );
    pointer-events: none;
    z-index: 1;
}

/* Sidebar Header */
#sidebar-header {
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px dashed var(--border-smoked);
}

#ascii-bottle {
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.2;
    color: var(--sidebar-text);
    white-space: pre;
    display: block;
    margin: 0 auto;
}

#sidebar-title {
    display: block;
    font-size: 18px;
    color: var(--accent-caramel);
    margin-top: 8px;
    line-height: 1.3;
}

.caveat {
    font-family: var(--font-handwritten);
}

.fraunces {
    font-family: var(--font-display);
    font-variation-settings: 'WONK' 0, 'SOFT' 50;
}

/* Liquid Canvas */
#liquid-canvas {
    width: 100%;
    height: 160px;
    min-height: 100px;
    border-radius: 8px;
    margin-bottom: 12px;
    background: rgba(59, 47, 32, 0.06);
}

/* Label Metadata */
#label-metadata {
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--border-smoked);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.3);
}

.label-field {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    border-bottom: 1px dotted rgba(74, 63, 50, 0.3);
}

.label-field:last-child {
    border-bottom: none;
}

.label-key {
    font-size: 16px;
    color: var(--accent-caramel);
}

.label-value {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--sidebar-text);
    letter-spacing: 0.5px;
}

/* Sidebar Navigation */
#sidebar-nav {
    margin-bottom: 16px;
}

.nav-label {
    display: block;
    font-size: 18px;
    color: var(--accent-caramel);
    margin-bottom: 6px;
}

#sidebar-nav ul {
    list-style: none;
}

#sidebar-nav li {
    margin-bottom: 4px;
}

.nav-link {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--sidebar-text);
    text-decoration: none;
    display: block;
    padding: 4px 8px;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.nav-link:hover {
    background: var(--accent-caramel);
    color: var(--sidebar-bg);
}

/* Fill Indicator */
#fill-indicator {
    margin-top: auto;
    text-align: center;
    padding-top: 12px;
}

#fill-indicator > .caveat {
    font-size: 16px;
    color: var(--accent-caramel);
    display: block;
    margin-bottom: 6px;
}

#fill-bar {
    width: 100%;
    height: 12px;
    background: rgba(74, 63, 50, 0.15);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-smoked);
}

#fill-level {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-caramel), var(--highlight-gold));
    border-radius: 6px;
    transition: width 0.3s ease;
}

#fill-percent {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--sidebar-text);
    display: block;
    margin-top: 4px;
}

/* --- Mobile Header --- */
#mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--sidebar-bg);
    border-bottom: 2px solid var(--border-smoked);
    z-index: 200;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

#mobile-ascii {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--sidebar-text);
}

#mobile-toggle {
    background: none;
    border: none;
    cursor: pointer;
    width: 28px;
    height: 22px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#mobile-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--sidebar-text);
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

#mobile-toggle.active span:nth-child(1) {
    transform: translateY(9.5px) rotate(45deg);
}

#mobile-toggle.active span:nth-child(2) {
    opacity: 0;
}

#mobile-toggle.active span:nth-child(3) {
    transform: translateY(-9.5px) rotate(-45deg);
}

/* --- Terminal (Main Area) --- */
#terminal {
    flex: 1;
    margin-left: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--terminal-bg);
    overflow: hidden;
}

#noise-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.15;
}

#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#terminal-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px 48px;
    position: relative;
    z-index: 1;
    scroll-behavior: smooth;
}

/* --- Message Sections --- */
.message {
    margin-bottom: 48px;
    opacity: 0;
    transform: translateY(30px);
    transition: none;
}

.message.visible {
    opacity: 1;
    transform: translateY(0);
}

.message-header {
    margin-bottom: 12px;
}

.grid-coord {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dusty);
    letter-spacing: 1px;
    opacity: 0.7;
}

/* Section Headings - Fraunces expressive */
.section-heading {
    font-size: 36px;
    font-weight: 700;
    color: var(--highlight-gold);
    margin-bottom: 20px;
    line-height: 1.2;
    font-variation-settings: 'WONK' 0, 'SOFT' 50;
    transition: font-variation-settings 0.3s;
}

.section-heading:hover {
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
}

.message-body p {
    margin-bottom: 16px;
    color: var(--text-honey);
    max-width: 680px;
}

.message-body p:last-child {
    margin-bottom: 0;
}

/* Terminal-style lines */
.terminal-line {
    padding-left: 24px;
    position: relative;
}

.terminal-line .prompt {
    color: var(--success-verdigris);
    font-weight: 600;
    position: absolute;
    left: 0;
}

.terminal-line .cmd {
    color: var(--highlight-gold);
    font-weight: 600;
}

.cmd-inline {
    color: var(--highlight-gold);
    font-weight: 600;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Pull Quotes */
.pull-quote {
    font-size: 28px;
    font-weight: 400;
    color: var(--accent-caramel);
    font-style: italic;
    margin: 32px 0;
    padding: 16px 24px;
    border-left: 3px solid var(--accent-caramel);
    line-height: 1.4;
    font-variation-settings: 'WONK' 1, 'SOFT' 80;
}

/* Code Block */
.code-block {
    background: var(--code-bg);
    border: 1px solid var(--border-smoked);
    border-radius: 4px;
    padding: 20px 24px;
    margin: 20px 0;
    overflow-x: auto;
}

.code-block pre {
    margin: 0;
}

.code-block code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-honey);
    line-height: 1.8;
}

/* Archive Entries */
.archive-entry {
    display: flex;
    gap: 24px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(74, 63, 50, 0.3);
    font-size: 13px;
}

.archive-id {
    color: var(--accent-caramel);
    font-weight: 600;
    min-width: 100px;
}

.archive-date {
    color: var(--text-dusty);
    min-width: 90px;
}

.archive-origin {
    color: var(--text-dusty);
    min-width: 80px;
}

.archive-status {
    color: var(--success-verdigris);
    font-weight: 600;
}

.archive-entry .archive-status {
    color: var(--success-verdigris);
}

.archive-entry:nth-child(3) .archive-status {
    color: var(--highlight-gold);
}

.archive-entry:nth-child(4) .archive-status {
    color: var(--accent-caramel);
}

.closing-line {
    color: var(--text-dusty);
    font-weight: 600;
    text-align: center;
    margin-top: 32px;
    letter-spacing: 2px;
}

/* --- Typed Content (Intro) --- */
#intro-text {
    min-height: 120px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-honey);
    line-height: 1.8;
}

.cursor {
    display: inline;
    color: var(--highlight-gold);
    font-weight: 600;
}

.cursor.blink {
    animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* --- ASCII Dividers --- */
.ascii-divider {
    text-align: center;
    margin: 24px 0;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.6s, transform 0.6s var(--spring-bounce);
}

.ascii-divider.visible {
    opacity: 1;
    transform: scale(1);
}

.ascii-divider pre {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--border-smoked);
    line-height: 1.3;
    display: inline-block;
}

/* --- Barcode Strips --- */
.barcode-strip {
    height: 20px;
    margin: 16px 0;
    background: repeating-linear-gradient(
        90deg,
        var(--border-smoked) 0px,
        var(--border-smoked) 2px,
        transparent 2px,
        transparent 5px,
        var(--border-smoked) 5px,
        var(--border-smoked) 6px,
        transparent 6px,
        transparent 10px,
        var(--border-smoked) 10px,
        var(--border-smoked) 13px,
        transparent 13px,
        transparent 15px,
        var(--border-smoked) 15px,
        var(--border-smoked) 16px,
        transparent 16px,
        transparent 22px,
        var(--border-smoked) 22px,
        var(--border-smoked) 24px,
        transparent 24px,
        transparent 26px,
        var(--border-smoked) 26px,
        var(--border-smoked) 28px,
        transparent 28px,
        transparent 34px
    );
    opacity: 0.4;
}

/* --- Chemical Diagrams --- */
.chemical-diagram {
    margin: 24px 0;
    padding: 12px 0;
    overflow: hidden;
}

.molecule-svg {
    width: 100%;
    max-width: 600px;
    height: auto;
    display: block;
}

.molecule-svg circle,
.molecule-svg line {
    opacity: 0.6;
}

.draw-line {
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    transition: stroke-dashoffset 1.5s ease;
}

.chemical-diagram.visible .draw-line {
    stroke-dashoffset: 0;
}

/* --- Waveform Accents --- */
.waveform-accent {
    margin: 20px 0;
    overflow: hidden;
}

.wave-svg {
    width: 100%;
    max-width: 600px;
    height: 30px;
    display: block;
}

.wave-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 2s ease;
}

.waveform-accent.visible .wave-path {
    stroke-dashoffset: 0;
}

/* --- Terminal Input --- */
#terminal-input-area {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    background: var(--code-bg);
    border-top: 1px solid var(--border-smoked);
    position: relative;
    z-index: 5;
    flex-shrink: 0;
}

#terminal-prompt {
    display: flex;
    gap: 0;
    white-space: nowrap;
    margin-right: 8px;
    font-size: 14px;
}

.prompt-user {
    color: var(--success-verdigris);
    font-weight: 600;
}

.prompt-separator {
    color: var(--text-dusty);
}

.prompt-path {
    color: var(--accent-caramel);
    font-weight: 600;
}

.prompt-symbol {
    color: var(--text-honey);
    margin-left: 4px;
}

#terminal-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-honey);
    caret-color: var(--highlight-gold);
}

#terminal-input::placeholder {
    color: rgba(184, 149, 106, 0.4);
}

/* --- Terminal Output (command results) --- */
.terminal-output {
    margin: 16px 0;
    padding: 12px 0;
}

.terminal-output-line {
    opacity: 0;
    transform: translateY(10px);
    color: var(--text-honey);
    font-size: 14px;
    line-height: 1.6;
}

.terminal-output-line.revealed {
    opacity: 1;
    transform: translateY(0);
}

.terminal-output pre {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-honey);
    white-space: pre;
    line-height: 1.4;
}

/* --- Footer / Sediment Layer --- */
#sediment {
    background: var(--code-bg);
    border-top: 2px solid var(--border-smoked);
    padding: 20px 48px;
    margin-left: var(--sidebar-width);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    display: none;
}

#sediment.visible {
    display: block;
}

#sediment-content {
    max-width: 680px;
}

.sediment-line {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dusty);
    line-height: 1.8;
    letter-spacing: 0.5px;
    opacity: 0.6;
}

.sediment-micro {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--border-smoked);
    margin-top: 8px;
    letter-spacing: 2px;
}

/* --- Spring Animation Keyframes --- */
@keyframes springEnter {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    40% {
        opacity: 1;
        transform: translateY(-8px) scale(1.02);
    }
    60% {
        transform: translateY(4px) scale(0.99);
    }
    80% {
        transform: translateY(-2px) scale(1.005);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes springPop {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.8;
    }
    70% {
        transform: scale(0.9);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.1);
        opacity: 0;
    }
}

.spring-enter {
    animation: springEnter 0.7s var(--spring-bounce) forwards;
}

/* --- Cork Pop Particles --- */
.cork-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
}

/* --- Scrollbar Styling --- */
#terminal-content::-webkit-scrollbar {
    width: 8px;
}

#terminal-content::-webkit-scrollbar-track {
    background: var(--code-bg);
}

#terminal-content::-webkit-scrollbar-thumb {
    background: var(--border-smoked);
    border-radius: 4px;
}

#terminal-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-dusty);
}

#sidebar-inner::-webkit-scrollbar {
    width: 4px;
}

#sidebar-inner::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar-inner::-webkit-scrollbar-thumb {
    background: rgba(74, 63, 50, 0.3);
    border-radius: 2px;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    #sidebar {
        display: none;
    }

    #sidebar.mobile-open {
        display: flex;
        position: fixed;
        top: 50px;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        min-width: 100%;
        z-index: 150;
    }

    #mobile-header {
        display: flex;
    }

    #terminal {
        margin-left: 0;
        margin-top: 50px;
        height: calc(100vh - 50px);
    }

    #terminal-content {
        padding: 24px 20px;
    }

    #terminal-input-area {
        padding: 10px 16px;
    }

    .section-heading {
        font-size: 26px;
    }

    .pull-quote {
        font-size: 22px;
    }

    .archive-entry {
        flex-wrap: wrap;
        gap: 8px;
    }

    #sediment {
        margin-left: 0;
        padding: 16px 20px;
    }
}

/* --- Utility --- */
.hidden {
    display: none;
}

/* Ensure the welcome section is visible by default for typing effect */
#msg-welcome {
    opacity: 1;
    transform: translateY(0);
}
