﻿/* Base styles, layout and shared ornament. Values come from css/tokens.css only.
   Bootstrap stays underneath for the Identity pages from the template; its variables are mapped to our tokens. */

/* ---- Bootstrap mapping -------------------------------------------------- */
:root,
[data-bs-theme="dark"] {
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-body-font-family: var(--font-body);
    --bs-body-font-size: var(--fs-md);
    --bs-emphasis-color: var(--text);
    --bs-secondary-color: var(--text-muted);
    --bs-tertiary-bg: var(--panel);
    --bs-secondary-bg: var(--panel-raised);
    --bs-border-color: var(--border);
    --bs-border-radius: var(--radius);
    --bs-link-color: var(--focus);
    --bs-link-color-rgb: 127, 200, 216;
    --bs-link-hover-color: var(--text);
    --bs-link-hover-color-rgb: 234, 223, 198;
    --bs-primary: var(--gold);
    --bs-primary-rgb: 217, 169, 63;
    --bs-danger: var(--down);
    --bs-danger-rgb: 218, 106, 80;
    --bs-success: var(--up);
    --bs-success-rgb: 99, 179, 92;
    --bs-form-invalid-color: var(--down);
    --bs-form-invalid-border-color: var(--down);
    --bs-form-valid-border-color: var(--up);
    --bs-focus-ring-color: rgba(127, 200, 216, 0.4);
}

.btn-primary {
    --bs-btn-color: var(--on-gold);
    --bs-btn-bg: var(--gold);
    --bs-btn-border-color: var(--gold);
    --bs-btn-hover-color: var(--on-gold);
    --bs-btn-hover-bg: var(--gold-hover);
    --bs-btn-hover-border-color: var(--gold-hover);
    --bs-btn-active-color: var(--on-gold);
    --bs-btn-active-bg: var(--gold-press);
    --bs-btn-active-border-color: var(--gold-press);
    --bs-btn-disabled-color: var(--on-gold);
    --bs-btn-disabled-bg: var(--gold);
    --bs-btn-disabled-border-color: var(--gold);
    font-weight: 700;
    /* Struck gold: a lit upper face, a darker lower face, an engraved edge. Text stays --on-gold (5.9:1 on the darkest stop). */
    background-image: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 48%, var(--gold-mid) 100%);
    border-color: var(--gold-deep);
    box-shadow: inset 0 1px 0 rgba(255, 244, 214, 0.55), inset 0 -2px 0 rgba(90, 62, 14, 0.35), 0 2px 6px rgba(0, 0, 0, 0.45);
    text-shadow: 0 1px 0 rgba(255, 236, 190, 0.45);
}

.btn-primary:hover {
    background-image: linear-gradient(180deg, var(--gold-glint) 0%, var(--gold-hover) 48%, var(--gold) 100%);
    border-color: var(--gold-deep);
}

.btn-primary:active,
.btn-primary.active {
    background-image: linear-gradient(180deg, var(--gold-mid) 0%, var(--gold) 100%);
    box-shadow: inset 0 2px 4px rgba(60, 40, 8, 0.5);
}

.btn-primary:disabled,
.btn-primary.disabled {
    background-image: none;
    box-shadow: none;
    text-shadow: none;
}

.form-control,
.form-select,
.form-check-input,
.btn-ghost {
    border-color: var(--border-strong) !important;
}

.form-control,
.form-select {
    background-color: var(--bg);
    color: var(--text);
    min-height: var(--touch);
    /* Carved into the oak: inputs sit in a shallow well. */
    box-shadow: var(--well);
    caret-color: var(--gold);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg);
    color: var(--text);
    border-color: var(--focus);
    box-shadow: var(--well), 0 0 0 0.2rem rgba(127, 200, 216, 0.3);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.form-check-input {
    background-color: var(--bg);
    box-shadow: var(--well);
}

.form-check-input:checked {
    background-color: var(--gold);
    border-color: var(--gold-deep) !important;
}

.form-check-input:checked[type=checkbox] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%231a1208' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}

hr {
    border: 0;
    height: 16px;
    margin: var(--space-4) 0;
    opacity: 1;
    background: var(--orn-centre) center / 120px 16px no-repeat;
}

.form-floating > label,
.form-label {
    color: var(--text-muted);
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: var(--text-muted);
}

.form-floating > .form-control:focus ~ label::after,
.form-floating > .form-control:not(:placeholder-shown) ~ label::after {
    background-color: transparent;
}

