/* Dark theme based on Talon Tales palette */
:root {
    --bg: #0E0E0E;
    --surface: #151515;
    --text: #E8E6E3;
    --muted: #B5B3AF;
    --primary: #D5A64A;
    --primary-hover: #E0B760;
    --danger: #E74C3C;
    --ok: #26b050;
    --border: #2A2A2A;
    --shadow: rgba(0,0,0,0.5);
}

html, body {
    background-color: var(--bg);
    color: var(--text);
    font-family: Inter, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Ensure padding and borders don't cause overflow */
*, *::before, *::after {
    box-sizing: border-box;
}

#app {
    display: block;
    min-height: 100dvh;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

h1, h2, h3, h4 {
    color: var(--text);
    margin: 0 0 12px 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 24px var(--shadow);
}

.row {
    display: grid;
    gap: 12px;
}

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

.grid-3 {
    /* Use auto-fit with a sensible min width to prevent overlap/overflow */
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Responsive grids to avoid overlap */
.responsive {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

@media (max-width: 900px) {
    .grid-3,
    .responsive {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 600px) {
    .grid-3,
    .responsive {
        grid-template-columns: 1fr;
    }
}

label {
    font-size: 0.85rem;
    color: var(--muted);
}

input, select {
    width: 100%;
    border: 1px solid var(--border);
    background: #121212;
    color: var(--text);
    padding: 10px 12px;
    border-radius: 8px;
    max-width: 100%;
}

input:focus, select:focus {
    outline: 2px solid var(--primary);
}

/* Inline level + evolved toggle */
.level-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.level-inline input[type=number] {
    flex: 1 1 220px;
}

/* Accessible hidden checkbox for toggle */
.toggle-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.toggle-pill {
    display: inline-block; /* ensure width/height apply on label */
    width: 46px;
    height: 26px;
    background: #2a2a2a;
    border: 1px solid var(--border);
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-pill::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 3px;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    background: #fff;
    border-radius: 50%;
    transition: left 0.2s ease, background 0.2s ease;
}

.toggle-input:checked + .toggle-pill {
    background: color-mix(in srgb, var(--primary) 35%, #3a2c10);
    border-color: var(--primary);
}

.toggle-input:checked + .toggle-pill::after {
    left: 22px;
    background: #1a1a1a;
}

.toggle-input:focus-visible + .toggle-pill {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.toggle-text {
    color: var(--muted);
    font-size: 0.9rem;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

/* Inline group for calculator type pills */
.toggle-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px; /* row gap, column gap */
    margin-top: 8px;
}

.toggle-item {
    display: inline-flex;
    align-items: center;
}

/* Checkbox inline alignment */
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: end; /* align with bottoms of other inputs in the grid */
    margin-top: 4px;
}

@media (max-width: 600px) {
    .checkbox-inline {
        align-self: start;
        margin-top: 0;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--primary);
    color: #1a1a1a;
    border: none;
    cursor: pointer;
}

.btn:hover { background: var(--primary-hover); }

.table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
}

.table th, .table td {
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
}

.table thead th {
    background: #1b1b1b;
    color: var(--muted);
    text-align: left;
}

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--ok); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); }

#blazor-error-ui { display: none; }

/* Radar chart styles */
.radar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

svg.radar {
    width: min(520px, 100%);
    height: auto;
}

.radar .ring {
    fill: none;
    stroke: var(--border);
    opacity: 0.6;
}

.radar .axis {
    stroke: #2b2b2b;
    opacity: 0.7;
}

.radar .label {
    fill: var(--muted);
    font-size: 12px;
    dominant-baseline: middle;
    text-anchor: middle;
}

.radar .poly {
    fill-opacity: 0.14;
    stroke-width: 2px;
}

.radar .poly-min {
    fill: transparent;
    stroke: #6b6b6b;
}

.radar .poly-max {
    fill: transparent;
    stroke: var(--border);
}

.radar .poly-cur {
    fill: color-mix(in srgb, var(--primary) 20%, transparent);
    stroke: var(--primary);
}

.radar .cur-point {
    fill: var(--primary);
}

/* Projected growth (teal) */
.radar .poly-proj {
    fill: color-mix(in srgb, #33d1b1 18%, transparent);
    stroke: #33d1b1;
}

.radar .proj-point {
    fill: #33d1b1;
}

.legend {
    display: flex;
    gap: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.swatch { display:inline-block; width:14px; height:10px; border-radius:2px; margin-right:6px; }

/* App loading ring (uses theme primary color) */
.loading-progress {
    /* Viewport-centered to ensure perfect centering during boot */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 96px;
    height: 96px;
    z-index: 1000;
    pointer-events: none;
    filter: drop-shadow(0 2px 6px var(--shadow));
}

.loading-progress circle {
    fill: none;
    stroke-width: 8;
}

/* Track */
.loading-progress circle:first-child {
    stroke: var(--border);
    opacity: 0.6;
}

/* Animated arc in primary orange */
.loading-progress circle:last-child {
    stroke: var(--primary);
    stroke-linecap: round;
    transform-origin: 50% 50%;
    animation: lp-spin 1.2s linear infinite, lp-dash 1.6s ease-in-out infinite;
}

@keyframes lp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes lp-dash {
    0% { stroke-dasharray: 1 300; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 110 190; stroke-dashoffset: -25; }
    100% { stroke-dasharray: 1 300; stroke-dashoffset: -300; }
}

.loading-progress-text {
    position: fixed;
    top: calc(50% + 72px);
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--muted);
    font-size: 0.95rem;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .loading-progress circle:last-child {
        animation: none;
        /* show a simple arc without spinning */
        stroke-dasharray: 110 190;
        stroke-dashoffset: 0;
    }
}
.sw-min { background:#6b6b6b; }
.sw-max { background: var(--border); }
.sw-cur { background: var(--primary); }
.sw-proj { background: #33d1b1; }
.sw-projmax { background: #8e67ff; }

/* Projected growth maximum (purple) */
.radar .poly-projmax {
    fill: color-mix(in srgb, #8e67ff 18%, transparent);
    stroke: #8e67ff;
}

.radar .projmax-point {
    fill: #8e67ff;
}