/* =====================================================================
   ASCII Art Web — theme
   A single, consistent dark/purple design system. No JavaScript.
   ===================================================================== */

:root {
    --bg-0: #0a0f1a;
    --bg-1: #0f172a;
    --accent: #2dd4bf;          /* readable teal on dark */
    --accent-strong: #14b8a6;   /* primary button fill */
    --accent-soft: rgba(45, 212, 191, 0.15);
    --surface: rgba(255, 255, 255, 0.045);
    --surface-2: #121c2e;       /* inputs */
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(45, 212, 191, 0.5);
    --text: #e6edf5;
    --muted: #94a3b8;
    --radius: 14px;
    --radius-sm: 10px;
    --pill: 999px;
    --ring: 0 0 0 3px var(--accent-soft);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.5;
    background:
        radial-gradient(1200px 600px at 15% -10%, rgba(20, 184, 166, 0.22), transparent 60%),
        radial-gradient(1000px 500px at 100% 0%, rgba(45, 212, 191, 0.14), transparent 55%),
        linear-gradient(160deg, var(--bg-1), var(--bg-0) 60%);
    background-attachment: fixed;
}

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

/* ── Page shell ─────────────────────────────────────────────────────── */
.page {
    max-width: 900px;
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem) 3rem;
}

.hero { text-align: center; margin-bottom: 1.75rem; }

.hero h1 {
    margin: 0;
    font-size: clamp(1.9rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero .subtitle {
    margin: 0.6rem auto 0;
    max-width: 46ch;
    color: var(--muted);
    font-size: clamp(0.9rem, 2vw, 1.05rem);
}

/* ── Card ───────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    padding: clamp(1.25rem, 3vw, 2rem);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

label, .legend { color: var(--text); font-weight: 600; font-size: 0.95rem; }

textarea {
    width: 100%;
    min-height: 6.5rem;
    resize: vertical;
    padding: 0.85rem 1rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea::placeholder { color: var(--muted); }

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

/* ── Controls ───────────────────────────────────────────────────────── */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem 2rem;
    align-items: flex-start;
}

.group {
    border: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.group .legend { padding: 0; }

/* Segmented radio group — pure CSS, driven by :checked */
.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.3rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--pill);
}

.seg { position: relative; display: inline-flex; }

.seg input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
}

.seg span {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border-radius: var(--pill);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.seg:hover span { color: var(--text); }

.seg input:checked + span {
    background: var(--accent-strong);
    color: #05221f;
    box-shadow: 0 2px 10px rgba(20, 184, 166, 0.45);
}

.seg input:focus-visible + span { box-shadow: var(--ring); }

/* Color picker */
.group--color { align-items: flex-start; }

.color-input {
    width: 3rem;
    height: 2.4rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 4px; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 6px; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.btn {
    appearance: none;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: var(--pill);
    padding: 0.6rem 1.4rem;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn--primary {
    background: var(--accent-strong);
    color: #05221f;
    box-shadow: 0 6px 18px rgba(20, 184, 166, 0.4);
}
.btn--primary:hover { background: var(--accent); }

.btn--ghost {
    background: transparent;
    color: var(--accent);
    border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--accent-soft); color: var(--text); }

.actions .spacer { flex: 1 1 auto; }

/* ── Output ─────────────────────────────────────────────────────────── */
.output {
    margin-top: 1.5rem;
    background: #05030a;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 220px;
    padding: 1.25rem;
    overflow: auto;
    display: flex;
}

.output__art {
    margin: auto 0;
    width: 100%;
    font-family: var(--mono);
    line-height: 1.05;
}

.output__art pre { font-family: var(--mono); }

.output__empty {
    margin: auto;
    color: var(--muted);
    font-size: 0.95rem;
    text-align: center;
}

/* ── Error page ─────────────────────────────────────────────────────── */
.error-center {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}
.error-status {
    font-size: clamp(4rem, 18vw, 8rem);
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(90deg, #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.error-message {
    margin: 1rem 0 2rem;
    max-width: 48ch;
    color: var(--muted);
    font-size: 1.15rem;
    white-space: pre-line;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 560px) {
    .controls { gap: 1rem; }
    .segmented { width: 100%; justify-content: center; }
    .actions .btn { flex: 1 1 auto; text-align: center; }
}