.text-danger {
    color: var(--down) !important;
}

.nav-pills {
    --bs-nav-pills-link-active-bg: var(--panel-raised);
    --bs-nav-pills-link-active-color: var(--gold);
    --bs-nav-link-color: var(--text);
    --bs-nav-link-hover-color: var(--gold);
}

/* ---- Base ----------------------------------------------------------------- */
html,
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    line-height: 1.5;
}

body {
    /* The counting-house wall: oak planks with grain and seams, a lamp glow from above, a dark vignette at the
       edges and a fine noise so the gradients never band. Gradients plus one tiny SVG tile; no image files. */
    background-image:
        radial-gradient(ellipse 90% 55% at 50% -8%, rgba(217, 169, 63, 0.11), transparent 70%),
        radial-gradient(ellipse 120% 90% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
        var(--tex-noise),
        var(--tex-grain);
    background-attachment: fixed;
    overflow-x: hidden;
}

html,
.table-wrap,
.ls-menu {
    scrollbar-color: var(--border-strong) var(--oak-deep);
}

::selection {
    background: rgba(217, 169, 63, 0.38);
    color: var(--text);
}

h1, h2, h3, h4,
.heading {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--text);
}

h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }

a {
    color: var(--focus);
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;
}

a:hover {
    text-decoration-thickness: 2px;
}

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

/* FocusOnNavigate moves focus to the page title for screen readers; no ring needed there. */
h1:focus,
h1:focus-visible {
    outline: none;
}

.num,
table,
.tabular {
    font-variant-numeric: tabular-nums lining-nums;
}

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

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---- Page title: engraved gold capitals over an ornamental rule ---------
   The rule is three background layers so containers (the league header) can reuse it: a lozenge flourish at
   the left, a gold hairline that fades out, and a bronze base line. */
.page-title,
.site-main > h1,
.section-title,
.orn-rule {
    background:
        var(--orn-lozenge) left bottom 3px / 34px 14px no-repeat,
        linear-gradient(90deg, var(--gold) 0%, rgba(217, 169, 63, 0.55) 35%, transparent 92%) left 34px bottom 9px / calc(100% - 34px) 1px no-repeat,
        linear-gradient(90deg, var(--border-strong), var(--border) 60%, transparent) left bottom / 100% 1px no-repeat;
}

.page-title,
.site-main > h1 {
    margin: var(--space-5) 0 var(--space-5);
    padding-bottom: calc(var(--space-3) + 16px);
    text-transform: uppercase;
    font-size: clamp(1.6rem, 1.1rem + 2.6vw, var(--fs-xxl));
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: 0.07em;
    color: var(--gold);
    text-wrap: balance;
    /* Engraved: a dark cut below, a faint lit edge above. */
    text-shadow: 0 2px 1px rgba(0, 0, 0, 0.8), 0 -1px 0 rgba(242, 207, 122, 0.2);
}

.page-title small,
.site-main > h1 small {
    display: block;
    margin-top: var(--space-1);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
    text-shadow: none;
    color: var(--text-muted);
}

/* ---- Panels with corner brackets ------------------------------------- */
/* ---- Panels: iron-bound ledger plates ---------------------------------
   The face stays flat --panel so data, charts and the validated series colours read exactly as before.
   ::before draws an inner gilt hairline (a double frame); ::after draws four iron corner brackets, each
   with a brass rivet, from layered gradients. Both ignore the pointer. */
.panel {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    box-shadow: var(--edge-hi), var(--shadow-1);
}

.panel::before,
.panel::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.panel::before {
    inset: 4px;
    border: 1px solid rgba(217, 169, 63, 0.11);
    border-radius: 2px;
}

