/* Site styles. Colours come only from theme.css variables. */

/* ---------- Base ---------- */
html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}
body { min-height: 100vh; overflow-x: hidden; }
a { color: var(--brand-ink); }

.page {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px 16px 48px;
}

.section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 20px 2px 8px;
    font-weight: 600;
}

/* ---------- Header + menu ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--brand);
    color: var(--on-brand);
    box-shadow: 0 2px 8px var(--shadow);
}
.site-header-inner {
    max-width: 560px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.site-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--on-brand);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 1rem;
}
.site-brand:hover { color: var(--on-brand); }
.site-brand img { width: 34px; height: 34px; object-fit: contain; }
.menu-button {
    margin-left: auto;
    background: transparent;
    border: 0;
    color: var(--on-brand);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}
.menu-button:hover, .menu-button:focus-visible { background: var(--brand-strong); }
.menu-button span, .menu-button span::before, .menu-button span::after {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    position: relative;
}
.menu-button span::before, .menu-button span::after { content: ""; position: absolute; left: 0; }
.menu-button span::before { top: -6px; }
.menu-button span::after { top: 6px; }

.site-menu.offcanvas { background: var(--surface); color: var(--ink); max-width: 300px; }
.site-menu .offcanvas-header { background: var(--brand); color: var(--on-brand); }
.site-menu .btn-close { filter: invert(1); }
.site-menu .nav-link {
    color: var(--ink);
    font-weight: 600;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 4px;
}
.site-menu .nav-link:hover { background: var(--chip-bg); }
.site-menu .nav-link.active { background: var(--brand); color: var(--on-brand); }
.site-menu .nav-link.logout { color: var(--danger); }

/* ---------- Buttons + cards ---------- */
.btn-accent {
    display: block;
    width: 100%;
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: 12px;
    padding: 13px 16px;
    font-weight: 800;
    font-size: 1rem;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 2px 6px var(--shadow);
}
.btn-accent:hover, .btn-accent:focus-visible { color: var(--on-accent); filter: brightness(0.96); }
.btn-brand {
    background: var(--brand);
    color: var(--on-brand);
    border: 0;
    border-radius: 12px;
    padding: 11px 16px;
    font-weight: 700;
}
.btn-brand:hover { background: var(--brand-strong); color: var(--on-brand); }
.btn-ghost {
    background: transparent;
    color: var(--brand-ink);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 14px;
    font-weight: 600;
}

.card-surface {
    background: var(--surface);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 3px var(--shadow);
}

/* ---------- Avatars ---------- */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    background: var(--chip-bg);
    flex: none;
    display: inline-block;
}
.avatar-initials {
    display: inline-grid;
    place-items: center;
    background: var(--brand);
    color: var(--on-brand);
    font-weight: 700;
}

/* ---------- Alerts ---------- */
.notice {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--surface);
    border-left: 4px solid var(--brand);
    box-shadow: 0 1px 3px var(--shadow);
}
.notice.error { border-left-color: var(--danger); }
.notice.success { border-left-color: var(--success); }

/* ---------- Landing ---------- */
.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px 16px;
    background: var(--brand);
    color: var(--on-brand);
    text-align: center;
}
.landing img { width: 140px; height: 140px; object-fit: contain; }
.landing h1 {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0;
}
.landing .btn-accent { max-width: 300px; }
.landing .notice { color: var(--ink); max-width: 320px; }

