/* ============================================
   SVG viewBox Explainer — Styles
   Theme: Blueprint aesthetic (dark, cyan grid)
   ============================================ */

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

:root {
    --bg: #0A0E14;
    --bg-card: rgba(12, 22, 32, 0.85);
    --bg-card-hover: rgba(18, 32, 48, 0.9);
    --bg-input: rgba(0, 20, 40, 0.6);
    --border: rgba(0, 212, 255, 0.2);
    --border-hover: rgba(0, 212, 255, 0.4);
    --primary: #00D4FF;
    --primary-hover: #33DFFF;
    --secondary: #0088CC;
    --camera: #FF4444;
    --camera-bg: rgba(255, 68, 68, 0.15);
    --element: #4488FF;
    --element-bg: rgba(68, 136, 255, 0.1);
    --accent: #FFD700;
    --text: #E0EAF0;
    --text-muted: #8899AA;
    --text-dim: #556677;
    --danger: #FF6B6B;
    --success: #2ED573;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --transition: 200ms ease;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --glass: blur(10px);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* --- Header --- */
.app-header {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.08), rgba(0, 136, 204, 0.04));
    border-bottom: 1px solid var(--border);
    backdrop-filter: var(--glass);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* --- Layout --- */
.app-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    align-items: start;
}

/* --- Canvas Panel --- */
.canvas-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.canvas-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.coords {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    background: var(--bg-card);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.canvas-container {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    min-height: 500px;
}

.world-svg {
    width: 100%;
    height: 500px;
    display: block;
    cursor: grab;
}

.world-svg:active {
    cursor: grabbing;
}

.canvas-tooltip {
    position: absolute;
    background: rgba(10, 14, 20, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.65rem;
    font-size: 0.75rem;
    font-family: var(--mono);
    color: var(--text);
    pointer-events: none;
    z-index: 50;
    white-space: nowrap;
}

.canvas-legend {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

/* --- Controls Panel --- */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 0.25rem;
}

.controls-panel::-webkit-scrollbar {
    width: 4px;
}

.controls-panel::-webkit-scrollbar-track {
    background: transparent;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

.control-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    backdrop-filter: var(--glass);
}

.control-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
}

.control-hint {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(0, 212, 255, 0.06);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    word-break: break-all;
}

.control-hint span {
    color: var(--accent);
    font-weight: 600;
}

.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.control-grid.two-col {
    grid-template-columns: 1fr 1fr;
}

.control-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.control-field label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.input-num {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.4rem 0.5rem;
    font-family: var(--mono);
    font-size: 0.85rem;
    width: 100%;
    transition: border-color var(--transition);
}

.input-num:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: rgba(0, 212, 255, 0.12);
    border-radius: 999px;
    outline: none;
    margin-top: 0.15rem;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.4);
    transition: transform 150ms ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.select-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.4rem 0.5rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    width: 100%;
    cursor: pointer;
    transition: border-color var(--transition);
}

.select-control:focus {
    outline: none;
    border-color: var(--primary);
}

.par-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.par-value {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(255, 215, 0, 0.06);
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* --- Sample Buttons --- */
.sample-buttons {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.7rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-sample {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-sample:hover,
.btn-sample.active {
    border-color: var(--primary);
    color: var(--text);
    background: rgba(0, 212, 255, 0.1);
}

.btn-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-copy:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* --- Preview --- */
.preview-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    overflow: hidden;
}

#preview-svg {
    background: #111822;
    border: 1px dashed rgba(0, 212, 255, 0.3);
}

/* --- Code Output --- */
.code-output {
    position: relative;
    background: rgba(0, 5, 15, 0.8);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    overflow-x: auto;
}

.code-output pre {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-output .attr-name {
    color: var(--primary);
}

.code-output .attr-value {
    color: var(--accent);
}

.code-output .tag {
    color: var(--camera);
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        max-height: none;
    }

    .world-svg {
        height: 350px;
    }

    .app-header {
        padding: 1rem;
    }

    .app-main {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .control-grid {
        grid-template-columns: 1fr;
    }

    .par-controls {
        grid-template-columns: 1fr;
    }
}