.panel::after {
    --c: var(--gold);
    --l: 18px;
    inset: -2px;
    background:
        /* rivets */
        radial-gradient(circle, var(--gold-hi) 0 1px, var(--bronze-hi) 1.6px 2.3px, var(--gold-deep) 2.4px 3px, transparent 3.4px) left 3px top 3px / 8px 8px no-repeat,
        radial-gradient(circle, var(--gold-hi) 0 1px, var(--bronze-hi) 1.6px 2.3px, var(--gold-deep) 2.4px 3px, transparent 3.4px) right 3px top 3px / 8px 8px no-repeat,
        radial-gradient(circle, var(--gold-hi) 0 1px, var(--bronze-hi) 1.6px 2.3px, var(--gold-deep) 2.4px 3px, transparent 3.4px) left 3px bottom 3px / 8px 8px no-repeat,
        radial-gradient(circle, var(--gold-hi) 0 1px, var(--bronze-hi) 1.6px 2.3px, var(--gold-deep) 2.4px 3px, transparent 3.4px) right 3px bottom 3px / 8px 8px no-repeat,
        /* brackets */
        linear-gradient(var(--c), var(--c)) left top / var(--l) 2px no-repeat,
        linear-gradient(var(--c), var(--c)) left top / 2px var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) right top / var(--l) 2px no-repeat,
        linear-gradient(var(--c), var(--c)) right top / 2px var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) left bottom / var(--l) 2px no-repeat,
        linear-gradient(var(--c), var(--c)) left bottom / 2px var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) right bottom / var(--l) 2px no-repeat,
        linear-gradient(var(--c), var(--c)) right bottom / 2px var(--l) no-repeat;
    opacity: 0.85;
}

.panel > h2:first-child,
.panel > h3:first-child {
    margin-top: 0;
}

/* Panel headings: gold engraved capitals on a fading gilt rule, led by a small lozenge. */
.panel-title {
    font-family: var(--font-heading);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7);
    margin: 0 0 var(--space-3);
    padding: 0 0 var(--space-2);
    background: linear-gradient(90deg, rgba(217, 169, 63, 0.5), rgba(94, 74, 44, 0.35) 45%, transparent 85%) left bottom / 100% 1px no-repeat;
}

.panel-title::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 0.6em 0.18em 1px;
    vertical-align: middle;
    background: var(--gold);
    box-shadow: 0 0 0 1px var(--gold-deep);
    transform: rotate(45deg);
}

.panel-title .muted {
    font-family: var(--font-body);
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
}

/* Rivet dots for raised surfaces (panels already carry rivets in their corner brackets). */
.rivets:not(.panel) {
    background-image:
        radial-gradient(circle at 8px 8px, var(--rivet) 2px, transparent 2.5px),
        radial-gradient(circle at calc(100% - 8px) 8px, var(--rivet) 2px, transparent 2.5px),
        radial-gradient(circle at 8px calc(100% - 8px), var(--rivet) 2px, transparent 2.5px),
        radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), var(--rivet) 2px, transparent 2.5px);
}

/* A section heading outside a panel (results page "Awards", etc.). */
.section-title {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    text-shadow: 0 2px 1px rgba(0, 0, 0, 0.8);
    margin: var(--space-5) 0 var(--space-3);
    padding-bottom: calc(var(--space-2) + 14px);
}

.grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

/* ---- Buttons and links that look like buttons ------------------------ */
.btn {
    min-height: var(--touch);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: background-color 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out, box-shadow 0.15s ease-out;
}

/* Iron-faced button: a dark forged plate with a lit top edge. */
.btn-ghost {
    background: linear-gradient(180deg, var(--iron) 0%, var(--iron-dark) 100%);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 240, 210, 0.08), 0 1px 3px rgba(0, 0, 0, 0.45);
}

.btn-ghost:hover {
    background: linear-gradient(180deg, var(--iron-lit) 0%, var(--iron) 100%);
    color: var(--gold);
    border-color: var(--gold) !important;
}

.btn-ghost:active {
    background: var(--iron-dark);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55);
}

/* ---- Messages: a framed slip with a status lozenge ------------------ */
.notice {
    position: relative;
    border: 1px solid var(--border);
    background:
        linear-gradient(90deg, rgba(217, 169, 63, 0.09), transparent 55%),
        var(--panel-raised);
    padding: var(--space-3) var(--space-4) var(--space-3) calc(var(--space-4) + 18px);
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
    box-shadow: var(--edge-hi), var(--shadow-1);
}

.notice::before {
    content: "";
    position: absolute;
    left: calc(var(--space-3) + 1px);
    top: calc(var(--space-3) + 0.42em);
    width: 9px;
    height: 9px;
    background: var(--gold);
    box-shadow: 0 0 0 1px var(--gold-deep), 0 0 0 3px rgba(217, 169, 63, 0.18);
    transform: rotate(45deg);
    pointer-events: none;
}

.notice.ok {
    border-color: rgba(99, 179, 92, 0.55);
    background: linear-gradient(90deg, rgba(99, 179, 92, 0.1), transparent 55%), var(--panel-raised);
}

