/* ============================================================================
 *  pages.css — auth + leaderboard screens (pages/*.html).
 *  Loads AFTER theme.css (tokens, shapes, logo, buttons).
 * ========================================================================== */

body {
    font-family: var(--font-body);
    background-color: var(--bg);
    background-image: radial-gradient(var(--muted) 2px, transparent 2px);
    background-size: 26px 26px;
    color: var(--fg);
    min-height: 100vh;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
}

/* Brand mark */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.brand .logo-circle,
.brand .logo-square {
    width: 26px;
    height: 26px;
}

.brand .logo-triangle {
    border-left-width: 14px;
    border-right-width: 14px;
    border-bottom-width: 25px;
}

.brand h1 {
    font-size: 1.7em;
    font-weight: 700;
    margin-left: 6px;
    color: var(--red);
}

/* Card panel used by auth + leaderboard */
.panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 40px;
}

.panel.wide {
    max-width: 720px;
}

/* Tabs — rounded segmented control */
.tabs {
    display: flex;
    gap: 6px;
    padding: 6px;
    background: var(--bg);
    border-radius: var(--radius-pill);
    margin-bottom: 28px;
}

.tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    color: var(--fg);
    transition: background 0.15s ease-out, color 0.15s ease-out;
}

.tab.active {
    background: var(--red);
    color: white;
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form.hidden {
    display: none;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 0.82em;
    font-weight: 600;
    color: var(--fg);
}

.field input,
.field select {
    font-family: var(--font-body);
    font-size: 1em;
    font-weight: 500;
    padding: 13px 16px;
    border: 2px solid rgba(46, 42, 38, 0.18);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--fg);
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--red);
}

/* School shown under the brand when it comes from the URL */
.school-banner {
    position: relative;
    z-index: 1;
    margin: -18px 0 28px;
    font-family: var(--font-display);
    font-size: 1.15em;
    font-weight: 600;
    color: var(--fg);
}

/* Hint shown on the register page when opened without a school link */
.school-hint {
    background: var(--bg);
    border: 2px dashed var(--taupe);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 24px;
    font-size: 0.92em;
    font-weight: 500;
    line-height: 1.5;
    color: var(--fg);
}

/* Read-only school label inside the register form (URL-locked school) */
.school-fixed {
    padding: 13px 16px;
    border: 2px solid rgba(46, 42, 38, 0.18);
    border-radius: var(--radius);
    background: var(--bg);
    font-weight: 600;
}

/* Custom brand-styled dropdown (replaces native <select>) */
.select {
    position: relative;
}

.select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px;
    border: 2px solid rgba(46, 42, 38, 0.18);
    border-radius: var(--radius);
    background: var(--card);
    font-family: var(--font-body);
    font-size: 1em;
    font-weight: 500;
    color: var(--fg);
    cursor: pointer;
    text-align: left;
}

.select-trigger:focus {
    outline: none;
    border-color: var(--red);
}

.select.open .select-trigger {
    border-color: var(--red);
}

.select-value.placeholder {
    color: rgba(46, 42, 38, 0.5);
}

.select-arrow {
    color: var(--taupe);
    transition: transform 0.15s ease-out;
    font-size: 0.8em;
}

.select.open .select-arrow {
    transform: rotate(180deg);
}

.select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.select.open .select-menu {
    display: block;
}

.select-option {
    padding: 11px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
}

.select-option:hover {
    background: rgba(230, 62, 44, 0.1);
    color: var(--red);
}

.select-option.selected {
    font-weight: 700;
    color: var(--red);
}

/* Messages */
.message {
    margin-top: 18px;
    padding: 13px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9em;
    display: none;
}

.message.show {
    display: block;
}

.message.error {
    background: var(--red);
    color: white;
}

.message.success {
    background: var(--orange);
    color: white;
}

/* Leaderboard */
.leaderboard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.leaderboard-head h2 {
    font-size: 2em;
    font-weight: 700;
    color: var(--red);
}

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

.lb-table th,
.lb-table td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid rgba(46, 42, 38, 0.12);
}

.lb-table th {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--taupe);
    font-weight: 700;
}

.lb-table td {
    font-weight: 500;
}

.lb-rank {
    font-weight: 700;
    width: 64px;
    font-family: var(--font-display);
    font-size: 1.1em;
}

.lb-score {
    font-weight: 700;
    text-align: right;
    color: var(--red);
    font-family: var(--font-display);
}

.lb-table tr.top-1 .lb-rank { color: var(--red); }
.lb-table tr.top-2 .lb-rank { color: var(--orange); }
.lb-table tr.top-3 .lb-rank { color: var(--purple); }

.lb-table tr.me {
    background: rgba(242, 168, 202, 0.35);
}

.lb-empty {
    text-align: center;
    padding: 40px;
    font-weight: 600;
    color: var(--taupe);
}

.actions-row {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-top: 28px;
    flex-wrap: wrap;
}

/* School directory rows */
.school-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(46, 42, 38, 0.12);
    flex-wrap: wrap;
}

.school-row-name {
    font-family: var(--font-display);
    font-size: 1.15em;
    font-weight: 600;
}

.school-row-url {
    font-size: 0.8em;
    color: var(--taupe);
    word-break: break-all;
}

.school-row-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Config notice */
.notice {
    position: relative;
    z-index: 1;
    max-width: 560px;
    background: var(--orange);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px 28px;
    margin-bottom: 24px;
    font-weight: 500;
    line-height: 1.5;
}

.notice code {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    padding: 1px 7px;
    font-size: 0.9em;
}

@media (max-width: 560px) {
    body {
        padding: 24px 14px;
    }

    .brand {
        margin-bottom: 24px;
    }

    .brand h1 {
        font-size: 1.4em;
    }

    .panel {
        padding: 26px 18px;
    }

    /* Bigger tap targets; 16px input font stops iOS auto-zoom on focus. */
    .field input,
    .field select,
    .select-trigger {
        padding: 14px 16px;
        font-size: 16px;
    }

    .lb-table th,
    .lb-table td {
        padding: 10px 8px;
        font-size: 0.9em;
    }

    /* School directory: stack the link + buttons, buttons span the row. */
    .school-row-actions {
        width: 100%;
    }

    .school-row-actions .btn {
        flex: 1;
    }

    /* Play / Sign Out actions go full width so they're easy to tap. */
    .actions-row .btn {
        flex: 1;
        min-width: 140px;
    }
}
