/* ==========================================================================
   REVOLVER CSS DESIGN SYSTEM (Paper & Pencil Drafting Theme)
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
    --bg-paper: #f6f4eb;         /* Archival cream paper */
    --bg-sidebar: #eedcb3;       /* Warm sketching board background */
    --bg-card: #faf6eb;          /* Deckled paper sheet highlight */
    --border-sepia: #d5c39a;     /* Soft pencil outline */
    --border-focus: #2e2c2b;     /* Dark graphite focus state */
    
    /* Graphite Shading Palette */
    --graphite-dark: #2e2c2b;    /* Deep charcoal pencil */
    --graphite-medium: #5c5446;  /* Medium graphite sketch lead */
    --graphite-light: #7c6f5d;   /* Light graphite shading */
    --graphite-sepia: #cbb685;   /* Sepia construction line */
    --graphite-ink: #201e1e;     /* Ink drawing black */
    
    /* Text Colors */
    --text-primary: #2e2c2b;     /* Deep charcoal text */
    --text-muted: #6e6454;       /* Sepia muted text */
    --text-bright: #2e2c2b;      /* Sharp pencil black */
    
    /* Animation Speeds */
    --anim-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --anim-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --anim-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & General Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'EB Garamond', serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-paper);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    font-size: 1.05rem;
}

/* Custom Scrollbars in Sepia Theme */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}
::-webkit-scrollbar-thumb {
    background: var(--border-sepia);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--graphite-medium);
}

/* Layout Framework */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* ==========================================================================
   SIDEBAR CONTROLS (Sketching Board Pane)
   ========================================================================== */
.sidebar {
    width: 420px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--graphite-sepia);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--anim-normal), width var(--anim-normal);
    box-shadow: 5px 0 20px rgba(46, 44, 43, 0.12);
    flex-shrink: 0;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute;
}

.app-header {
    padding: 24px;
    border-bottom: 1px solid var(--graphite-sepia);
    background: rgba(0, 0, 0, 0.02);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand i {
    font-size: 1.7rem;
    color: var(--graphite-dark);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.brand h1 {
    font-family: 'Architects Daughter', cursive;
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--graphite-dark);
}

.subtitle {
    font-family: 'EB Garamond', serif;
    font-size: 0.95rem;
    font-style: italic;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ==========================================================================
   CONTROL CARDS & ACCORDIONS
   ========================================================================== */
.control-card {
    background: var(--bg-card);
    border: 1px solid var(--border-sepia);
    border-radius: 6px;
    overflow: hidden;
    transition: all var(--anim-normal);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.control-card:hover {
    border-color: #bbab80;
}

.control-card.active {
    border-color: #a89467;
    box-shadow: 0 2px 10px rgba(168, 148, 103, 0.12);
}

/* Sidebar Tabs */
.tabs-container {
    display: flex;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px dashed var(--border-sepia);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 14px;
    font-family: 'Architects Daughter', cursive;
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--graphite-medium);
    cursor: pointer;
    text-align: center;
    transition: all var(--anim-fast);
    outline: none;
}

.tab-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--graphite-dark);
}

.tab-btn.active {
    background: var(--graphite-dark);
    color: var(--bg-paper);
    border-bottom-color: var(--graphite-dark);
}

.card-header {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px dashed var(--border-sepia);
    user-select: none;
}

.card-header h2 {
    font-family: 'Architects Daughter', cursive;
    font-size: 1.05rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--graphite-dark);
}

.card-header h2 i {
    color: var(--graphite-medium);
    font-size: 0.95rem;
}

.toggle-icon {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform var(--anim-normal);
}

.control-card.collapsed .card-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    opacity: 0;
}

.control-card.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.card-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    opacity: 1;
    transition: max-height var(--anim-normal), padding var(--anim-normal), opacity var(--anim-normal);
}

/* ==========================================================================
   INPUTS, SLIDERS & CONTROLS
   ========================================================================== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group.flex-row {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.row {
    display: flex;
    gap: 12px;
}

.col-6 {
    flex: 1;
}

.col-12 {
    width: 100%;
}

label {
    font-family: 'EB Garamond', serif;
    font-size: 0.95rem;
    color: var(--graphite-medium);
    font-weight: 600;
}

.checkbox-label {
    color: var(--graphite-dark);
    cursor: pointer;
    font-size: 0.95rem;
}

/* Math Input with custom prefix */
.math-input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border-sepia);
    border-radius: 6px;
    padding: 2px 12px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    transition: border-color var(--anim-fast), box-shadow var(--anim-fast);
}

.math-y-prefix {
    font-family: 'Architects Daughter', cursive;
    color: var(--graphite-dark);
    font-size: 0.95rem;
    margin-right: 8px;
    font-weight: bold;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.curve-type-toggle {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-sepia);
    border-radius: 4px;
    padding: 3px 8px;
    font-family: 'Architects Daughter', cursive;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--graphite-dark);
    cursor: pointer;
    user-select: none;
    transition: all var(--anim-fast);
    outline: none;
    margin-right: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.curve-type-toggle:hover {
    background: var(--bg-sidebar);
    border-color: var(--graphite-medium);
}

.math-input-wrapper input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--graphite-dark);
    width: 100%;
    padding: 8px 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
}

.math-input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 5px rgba(46, 44, 43, 0.15);
}

/* Basic Input Boxes */
input[type="number"], select {
    background: #ffffff;
    border: 1px solid var(--border-sepia);
    border-radius: 6px;
    color: var(--graphite-dark);
    padding: 8px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    outline: none;
    width: 100%;
    transition: border-color var(--anim-fast), box-shadow var(--anim-fast);
}

