/* ================================================================
   SegerScale — Ceramic Glaze Chemistry Engine
   Kiln-fired earthy dark theme · Split dashboard layout
   ================================================================ */

/* -- Design Tokens ------------------------------------------------ */
:root {
    --color-bg: #0f0d0a;
    --color-surface: #1a1714;
    --color-surface-alt: #231f1a;
    --color-text: #e8dcc8;
    --color-text-muted: #7a6e5e;
    --color-accent: #d4a574;
    --color-accent-glow: rgba(212, 165, 116, 0.15);

    /* Zone colors */
    --color-gloss: #2563eb;
    --color-satin: #0891b2;
    --color-matte: #16a34a;
    --color-craze: #dc2626;
    --color-underfire: #78716c;
    --color-safe: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;

    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    -webkit-font-smoothing: antialiased;
}

/* -- Header ------------------------------------------------------- */
.app-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.app-header .accent {
    color: var(--color-accent);
}

.app-header p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.3rem;
}

/* -- Ad Placeholders ---------------------------------------------- */
.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(122, 110, 94, 0.3);
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    margin: 0 auto;
    width: 100%;
}

.ad-mobile { height: 50px; max-width: 320px; }
.ad-desktop { display: none; height: 90px; max-width: 728px; }

/* -- Main Layout -------------------------------------------------- */
.app-main {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* -- Sidebar ------------------------------------------------------ */
.sidebar { width: 100%; }

.input-panel {
    background: var(--color-surface);
    border: 1px solid rgba(148, 163, 184, 0.06);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 0.6rem;
}

.input-panel h2 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}

.input-group {
    margin-bottom: 0.6rem;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.2rem;
}

.input-group select {
    width: 100%;
    background: var(--color-surface-alt);
    border: 1px solid rgba(148, 163, 184, 0.1);
    color: var(--color-text);
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
}

.input-group select:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* Range Sliders */
input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: var(--color-surface-alt);
    border-radius: 3px;
    outline: none;
    margin-top: 0.3rem;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    border: 2px solid var(--color-bg);
    box-shadow: 0 0 6px rgba(212, 165, 116, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    border: 2px solid var(--color-bg);
}

.input-group output {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-top: 0.15rem;
    font-variant-numeric: tabular-nums;
}

/* Flux Unity Summary */
.flux-summary {
    border: 1px solid rgba(212, 165, 116, 0.2);
}

.unity-bar-wrap {
    width: 100%;
    height: 8px;
    background: var(--color-surface-alt);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.unity-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.2s ease, background 0.2s ease;
    background: var(--color-safe);
}

.unity-bar.over { background: var(--color-danger); }
.unity-bar.under { background: var(--color-warning); }

.unity-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    color: var(--color-text-muted);
}

.unity-label.exact { color: var(--color-safe); }
.unity-label.warning { color: var(--color-warning); }
.unity-label.danger { color: var(--color-danger); }

/* -- Main View ---------------------------------------------------- */
.main-view { width: 100%; }

.results-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.result-card {
    background: var(--color-surface);
    border: 1px solid rgba(148, 163, 184, 0.06);
    border-radius: var(--radius);
    padding: 0.75rem;
    text-align: center;
}

.result-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: 0.2rem;
}

.result-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
}

.status-card.safe { border-color: var(--color-safe); }
.status-card.safe .result-value { color: var(--color-safe); }
.status-card.warning { border-color: var(--color-warning); }
.status-card.warning .result-value { color: var(--color-warning); }
.status-card.danger { border-color: var(--color-danger); }
.status-card.danger .result-value { color: var(--color-danger); }

/* SVG Viewport */
.svg-viewport {
    background: var(--color-surface);
    border: 1px solid rgba(148, 163, 184, 0.06);
    border-radius: var(--radius-lg);
    padding: 1rem;
    overflow: hidden;
}

.chart-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-accent);
    text-align: center;
    margin-bottom: 0.5rem;
}

#stullChart {
    width: 100%;
    height: auto;
    min-height: 300px;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.75rem;
    padding: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.legend-swatch {
    width: 14px;
    height: 10px;
    border-radius: 2px;
}

.gloss-swatch { background: var(--color-gloss); opacity: 0.7; }
.satin-swatch { background: var(--color-satin); opacity: 0.7; }
.matte-swatch { background: var(--color-matte); opacity: 0.7; }
.craze-swatch { background: var(--color-craze); opacity: 0.7; }
.underfire-swatch { background: var(--color-underfire); opacity: 0.7; }

/* UMF Table */
.umf-table-section {
    margin-top: 1rem;
    background: var(--color-surface);
    border: 1px solid rgba(148, 163, 184, 0.06);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.umf-table-section h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-accent);
    margin-bottom: 0.75rem;
}

.umf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.umf-table th {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.umf-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.05);
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.umf-table .oxide-name { color: var(--color-text-muted); font-weight: 600; }
.umf-table .oxide-val { font-weight: 700; }

/* -- Animations --------------------------------------------------- */
@keyframes pulseGlow {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.4)); }
    50% { filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.8)); }
}

.formula-point-danger {
    animation: pulseGlow 0.8s ease-in-out infinite;
}

/* -- Footer ------------------------------------------------------- */
.app-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ================================================================
   RESPONSIVE — Desktop
   ================================================================ */
@media (min-width: 768px) {
    .ad-mobile { display: none; }
    .ad-desktop { display: flex; }

    .dashboard {
        flex-direction: row;
        align-items: flex-start;
    }

    .sidebar {
        width: 310px;
        flex-shrink: 0;
        max-height: calc(100vh - 6rem);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--color-accent) var(--color-surface);
    }

    .sidebar::-webkit-scrollbar { width: 5px; }
    .sidebar::-webkit-scrollbar-track { background: var(--color-surface); }
    .sidebar::-webkit-scrollbar-thumb { background: var(--color-accent); border-radius: 3px; }

    .main-view {
        flex: 1;
        min-width: 0;
    }

    .results-strip {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ═══════════════ AFFILIATE & SEO ═══════════════ */
.seo-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 2rem 0;
}
.seo-card h2 {
    color: var(--color-accent);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}
.seo-card p {
    color: var(--color-text-muted);
    line-height: 1.6;
}
.affiliate-gear a {
    color: var(--color-accent);
    font-weight: 600;
    text-decoration: none;
}
.affiliate-gear a:hover {
    color: var(--color-text);
    text-decoration: underline;
}
