/*
 * SPDX-FileCopyrightText: 2026 Alexander Metzger
 * SPDX-License-Identifier: GPL-2.0-only
 */

:root {
    color-scheme: light;
    --ink: #171a1f;
    --muted: #5f6671;
    --panel: rgba(251, 251, 248, 0.88);
    --panel-strong: rgba(255, 255, 252, 0.96);
    --border: rgba(32, 38, 46, 0.16);
    --blue: #0867d8;
    --blue-strong: #095fc4;
    --blue-soft: rgba(8, 103, 216, 0.13);
    --green: #237052;
    --surface: #f5f5f0;
    --shadow: 0 18px 46px rgba(29, 35, 43, 0.15);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--surface);
}

button,
select,
textarea {
    font: inherit;
}

button,
select {
    min-height: 40px;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    padding: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(244, 245, 241, 0.94)),
        #f7f7f3;
}

.calculator-stage {
    width: min(1380px, 100%);
    min-height: calc(100vh - 44px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(360px, 0.82fr) minmax(0, 1.18fr);
    gap: 16px;
}

.input-panel,
.result-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-strong);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.input-panel {
    display: grid;
    align-content: start;
    gap: 16px;
    padding: 20px;
}

.panel-header {
    display: grid;
    gap: 8px;
}

.eyebrow {
    margin: 0;
    color: var(--blue);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(30px, 4vw, 54px);
    line-height: 0.98;
    letter-spacing: 0;
}

.lede {
    max-width: 52ch;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.48;
}

.control-grid,
.example-row {
    display: grid;
    gap: 10px;
}

.control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.example-row {
    grid-template-columns: minmax(0, 1fr) 92px;
    align-items: end;
}

.field {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 780;
}

select,
textarea {
    width: 100%;
    border: 1px solid rgba(32, 38, 46, 0.18);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

select {
    padding: 0 10px;
}

select:focus,
textarea:focus,
button:focus-visible {
    outline: 2px solid rgba(8, 103, 216, 0.28);
    outline-offset: 2px;
}

textarea {
    min-height: 340px;
    max-height: 52vh;
    resize: vertical;
    padding: 13px 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.45;
}

.secondary-action,
.primary-action {
    border-radius: 8px;
    font-weight: 800;
}

.secondary-action {
    border: 1px solid rgba(32, 38, 46, 0.16);
    background: #fff;
    color: var(--ink);
}

.secondary-action:hover {
    border-color: rgba(8, 103, 216, 0.42);
    background: rgba(255, 255, 255, 0.95);
}

.primary-action {
    min-height: 44px;
    border: 1px solid rgba(5, 73, 154, 0.18);
    background: var(--blue-strong);
    color: #fff;
    padding: 0 20px;
    box-shadow: 0 8px 28px rgba(17, 68, 125, 0.19);
}

.primary-action:disabled {
    cursor: default;
    background: #7b8490;
    box-shadow: none;
}

.input-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
}

.hint {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.result-panel {
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(360px, 1fr) auto;
    gap: 16px;
}

.result-card {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 14px;
}

.output-card {
    min-height: 0;
}

.card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 28px;
    margin-bottom: 10px;
}

.card-title h2 {
    font-size: 14px;
    line-height: 1.2;
}

.output-box,
.log-box,
.runtime-box {
    min-width: 0;
    border: 1px solid rgba(32, 38, 46, 0.10);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.74);
    color: var(--ink);
}

.output-box {
    min-height: 420px;
    overflow: auto;
    padding: 14px;
}

.log-box,
.runtime-box {
    min-height: 112px;
    overflow: auto;
    padding: 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.runtime-box {
    display: flex;
    align-items: center;
    color: var(--green);
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

.empty-state {
    color: var(--muted);
}

#stdout pre {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.45;
}

.embedding-image {
    display: block;
    width: min(100%, 760px);
    max-height: 68vh;
    object-fit: contain;
    margin: 0 auto;
}

.model-viewer {
    height: calc(100% + 28px);
    border: 1px solid rgba(32, 38, 46, 0.14);
    border-radius: 8px;
    background: #f7f7f4;
    overflow: hidden;
    margin: -14px;
}

.model-viewer canvas {
    display: block;
}

@media (max-width: 980px) {
    .app-shell {
        padding: 12px;
    }

    .calculator-stage {
        min-height: calc(100vh - 24px);
        grid-template-columns: 1fr;
    }

    .result-panel {
        grid-template-rows: auto auto;
    }
}

@media (max-width: 700px) {
    h1 {
        font-size: 36px;
    }

    .input-panel,
    .result-card {
        box-shadow: none;
        backdrop-filter: none;
    }

    .control-grid,
    .example-row,
    .input-footer {
        grid-template-columns: 1fr;
    }

    .primary-action,
    .secondary-action {
        width: 100%;
    }

    textarea {
        min-height: 260px;
        max-height: none;
    }

    .output-box {
        min-height: 280px;
    }

    .model-viewer {
        min-height: 340px;
        height: 58vh;
    }
}

/* Card Container */
.bibtex-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    font-family: system-ui, -apple-system, sans-serif;
    overflow: hidden;
}

/* Header Section */
.bibtex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background-color: #ffffff;
}

.bibtex-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

/* Copy Button */
.copy-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    background-color: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background-color: #e2e8f0;
    color: #1e293b;
}

.copy-btn:active {
    background-color: #d1d5db;
}

/* Success State for Button */
.copy-btn.copied {
    background-color: #10b981;
    color: #ffffff;
}

.copy-btn.copied .copy-icon {
    display: none; /* Hide standard icon when copied */
}

/* Code Block Area */
.bibtex-body {
    padding: 1.25rem;
    background-color: #f8fafc;
    overflow-x: auto;
}

.bibtex-body pre {
    margin: 0;
}

.bibtex-body code {
    display: block;
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    color: #1e293b;
    line-height: 1.5;
    height: 10lh;
}
