/* Project Hero - base theme. Dark is the default; light is opt-in via the header toggle. */

:root {
    color-scheme: dark;
    --bg: #070b14;
    --bg-glow: #12213f;
    --surface: #0f1728;
    --surface-2: #162036;
    --border: #25324d;
    --text: #e9eef8;
    --text-muted: #9aa8c2;
    --hero-red: #e63950;
    --hero-gold: #f2c14e;
    --villain-purple: #a06cf0;
    --villain-green: #4fd08a;
    --system-blue: #4da3ff;
    --on-accent: #14080a;
    --danger-bg: rgba(230, 57, 80, 0.14);
    --success-bg: rgba(79, 208, 138, 0.14);
    --info-bg: rgba(77, 163, 255, 0.14);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --radius: 12px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", var(--font);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #eef1f7;
    --bg-glow: #d9e2f5;
    --surface: #ffffff;
    --surface-2: #f3f5fa;
    --border: #cfd7e6;
    --text: #131a2a;
    --text-muted: #55627b;
    --hero-red: #c81e36;
    --hero-gold: #9a6a00;
    --villain-purple: #6b3fc4;
    --villain-green: #1c7d4b;
    --system-blue: #1565c0;
    --on-accent: #ffffff;
    --danger-bg: rgba(200, 30, 54, 0.1);
    --success-bg: rgba(28, 125, 75, 0.1);
    --info-bg: rgba(21, 101, 192, 0.1);
    --shadow: 0 8px 24px rgba(30, 45, 80, 0.12);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg) radial-gradient(1100px 520px at 50% -180px, var(--bg-glow), transparent 70%) no-repeat;
}

h1,
h2 {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.15;
    margin: 0 0 0.6rem;
    text-wrap: balance;
}

h1 {
    font-size: clamp(1.7rem, 4.5vw, 2.6rem);
}

h2 {
    font-size: 1.15rem;
}

p {
    margin: 0 0 1rem;
}

a {
    color: var(--system-blue);
}

:focus-visible {
    outline: 2px solid var(--system-blue);
    outline-offset: 2px;
}

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

.skip-link {
    position: absolute;
    left: -9999px;
}

.skip-link:focus {
    left: 16px;
    top: 12px;
    z-index: 10;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 8px;
}

/* Header */

.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    padding-top: 12px;
    padding-bottom: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.brand-sub {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.main-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.main-nav a {
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
}

.main-nav a:hover {
    color: var(--text);
    background: var(--surface-2);
}

.main-nav a[aria-current="page"] {
    color: var(--text);
    box-shadow: inset 0 -2px 0 var(--hero-red);
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.header-actions form {
    margin: 0;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 220px;
    font-weight: 600;
}

.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Buttons */

.button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button-small {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.9rem;
}

.button-block {
    width: 100%;
}

.button-primary {
    color: var(--on-accent);
    background: linear-gradient(135deg, var(--hero-gold), var(--hero-red));
}

.button-primary:hover {
    filter: brightness(1.1);
}

.button-ghost,
.icon-button {
    color: var(--text);
    background: transparent;
    border-color: var(--border);
}

.button-ghost:hover,
.icon-button:hover {
    background: var(--surface-2);
}

.icon-button {
    min-height: 36px;
    width: 36px;
    padding: 0;
}

/* Layout */

.main {
    flex: 1;
    padding-top: 28px;
    padding-bottom: 48px;
}

.site-footer {
    padding: 16px 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--hero-gold);
}

.lead {
    max-width: 62ch;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.page-head {
    margin-bottom: 20px;
}

.grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

@media (min-width: 640px) {
    .grid-2,
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (min-width: 960px) {
    .grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Cards and stats */

.card,
.stat {
    min-width: 0;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card p:last-child {
    margin-bottom: 0;
}

.card-hero {
    border-top: 3px solid var(--hero-red);
}

.card-system {
    border-top: 3px solid var(--system-blue);
}

.card-villain {
    border-top: 3px solid var(--villain-purple);
}

.stat {
    border-left: 4px solid var(--accent, var(--border));
}

.stat-gold {
    --accent: var(--hero-gold);
}

.stat-red {
    --accent: var(--hero-red);
}

.stat-blue {
    --accent: var(--system-blue);
}

.stat-green {
    --accent: var(--villain-green);
}

.stat-label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.stat-value {
    margin: 2px 0 4px;
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.stat-note {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.level-progress {
    display: block;
    width: 100%;
    height: 8px;
    margin: 0 0 6px;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-2);
    accent-color: var(--hero-red);
    -webkit-appearance: none;
    appearance: none;
}

.level-progress::-webkit-progress-bar {
    background: var(--surface-2);
}

.level-progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--hero-gold), var(--hero-red));
}

.level-progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--hero-gold), var(--hero-red));
}

.tag {
    display: inline-block;
    padding: 1px 8px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

.tag-gold {
    color: var(--hero-gold);
}

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

.session-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
}

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 28px;
    margin: 0;
}

.facts dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.facts dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-weight: 400;
}

.table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.table tbody tr:last-child th,
.table tbody tr:last-child td {
    border-bottom: 0;
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table td.num {
    font-weight: 700;
}

/* Landing */

.hero {
    padding: 36px 0 32px;
}

.hero h1 {
    max-width: 18ch;
    font-size: clamp(2rem, 6.5vw, 3.6rem);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

/* Forms */

.auth-card {
    max-width: 440px;
    margin: 24px auto 0;
    border-top: 3px solid var(--hero-red);
}

.form {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

.field input {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
}

.field input:focus-visible {
    outline-offset: 0;
    border-color: var(--system-blue);
}

.field input[aria-invalid="true"] {
    border-color: var(--hero-red);
}

.field-hint,
.field-error {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.field-error {
    color: var(--hero-red);
    font-weight: 600;
}

.auth-switch {
    margin: 20px 0 0;
    text-align: center;
    color: var(--text-muted);
}

/* Alerts */

.alert {
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--alert-color);
    border-radius: 10px;
    background: var(--alert-bg);
}

.alert-error {
    --alert-color: var(--hero-red);
    --alert-bg: var(--danger-bg);
}

.alert-success {
    --alert-color: var(--villain-green);
    --alert-bg: var(--success-bg);
}

.alert-info {
    --alert-color: var(--system-blue);
    --alert-bg: var(--info-bg);
}

/* Error pages */

.error-page {
    padding: 48px 0;
    text-align: center;
}

.error-page .lead {
    margin: 0 auto 24px;
}

.error-code {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(4rem, 18vw, 8rem);
    font-weight: 700;
    line-height: 1;
    color: var(--hero-red);
}

@media (max-width: 520px) {
    .brand-sub {
        display: none;
    }

    .user-chip {
        max-width: 130px;
    }
}