.notice.ok::before {
    background: var(--up);
    box-shadow: 0 0 0 1px var(--up-ring), 0 0 0 3px rgba(99, 179, 92, 0.2);
}

.notice.error {
    border-color: rgba(218, 106, 80, 0.6);
    background: linear-gradient(90deg, rgba(218, 106, 80, 0.1), transparent 55%), var(--panel-raised);
}

.notice.error::before {
    background: var(--down);
    box-shadow: 0 0 0 1px var(--down-ring), 0 0 0 3px rgba(218, 106, 80, 0.2);
}

/* ---- Empty states: an open ledger with nothing written in it yet ---- */
.empty-state {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    color: var(--text-muted);
}

.panel.empty-state {
    padding-top: calc(var(--space-5) + 64px);
    background:
        var(--orn-ledger) center var(--space-5) / 72px 52px no-repeat,
        radial-gradient(ellipse 60% 70% at 50% 30%, rgba(217, 169, 63, 0.07), transparent 70%),
        var(--panel);
}

.empty-state .heading {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 2px 1px rgba(0, 0, 0, 0.8);
    margin-bottom: var(--space-2);
    padding-bottom: calc(var(--space-2) + 16px);
    background: var(--orn-centre) center bottom / 120px 16px no-repeat;
}

.empty-state p {
    max-width: 52ch;
    margin-left: auto;
    margin-right: auto;
}

/* ---- Tables: ledger pages, ruled in bronze; cards on narrow screens -- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.ledger th {
    font-family: var(--font-heading);
    font-size: var(--fs-xs);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    text-align: left;
    /* Ledger head: a darker band over a double bronze rule. */
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.08));
    border-bottom: 3px double var(--border-strong);
    padding: var(--space-2) var(--space-3);
}

.ledger td {
    border-bottom: 1px solid rgba(94, 74, 44, 0.45);
    padding: var(--space-2) var(--space-3);
    vertical-align: top;
}

.ledger tbody tr {
    transition: background-color 0.12s ease-out;
}

.ledger tbody tr:hover {
    background-color: rgba(217, 169, 63, 0.045);
}

.ledger td.num,
.ledger th.num {
    text-align: right;
}

@media (max-width: 640px) {
    .ledger.stack thead {
        display: none;
    }

    /* Each row becomes a ledger slip: a gilt top edge and a bronze frame. */
    .ledger.stack tr {
        display: block;
        border: 1px solid var(--border);
        border-top: 2px solid var(--gold-deep);
        border-radius: var(--radius);
        background: var(--panel);
        box-shadow: var(--shadow-1);
        margin-bottom: var(--space-3);
        padding: var(--space-2) var(--space-3);
    }

    .ledger.stack td {
        display: flex;
        justify-content: space-between;
        gap: var(--space-3);
        border: 0;
        border-bottom: 1px dotted rgba(94, 74, 44, 0.55);
        padding: var(--space-1) 0;
        text-align: right;
        overflow-wrap: anywhere;
    }

    .ledger.stack td:last-child {
        border-bottom: 0;
    }

    .ledger.stack td::before {
        content: attr(data-label);
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }
}

/* ---- Blazor error UI and validation (from the template) ------------- */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--up);
}

.invalid {
    outline: 1px solid var(--down);
}

.validation-message {
    color: var(--down);
}

#blazor-error-ui {
    color-scheme: dark only;
    background: var(--panel-raised);
    color: var(--text);
    border-top: 1px solid var(--down);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.4);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--down);
    padding: 1rem;
    color: var(--on-gold);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ---- Phones: the league strip above the bottom bar ------------------- */
@media (max-width: 899.98px) {
    body:has(.bottom-bar.with-strip) .site-footer {
        padding-bottom: calc(var(--bottom-nav-h) + var(--touch) + var(--space-4) + env(safe-area-inset-bottom));
    }
}

/* ---- Identity pages (template markup): the form column becomes a ledger plate ---- */
.site-main > .row > .col-lg-6:first-child > :is(section, form) {
    background: var(--panel);
    border: 1px solid var(--border);
    border-top: 2px solid var(--gold-deep);
    border-radius: var(--radius);
    padding: var(--space-5) var(--space-4);
    box-shadow: var(--edge-hi), var(--shadow-2);
}

.text-secondary {
    color: var(--text-muted) !important;
}

/* ---- Motion: every transition and the one authored moment (results seals) stand down ---- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:root {
    accent-color: var(--gold);
}

