/* Portal styles: the family portal and the admin pages.
   Layers on top of styles.css and takes its tokens (--navy, --blue, --surface,
   --line and the rest), its header and its buttons. Every class here is one
   js/portal/*.js already builds; this file changes how they look, never what
   they are. */

/* --- Page --------------------------------------------------------------- */

.portal-body { background: var(--page-alt); }

.portal-main {
    min-height: 100vh;
    padding: calc(var(--header-h) + 40px) 0 80px;
}

.portal-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.6rem;
}

.portal-header h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 2.6rem;
    line-height: 1;
}

:lang(zh) .portal-header h1 { font-family: 'Noto Serif SC', var(--font-display); font-weight: 700; font-size: 2.1rem; }

.portal-user { color: var(--muted); font-size: .9rem; }

/* --- Buttons ------------------------------------------------------------ */

/* The marketing pages keep a button on one line; here a label can be a whole
   instruction ("Complete your details first"), so it wraps rather than
   pushing a card wider than a phone. .dialog is listed beside .portal-main
   because dialogs are appended to <body>, outside it. */
.portal-main .btn,
.dialog .btn {
    white-space: normal;
    text-align: center;
}

.btn:disabled,
.btn[disabled] {
    background: var(--line-2);
    color: var(--muted);
    border-color: var(--line);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    opacity: 1;
}

/* --- Tabs --------------------------------------------------------------- */

.portal-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 5px;
    margin-bottom: 1.8rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
}

.portal-tab {
    background: none;
    border: 0;
    padding: .55rem 1.1rem;
    border-radius: 999px;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, color .2s;
}

.portal-tab:hover { color: var(--blue); }

