/* ============================================================
   Cryogenic Cable Heat Load Calculator
   Aesthetic: Laboratory instrument panel — Lakeshore meets oscilloscope
   ============================================================ */

:root {
    --bg-primary:     #080d12;
    --bg-secondary:   #0e1519;
    --bg-card:        #111a22;
    --bg-inset:       #060a0e;
    --text-primary:   #d8e2ec;
    --text-secondary: #6b8399;
    --text-dim:       #3d5266;
    --accent:         #00d4ff;
    --accent-mid:     rgba(0, 212, 255, 0.4);
    --accent-glow:    rgba(0, 212, 255, 0.12);
    --accent-deep:    rgba(0, 212, 255, 0.06);
    --warm:           #ff9f43;
    --border:         #1a2733;
    --border-light:   #243340;
    --input-bg:       #060a0e;
    --font-display:   'Oxanium', 'Orbitron', sans-serif;
    --font-body:      'Source Sans 3', 'Segoe UI', sans-serif;
    --font-mono:      'Space Mono', 'JetBrains Mono', 'Fira Code', monospace;

    --radius-sm:      4px;
    --radius-md:      6px;
    --radius-lg:      10px;
}

/* ── Reset ── */

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

/* ── Base ── */

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Subtle noise grain */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(0, 212, 255, 0.02) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 100, 180, 0.015) 0%, transparent 50%);
}

/* ── Header ── */

header {
    text-align: center;
    padding: 1.75rem 1.5rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: relative;
}

/* Accent line at very top — like the power-on indicator of an instrument */
header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--accent) 20%,
        var(--accent) 80%,
        transparent 100%
    );
    opacity: 0.7;
}

header h1 {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
}

header .subtitle {
    margin-top: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

header .disclaimer {
    margin-top: 0.4rem;
    font-size: 0.72rem;
    color: var(--warm);
    opacity: 0.85;
}

/* ── Main layout ── */

main {
    max-width: 1400px;
    width: 100%;
    margin: 1.75rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 1.75rem;
    flex: 1;
}

/* ── Panel shared ── */

.input-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.4rem 1.4rem;
    /* Subtle inset shadow for instrument recess feel */
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.02),
        0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Section headings — small caps, accent colored, with divider */

.input-panel h2,
.results-panel h2 {
    font-family: var(--font-display);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-top: 1.25rem;
    margin-bottom: 0.65rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Decorative dash before section titles */
.input-panel h2::before {
    content: '';
    width: 12px;
    height: 1px;
    background: var(--accent);
    opacity: 0.5;
}

.input-panel h2:first-of-type {
    margin-top: 1rem;
}

/* ── Form controls ── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
    min-width: 150px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
}

label {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
}

input[type="number"],
select {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    /* Inset shadow like a recessed control */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}

input[type="number"]:focus,
select:focus {
    border-color: var(--accent);
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.25),
        0 0 0 2px var(--accent-glow),
        0 0 8px var(--accent-deep);
}

input[type="number"]:hover,
select:hover {
    border-color: var(--border-light);
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0.5 0.5l4.5 4.5 4.5-4.5' stroke='%236b8399' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 1.8rem;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.3;
}

/* ── Calculate button ── */

#calculate-btn {
    display: block;
    width: 100%;
    margin-top: 1.35rem;
    padding: 0.65rem 1rem;
    background: linear-gradient(180deg, var(--accent) 0%, #00b8d9 100%);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 212, 255, 0.15);
    position: relative;
    overflow: hidden;
}

#calculate-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 50%);
    pointer-events: none;
}

#calculate-btn:hover {
    background: linear-gradient(180deg, #33ddff 0%, #00c8e8 100%);
    box-shadow:
        0 2px 8px rgba(0, 212, 255, 0.25),
        0 0 20px rgba(0, 212, 255, 0.1);
    transform: translateY(-1px);
}

#calculate-btn:active {
    background: linear-gradient(180deg, #00b8d9 0%, #0099b3 100%);
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 212, 255, 0.1);
}

/* ── Results panel ── */

.results-hidden {
    display: none;
}

.results-visible {
    display: block;
    animation: resultsReveal 0.35s ease-out;
}

@keyframes resultsReveal {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-panel h2 {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* ── Result cards — digital readout style ── */

.result-cards {
    display: flex;
    gap: 0.85rem;
    margin-bottom: 1.4rem;
}

.result-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    /* Recessed readout look */
    box-shadow:
        inset 0 1px 4px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.015);
}

.result-card.primary {
    border-color: rgba(0, 212, 255, 0.3);
    background:
        linear-gradient(135deg, var(--bg-card) 50%, rgba(0, 212, 255, 0.04));
    box-shadow:
        inset 0 1px 4px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(0, 212, 255, 0.04);
}

.result-label {
    font-family: var(--font-body);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.result-value {
    font-family: var(--font-mono);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    /* Subtle digital readout glow */
    text-shadow: 0 0 8px rgba(216, 226, 236, 0.08);
}

.result-card.primary .result-value {
    color: var(--accent);
    text-shadow:
        0 0 10px rgba(0, 212, 255, 0.3),
        0 0 30px rgba(0, 212, 255, 0.08);
}

/* ── Breakdown ── */

.result-breakdown {
    margin-bottom: 1.4rem;
}

.result-breakdown h3,
.chart-container h3 {
    font-family: var(--font-display);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.6rem;
}

/* ── Table — instrument data readout ── */

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

thead th {
    font-family: var(--font-body);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    text-align: left;
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

tbody tr {
    border-bottom: 1px solid rgba(26, 39, 51, 0.6);
    transition: background-color 0.12s ease;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(0, 212, 255, 0.02);
}

tbody td {
    padding: 0.45rem 0.55rem;
    color: var(--text-primary);
    vertical-align: middle;
}

tbody td:first-child {
    color: var(--accent);
    font-weight: 700;
    font-family: var(--font-body);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

/* Fraction column — warm accent */
tbody td:last-child {
    color: var(--warm);
}

/* ── Chart ── */

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

#temp-profile-chart,
#conductivity-chart,
#s21-chart {
    display: block;
    width: 100%;
}

.s21-summary {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-inset);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.s21-summary .s21-col {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.s21-summary .s21-freq {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.s21-summary .s21-val {
    color: var(--accent);
    font-weight: 700;
}

.s21-summary .s21-breakdown {
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.chart-refs {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-body);
    font-size: 0.65rem;
    color: var(--text-dim);
    line-height: 1.6;
}

.chart-refs strong {
    color: var(--text-secondary);
}

/* ── Footer ── */

footer {
    text-align: center;
    padding: 1.1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-body);
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

footer a:hover {
    color: var(--accent);
}

/* ── Responsive ── */

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 500px) {
    header h1 {
        font-size: 1.1rem;
        letter-spacing: 0.04em;
    }

    header .subtitle {
        font-size: 0.68rem;
    }

    main {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    .input-panel {
        padding: 1rem;
    }

    .result-cards {
        flex-direction: column;
    }

    .result-value {
        font-size: 1.2rem;
    }

    table {
        font-size: 0.68rem;
    }

    thead th {
        font-size: 0.52rem;
    }
}

/* ── Selection styling ── */

::selection {
    background: rgba(0, 212, 255, 0.25);
    color: #fff;
}

/* ── Scrollbar ── */

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}