/* ---------- Fines home ---------- */
.board-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 14px 0;
}
.board-summary > div {
    background: var(--surface);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 1px 3px var(--shadow);
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.board-summary b { font-size: 1.6rem; color: var(--brand-ink); line-height: 1; }
.board-summary span { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.board-summary .hand-out b { color: var(--hand-out-ink); }

.view-switch {
    display: flex;
    background: var(--chip-bg);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 12px;
}
.view-switch button {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 8px;
    border-radius: 9px;
    font-weight: 700;
    color: var(--muted);
}
.view-switch button.active {
    background: var(--surface);
    color: var(--brand-ink);
    box-shadow: 0 1px 3px var(--shadow);
}

.board .view-grid { display: none; }
.board.view-grid-on .view-list { display: none; }
.board.view-grid-on .view-grid { display: block; }

/* List rows */
.player-row {
    background: var(--surface);
    border-radius: 14px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    border: 2px solid transparent;
    transition: border-color 0.15s;
}
.player-row[open] { border-color: var(--accent); }
.player-row summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    cursor: pointer;
}
.player-row summary::-webkit-details-marker { display: none; }
.player-row[open] summary { display: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-name { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip {
    font-size: 0.68rem;
    background: var(--chip-bg);
    color: var(--brand-ink);
    border-radius: 20px;
    padding: 2px 8px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chip.empty { background: transparent; color: var(--muted); padding-left: 0; }
.row-totals { display: flex; gap: 12px; flex: none; }
.total { display: flex; flex-direction: column; align-items: center; min-width: 44px; }
.total b { font-size: 1.25rem; color: var(--brand-ink); line-height: 1.1; }
.total small { font-size: 0.62rem; color: var(--muted); white-space: nowrap; }
.total.hand-out b { color: var(--hand-out-ink); }

/* Expanded card */
.row-card { padding: 16px 14px 12px; cursor: pointer; }
.card-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.card-name { font-weight: 800; font-size: 1.2rem; }
.card-totals { display: flex; gap: 28px; margin: 4px 0 8px; }
.card-totals .total b { font-size: 2rem; }
.card-totals .total small { font-size: 0.75rem; }
.lines { margin-top: 10px; }
.lines-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 2px;
}
.line {
    display: flex;
    justify-content: space-between;
    padding: 7px 2px;
    border-top: 1px dashed var(--line);
    font-size: 0.95rem;
}
.lines.hand-out .lines-title, .lines.hand-out .line { color: var(--hand-out-ink); }
.empty-note { color: var(--muted); text-align: center; margin: 8px 0; font-size: 0.9rem; }

/* Grid */
.grid-scroll { padding: 0; overflow-x: auto; }
.fines-grid { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.fines-grid th, .fines-grid td { padding: 7px 3px; text-align: center; }
.fines-grid thead th { vertical-align: bottom; }
.fines-grid thead .avatar { display: block; margin: 0 auto 2px; }
.grid-name { display: block; font-size: 0.68rem; font-weight: 600; max-width: 44px; margin: 0 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fines-grid tbody th, .fines-grid tfoot th { text-align: left; padding-left: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
.fines-grid tbody tr:nth-child(even) { background: var(--bg); }
.fines-grid tbody tr.hand-out th, .fines-grid tbody tr.hand-out td { color: var(--hand-out-ink); background: var(--hand-out-bg); }
.fines-grid td.top { background: var(--top-bg); font-weight: 800; }
.fines-grid tfoot td, .fines-grid tfoot th { font-weight: 800; }
.fines-grid tfoot tr:first-child td, .fines-grid tfoot tr:first-child th { border-top: 2px solid var(--accent); color: var(--brand-ink); }
.fines-grid tfoot tr.hand-out td, .fines-grid tfoot tr.hand-out th { color: var(--hand-out-ink); }

/* Latest feed */
.feed { list-style: none; padding: 4px 14px; margin: 0; }
.feed li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.feed li:last-child { border-bottom: 0; }
.feed-meta { font-size: 0.78rem; color: var(--muted); }

/* ---------- Add a fine ---------- */
.page-title { font-size: 1.4rem; font-weight: 800; color: var(--brand-ink); margin: 4px 0 14px; }
.confirm { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.confirm form { margin: 0; flex: none; }
.fine-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.field > span { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.field select, .field input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    font-size: 1rem;
    background: var(--surface);
    color: var(--ink);
}
.field select:focus, .field input:focus { outline: 2px solid var(--accent); border-color: var(--brand); }
.toggles { display: flex; gap: 10px; flex-wrap: wrap; }
.toggle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 600;
    min-width: 140px;
}
.toggle input { width: 18px; height: 18px; accent-color: var(--brand); }
.preview {
    background: var(--chip-bg);
    color: var(--brand-ink);
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 600;
    text-align: center;
}

/* ---------- Assign fines ---------- */
.remaining {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
    border: 2px solid var(--accent);
}
.remaining b { font-size: 2.2rem; color: var(--hand-out-ink); line-height: 1; }
.remaining span { font-weight: 700; color: var(--muted); }
.remaining.done { border-color: var(--success); }
.remaining.done b { color: var(--success); }
.remaining.over { border-color: var(--danger); }
.remaining.over b { color: var(--danger); }
.assign-list { display: flex; flex-direction: column; gap: 8px; }
.assign-row { display: flex; align-items: center; gap: 10px; padding: 10px; }
.assign-name { flex: 1; font-weight: 700; min-width: 0; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input {
    width: 52px;
    text-align: center;
    font-weight: 800;
    font-size: 1.1rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 2px;
    color: var(--brand-ink);
    background: var(--surface);
}
.step {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 800;
    font-size: 1.2rem;
    line-height: 1;
}
.btn-accent:disabled { opacity: 0.5; }

/* ---------- Wide-screen cards (hidden on phones) ---------- */
.board .view-cards { display: none; }
.player-card { padding: 18px 16px 14px; }
.wide-only { display: none; }

/* ---------- Desktop: sidebar menu, wider page, cards instead of list ---------- */
.site-sidebar { display: none; }

@media (min-width: 992px) {
    .site-header, .site-menu.offcanvas { display: none; }

    .app-shell { display: flex; min-height: 100vh; }
    .site-sidebar {
        display: flex;
        flex-direction: column;
        position: sticky;
        top: 0;
        height: 100vh;
        width: 240px;
        flex: none;
        padding: 24px 16px;
        background: var(--brand);
        color: var(--on-brand);
    }
    .sidebar-brand {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-bottom: 28px;
        color: var(--on-brand);
        text-decoration: none;
        font-weight: 800;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }
    .sidebar-brand:hover { color: var(--on-brand); }
    .sidebar-brand img { width: 120px; height: 120px; object-fit: contain; }
    .site-sidebar .nav-link { color: var(--on-brand); }
    .site-sidebar .nav-link:hover { background: var(--brand-strong); }
    .site-sidebar .nav-link.active { background: var(--accent); color: var(--on-accent); }
    .site-sidebar .nav-link.sidebar-logout {
        margin-top: auto;
        background: var(--danger);
        color: var(--on-brand);
        text-align: center;
    }
    .site-sidebar .nav-link.sidebar-logout:hover { background: var(--danger); filter: brightness(0.92); }

    .app-main { flex: 1; min-width: 0; }
    .page { max-width: 1200px; padding: 28px 32px 56px; }
    .page .btn-accent { max-width: 320px; }
    .fine-form, .assign-list, .remaining, .page > .notice, .page > .feed, .page > .page-title,
    .page > .section-label { max-width: 640px; }
    .board-toolbar {
        display: flex;
        align-items: stretch;
        gap: 14px;
        margin: 16px 0 14px;
    }
    .board-toolbar .board-summary { margin: 0; flex: 0 1 420px; }
    .board-toolbar .view-switch { margin: 0; flex: 0 0 260px; align-items: center; }
    .board-toolbar .view-switch button { height: 100%; }
    .page > .latest-label { max-width: none; }
    .page > .latest-feed {
        max-width: none;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        column-gap: 28px;
        padding: 4px 18px;
    }
    .latest-feed li:last-child { border-bottom: 1px solid var(--line); }

    .narrow-only { display: none; }
    .wide-only { display: inline; }
    .board .view-list { display: none; }
    .board .view-cards {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 14px;
        align-items: start;
    }
    .board.view-grid-on .view-cards { display: none; }
    .fines-grid { font-size: 0.95rem; }
    .fines-grid th, .fines-grid td { padding: 9px 8px; }
    .grid-name { max-width: 90px; font-size: 0.78rem; }
}