.portal-tab.is-active { background: var(--navy); color: #fff; }

/* --- Cards and panels --------------------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.75rem;
}

.panel h2,
.panel h3 { font-family: var(--font-sans); }

.auth-card {
    max-width: 460px;
    margin: 2rem auto;
}

.auth-card h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 2rem;
    line-height: 1.1;
    margin-bottom: .6rem;
}

:lang(zh) .auth-card h2 { font-family: 'Noto Serif SC', var(--font-display); font-weight: 700; font-size: 1.6rem; }

.auth-card p {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

/* --- Google sign-in ----------------------------------------------------- */

/* Google renders its own button here and controls its appearance; their
   brand terms don't allow restyling it. We only centre it. */
.google-slot {
    display: flex;
    justify-content: center;
    min-height: 44px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin: 1.4rem 0;
    color: var(--muted);
    font-size: .85rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: var(--line);
}

/* --- Choice list (account type, "who is joining?") ----------------------- */

.choice-list {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin: 1rem 0 1.5rem;
}

.choice {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    text-align: left;
    width: 100%;
    padding: 1rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.choice:hover:not(:disabled) {
    border-color: var(--blue);
    background: var(--blue-50);
    box-shadow: 0 2px 10px rgba(10, 88, 202, .1);
}

.choice:focus-visible {
    outline: 3px solid rgba(10, 88, 202, .35);
    outline-offset: 2px;
}

.choice:disabled { opacity: .55; cursor: not-allowed; }

.choice-label { font-weight: 600; color: var(--ink); font-size: 1rem; }
.choice-hint { font-size: .87rem; color: var(--muted); }

/* --- Attendee chips ----------------------------------------------------- */

/* One per enrolled child on a session card. */
.attendee-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .55rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .7rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.chip-in { background: #e7f5ec; color: #1a7f3c; border-color: #c5e8d2; }
.chip-in:hover:not(:disabled) { background: #d6eede; }

.chip-away { background: #f2f4f7; color: #667085; border-color: #e3e7ee; }
.chip-away:hover:not(:disabled) { background: #e8ebef; }
.chip-away .chip-state { text-decoration: line-through; }

.chip:disabled { cursor: default; opacity: .7; }

.chip-state { font-weight: 500; opacity: .8; }

/* --- Banner ------------------------------------------------------------- */

.banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: #fff8e6;
    border: 1px solid #f5d78e;
    border-radius: var(--radius);
    box-shadow: inset 4px 0 0 #e0a800;
    padding: 1rem 1.25rem 1rem 1.4rem;
    margin-bottom: 1.5rem;
    color: #6b5200;
}

/* --- Forms -------------------------------------------------------------- */

.form-field { margin-bottom: 1.25rem; }

.form-field label {
    display: block;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: .4rem;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: .75rem .95rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--surface-2);
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--blue);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(10, 88, 202, .12);
}

.field-hint {
    display: block;
    margin-top: .35rem;
    font-size: .85rem;
    color: var(--muted);
}

.form-section {
    border-top: 1px solid var(--line);
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

.form-section h3 { color: var(--ink); margin-bottom: .25rem; }

/* --- Week navigation ---------------------------------------------------- */

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.week-label {
    font-family: var(--font-display);
    font-size: 1.6rem;
    line-height: 1.1;
    color: var(--ink);
}

.week-nav-buttons { display: flex; gap: .5rem; }

/* --- Day groups and session cards --------------------------------------- */

.day-group { margin-bottom: 2rem; }

.day-heading {
    display: flex;
    align-items: center;
    gap: .8rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: .8rem;
}

.day-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

:lang(zh) .day-heading,
:lang(zh) .week-label { font-family: 'Noto Serif SC', var(--font-display); font-weight: 700; font-size: 1.2rem; }

.session-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.05rem 1.25rem;
    margin-bottom: .6rem;
    transition: box-shadow .2s, border-color .2s;
}

.session-card:hover { box-shadow: var(--shadow-sm); border-color: var(--blue-200); }

/* State is a 3px bar down the left edge, drawn inside the card's rounded
   corners rather than as a border that would square them off. */
.session-card::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 3px;
    background: var(--blue-200);
}

.session-time {
    flex: 0 0 auto;
    min-width: 9.5rem;
    font-family: var(--font-display);
    font-size: 1.3rem;
    line-height: 1.15;
    color: var(--ink);
}

:lang(zh) .session-time { font-family: var(--font-sans); font-size: 1.02rem; font-weight: 600; }

.session-body { flex: 1 1 auto; min-width: 0; }

.session-name {
    font-weight: 600;
    color: var(--ink);
    margin-bottom: .15rem;
}

.session-meta {
    font-size: .86rem;
    color: var(--muted);
}

.session-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.seat-count {
    font-size: .85rem;
    color: var(--muted);
    white-space: nowrap;
}

.seat-count.is-low { color: #b54708; font-weight: 600; }

.badge {
    display: inline-block;
    padding: .3rem .75rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-registered { background: #e7f5ec; color: #1a7f3c; }
.badge-full       { background: #fdecea; color: #b42318; }
.badge-cancelled  { background: #f2f4f7; color: #667085; }
.badge-past       { background: #f2f4f7; color: #667085; }

.session-card.is-registered {
    border-color: #bfe3cc;
    background: linear-gradient(90deg, #f3fbf6, var(--surface) 40%);
}

.session-card.is-registered::before { background: #1a7f3c; }

.session-card.is-cancelled { background: var(--surface-2); }
.session-card.is-cancelled::before { background: #c4ccd8; }

.session-card.is-cancelled .session-name,
.session-card.is-cancelled .session-time {
    text-decoration: line-through;
    color: #98a2b3;
}

.session-card.is-past { opacity: .65; }
.session-card.is-past::before { background: #c4ccd8; }

/* --- Notice cards -------------------------------------------------------- */

/* Notices borrow the session card's shape but not its states. Giving them
   .is-cancelled once struck a line through the whole sentence and greyed it,
   so "we could not offer Leo a place" arrived crossed out and hard to read.
   Colour lives in the left edge; the words stay plain. */
.notice-card { margin-bottom: .6rem; }
.notice-card .session-name { color: var(--ink); text-decoration: none; }
.notice-good::before  { background: #1a7f3c; }
.notice-alert { border-color: #f5d0cb; background: #fffaf9; }
.notice-alert::before { background: #b42318; }

/* Admin week view: the whole card is the control that opens a roster. */
.session-card.is-clickable { cursor: pointer; }
.session-card.is-clickable:focus-visible {
    outline: 3px solid rgba(10, 88, 202, .4);
    outline-offset: 2px;
}

/* --- Empty and loading states ------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
}

.empty-state h3 { color: var(--ink); margin-bottom: .5rem; }

.spinner {
    width: 34px;
    height: 34px;
    margin: 3rem auto;
    border: 3px solid var(--line);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: portal-spin .8s linear infinite;
}

@keyframes portal-spin { to { transform: rotate(360deg); } }

/* styles.css stops every animation under reduced motion, which would leave
   the spinner a still ring. A slow turn still says "working". */
@media (prefers-reduced-motion: reduce) {
    .spinner { animation: portal-spin 2.4s linear infinite !important; }
}

/* --- Status lines ------------------------------------------------------- */

.status-line {
    margin-top: 1rem;
    padding: .75rem 1rem;
    border-radius: 12px;
    font-size: .92rem;
}

.status-error   { background: #fdecea; color: #b42318; border: 1px solid #f5c6c0; }
.status-success { background: #e7f5ec; color: #1a7f3c; border: 1px solid #b3e0c4; }
.status-info    { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-200); }

/* --- Dialog ------------------------------------------------------------- */

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 26, 54, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    z-index: 2000;
}

/* Centred while it fits, capped and self-scrolling once it does not. Without
   the cap, a dialog taller than the window is clipped at both ends by the
   centring and cannot be scrolled; on a phone in landscape, or with the
   keyboard open, that put Save out of reach. dvh tracks the browser chrome
   sliding away on mobile; vh is the older fallback. */
.dialog {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    max-width: 26rem;
    width: 100%;
    max-height: calc(100vh - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.dialog-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.7rem;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: .6rem;
}

:lang(zh) .dialog-title { font-family: 'Noto Serif SC', var(--font-display); font-weight: 700; font-size: 1.3rem; }

.dialog-body { color: var(--muted); margin-bottom: 1.5rem; }

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    flex-wrap: wrap;
}

/* --- Roster table ------------------------------------------------------- */

.roster-scroll { overflow-x: auto; }

.roster-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 40rem;
}

.roster-table th,
.roster-table td {
    text-align: left;
    padding: .8rem .9rem;
    border-bottom: 1px solid var(--line-2);
    font-size: .93rem;
}

.roster-table th {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    border-bottom-color: var(--line);
}

.roster-table tbody tr:hover { background: var(--surface-2); }

.roster-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.roster-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin-top: .4rem;
    font-size: .88rem;
    color: var(--muted);
    cursor: pointer;
}

.roster-table tr.is-away td { opacity: .55; }
.roster-table tr.is-settled td { opacity: .65; }

/* --- Make-up counter ----------------------------------------------------- */

/* The +/- pair on the make-up balance. Tabular numerals so the count does not
   jitter sideways between 1 and 8 while somebody presses. */
.counter {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.counter-value {
    min-width: 1.75rem;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.counter-btn {
    min-width: 2.5rem;
    padding-left: .6rem;
    padding-right: .6rem;
    font-size: 1.05rem;
    line-height: 1;
}

/* --- Copy-addresses dialog ------------------------------------------------ */

/* Wider than a confirm, so a list of addresses reads as a list rather than a
   column of fragments. */
.dialog.dialog-wide { max-width: 34rem; }

.copy-area {
    width: 100%;
    padding: .75rem .95rem;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-family: inherit;
    font-size: .9rem;
    color: var(--ink);
    background: var(--surface-2);
    resize: vertical;
    word-break: break-all;
}

/* Day heading with its own action beside it, on the admin week view. */
.day-heading-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    /* The row owns the space beneath it, not the heading inside it. The button
       is taller than the heading text, so with align-items:flex-end the row's
       bottom edge is the button's, and the heading's own margin would sit
       above it doing nothing. Without this the button lands directly on the
       first session card. */
    margin-bottom: .85rem;
}

.day-heading-row .day-heading {
    flex: 1 1 auto;
    margin-bottom: 0;
}

.minor-tag {
    display: inline-block;
    margin-left: .4rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: .72rem;
    font-weight: 600;
}

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 768px) {
    .portal-main { padding: calc(var(--header-h) + 24px) 0 3rem; }
    .portal-header h1 { font-size: 2rem; }
    .panel { padding: 1.25rem; }

    .session-card {
        flex-direction: column;
        align-items: stretch;
        gap: .75rem;
    }

    .session-time { min-width: 0; }

    .session-actions {
        justify-content: space-between;
        width: 100%;
        /* Admin class cards carry four buttons. Without this they compress
           to unreadable slivers instead of wrapping onto a second row. */
        flex-wrap: wrap;
    }

    /* A fixed basis rather than auto, so four buttons wrap two and two instead
       of sitting four across at 40px each. 6.5rem and not more: at 375px a card
       has about 245px of room, so anything above ~7rem puts two buttons over
       the line and they stack one per row, fourteen cards down the page. */
    .session-actions .btn { flex: 1 1 6.5rem; }

    .week-nav { flex-direction: column; align-items: stretch; }
    .week-nav-buttons { justify-content: space-between; }
    .week-nav-buttons .btn { flex: 1 1 auto; }
    .week-label { text-align: center; }

    /* Tabs wrap rather than scroll off the edge. The admin bar is five tabs
       wide, and on a phone Attendance and Payments sat past the right edge
       with no scrollbar to say so. As a wrapped group they read as one
       control, so the pill becomes a rounded panel. */
    .portal-tabs { display: flex; border-radius: 18px; }
    .portal-tab { flex: 1 1 auto; }

    /* Taking attendance happens standing in the room holding a phone, so the
       roster stops being a table there and becomes one card per student.
       Scrolling it sideways put Mark absent, the whole point of the screen,
       beyond the right edge of a 375px phone. The header row goes away and
       each cell carries its own label. */
    .roster-scroll { overflow-x: visible; }

    .roster-table { min-width: 0; display: block; }
    .roster-table thead { display: none; }
    .roster-table tbody,
    .roster-table tr,
    .roster-table td { display: block; width: 100%; }

    .roster-table tr {
        position: relative;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: inset 3px 0 0 var(--blue);
        padding: .9rem 1rem .9rem 1.15rem;
        margin-bottom: .6rem;
    }

    .roster-table tbody tr:hover { background: var(--surface); }

    .roster-table td {
        border-bottom: none;
        padding: .25rem 0;
    }

    /* The label a phone loses with the header row. */
    .roster-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .1em;
    }

    /* The name heads the card, so it needs no label above it. */
    .roster-table td.cell-name {
        font-size: 1rem;
        font-weight: 600;
        color: var(--ink);
        padding-top: 0;
    }
    .roster-table td.cell-name::before { content: none; }

    .roster-table td.cell-action { margin-top: .7rem; padding-bottom: 0; }
    .roster-table td.cell-action::before { content: none; }
    .roster-table td.cell-action .btn { width: 100%; }

    /* cell-counter rather than cell-action: cell-action drops the label above,
       which is right for a button whose own text says what it does and wrong
       for a bare + and -. This one keeps its data-label and takes the same
       spacing. */
    .roster-table td.cell-counter { margin-top: .7rem; padding-bottom: 0; }

    .counter { width: 100%; justify-content: space-between; }
    .counter-btn { flex: 1 1 auto; }
    .counter-value { flex: 0 0 auto; min-width: 3rem; font-size: 1.1rem; }

    /* Comfortable to hit with a thumb. These are the primary actions on every
       screen the portal has. */
    .btn-small { min-height: 44px; }
    .site-header--app .lang-btn,
    .site-header--app .header-link { min-height: 40px; display: inline-flex; align-items: center; }
}

@media (max-width: 480px) {
    .portal-tab { padding: .6rem .8rem; font-size: .88rem; }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions .btn { width: 100%; }
}