input[type="number"]:focus, select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 5px rgba(46, 44, 43, 0.15);
}

/* Custom Checkbox */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff;
    border: 1px solid var(--border-sepia);
    padding: 8px;
    border-radius: 3px;
    display: inline-block;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: all var(--anim-fast);
}

input[type="checkbox"]:checked {
    background: var(--graphite-dark);
    border-color: var(--graphite-dark);
}

input[type="checkbox"]:checked::after {
    content: '\2714';
    font-size: 10px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--bg-paper);
}

/* Custom Dropdown select indicator styling */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%232e2c2b' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
    cursor: pointer;
}

.input-helper {
    font-family: 'EB Garamond', serif;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--graphite-light);
    line-height: 1.3;
}

/* Radio Button Toggle Layout */
.radio-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-sepia);
    border-radius: 6px;
    overflow: hidden;
    padding: 3px;
}

.radio-toggle input[type="radio"] {
    display: none;
}

.radio-toggle label {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
    cursor: pointer;
    font-family: 'Architects Daughter', cursive;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--graphite-medium);
    border-radius: 4px;
    transition: all var(--anim-fast);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.radio-toggle input[type="radio"]:checked + label {
    background: var(--graphite-dark);
    color: var(--bg-paper);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

/* Sliders with beautiful track & thumb */
.label-with-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tech-value {
    font-family: 'Architects Daughter', cursive;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--graphite-dark);
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-sepia);
}

.slider-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border-sepia);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--graphite-dark);
    border: 1px solid var(--bg-paper);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Buttons */
.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-sepia);
    color: var(--graphite-dark);
    width: 38px;
    height: 38px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--anim-fast);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.icon-btn:hover {
    background: var(--bg-sidebar);
    border-color: var(--graphite-medium);
}

.icon-btn.playing {
    border-color: var(--graphite-dark);
    background: var(--graphite-dark);
    color: var(--bg-paper);
}

/* ==========================================================================
   3D VIEWPORT STAGE
   ========================================================================== */
.viewport-container {
    flex: 1;
    height: 100vh;
    position: relative;
    background-color: var(--bg-paper);
}

#canvas-3d-container {
    width: 100%;
    height: 100%;
    display: block;
}

/* Overlay Top Controls */
.viewport-overlay-top {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 10;
    font-family: 'Architects Daughter', cursive;
}

.overlay-btn {
    pointer-events: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-sepia);
    color: var(--graphite-dark);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--anim-fast);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.overlay-btn:hover {
    background: var(--bg-sidebar);
    border-color: var(--graphite-medium);
    transform: translateY(-2px);
}

.overlay-btn:active {
    transform: translateY(1px);
}

.viewport-title-card {
    background: var(--bg-card);
    border: 1px solid var(--border-sepia);
    padding: 10px 20px;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    pointer-events: auto;
    user-select: none;
    color: var(--graphite-dark);
}

.status-badge {
    font-family: 'Architects Daughter', cursive;
    font-size: 0.7rem;
    font-weight: bold;
    letter-spacing: 0.5px;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid var(--graphite-dark);
    color: var(--graphite-dark);
}

.status-badge.live {
    background: rgba(46, 44, 43, 0.08);
}

#viewport-subtitle {
    font-family: 'Architects Daughter', cursive;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Navigation Hints (Overlay Bottom) */
.viewport-overlay-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 10;
}

.control-hints {
    background: rgba(250, 246, 235, 0.9);
    border: 1px dashed var(--border-sepia);
    padding: 10px 20px;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    gap: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    font-family: 'Architects Daughter', cursive;
}

.control-hints span {
    font-family: 'Architects Daughter', cursive;
    font-size: 0.8rem;
    color: var(--graphite-medium);
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-hints i {
    color: var(--graphite-dark);
    font-size: 0.85rem;
}

.control-hints strong {
    color: var(--graphite-dark);
}

/* ==========================================================================
   TOAST ERRORS (Red-Crayon Sketch Annotation style)
   ========================================================================== */
.error-toast {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: #fdf1f1;
    border: 1px solid #e0b3b3;
    padding: 14px 20px;
    border-radius: 8px;
    color: #a63a3a;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(166, 58, 58, 0.08);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transform: translateY(120px);
    opacity: 0;
    transition: transform var(--anim-normal), opacity var(--anim-normal);
    z-index: 1000;
    pointer-events: none;
    font-family: 'Architects Daughter', cursive;
}

.error-toast.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.error-toast i {
    color: #b83a3a;
    font-size: 1.1rem;
}

.error-toast span {
    font-family: 'Architects Daughter', cursive;
    font-size: 0.85rem;
    font-weight: bold;
}

/* ==========================================================================
   RESPONSIVE DESIGN (Media Queries)
   ========================================================================== */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column-reverse;
    }
    
    .sidebar {
        width: 100%;
        height: 45vh;
        border-right: none;
        border-top: 1px solid var(--graphite-sepia);
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.08);
    }
    
    .viewport-container {
        height: 55vh;
    }
    
    .sidebar-scroll {
        padding: 16px;
    }
    
    .sidebar.collapsed {
        transform: translateY(100%);
        height: 0;
    }

    .viewport-overlay-bottom {
        display: none;
    }
}

@media (max-width: 600px) {
    .sidebar {
        height: 50vh;
    }
    .viewport-container {
        height: 50vh;
    }
    .row {
        flex-direction: column;
        gap: 12px;
    }
}
