/* FSG Today.
 *
 * Two schedule surfaces:
 *   .sched*        the overview table — server-rendered, the default, the one
 *                  people read. Becomes a card list below 820px.
 *   .schedule-view the client component's week grid and list, kept as an
 *                  alternate layout.
 *
 * Colours come from fsg-aura's custom properties where there is one, with a
 * literal fallback so this file is not silently dependent on a variable that
 * may be renamed upstream.
 */

:root {
    /* FSG brand, from the legacy fsgtoday stylesheet. */
    --fsgt-cv: #76b82a;
    --fsgt-ev: #ffdd00;
    --fsgt-dv: #5fc4e1;
    --fsgt-officials: #e40e1b;
    --fsgt-internal: #009926;
    --fsgt-line: rgba(128, 128, 128, .35);
    --fsgt-zebra: rgba(128, 128, 128, .07);
    --fsgt-hover: rgba(0, 74, 153, .09);
}

/* ── Header: audience + layout switches ───────────────────────────────────── */

.sched-head {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sched-switch {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sched-switch-btn {
    background: transparent;
    border: 1px solid var(--fsgt-line);
    border-radius: 999px;
    color: inherit;
    display: inline-block;
    font-size: 13px;
    line-height: 1.2;
    padding: 6px 12px;
    text-decoration: none;
    white-space: nowrap;
}

.sched-switch-btn:hover { background: var(--fsgt-hover); }

.sched-switch-btn.is-active {
    background: var(--color-blue, #004a99);
    border-color: var(--color-blue, #004a99);
    color: #fff;
}

.sched-notice {
    background: var(--fsgt-zebra);
    border-radius: 6px;
    margin: 0 0 12px;
    padding: 10px 12px;
}

/* ── Overview table: controls ─────────────────────────────────────────────── */

/* The table answers to the width IT has, not the window's. fsg-style's sidebar
   takes ~370px, so a 834px tablet leaves about as much room as a phone — a
   viewport media query would keep showing a seven-column table in 450px of
   space. */
.sched {
    container-type: inline-size;
    container-name: sched;
}

.sched-controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 10px;
}

.sched-days {
    display: flex;
    flex: 1 1 260px;
    flex-wrap: wrap;
    gap: 4px;
    /* Without this the chip row's max-content width becomes the flex base and
       the whole page grows sideways to fit it. */
    min-width: 0;
}

.sched-chip {
    background: transparent;
    border: 1px solid var(--fsgt-line);
    border-radius: 999px;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
    padding: 6px 10px;
    white-space: nowrap;
}

.sched-chip:hover { background: var(--fsgt-hover); }

.sched-chip.is-active {
    background: var(--color-blue, #004a99);
    border-color: var(--color-blue, #004a99);
    color: #fff;
}

.sched-chip.is-today { border-color: var(--fsgt-officials); }

.sched-chip-n {
    font-size: 11px;
    opacity: .65;
}

.sched-chip.is-active .sched-chip-n { opacity: .8; }

.sched-search {
    align-items: center;
    border: 1px solid var(--fsgt-line);
    border-radius: 999px;
    display: flex;
    flex: 0 1 auto;
    gap: 6px;
    min-width: 0;
    padding: 4px 12px;
}

.sched-search input {
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    font-size: 14px;
    outline: 0;
    padding: 3px 0;
    width: 190px;
}

/* ── Overview table ───────────────────────────────────────────────────────── */

/* The wrapper scrolls, not the page: a wide table must never make the whole
   document scroll sideways. */
.sched-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sched-table {
    border-collapse: collapse;
    font-size: 14px;
    width: 100%;
}

/* The filter hides rows with the `hidden` attribute, which the UA implements as
   `[hidden] { display: none }` — an author rule setting `display` beats it. The
   card layout below sets `display: block` on tr and td, so without this the day
   chips and the filter box do nothing at all on a phone while still reporting
   that they matched. */
.sched-table [hidden] { display: none; }

.sched-table thead th {
    border-bottom: 2px solid var(--fsgt-line);
    font-size: 12px;
    letter-spacing: .04em;
    padding: 8px 10px;
    position: sticky;
    text-align: left;
    text-transform: uppercase;
    top: 0;
    z-index: 2;
    /* Sticky over scrolling rows needs its own background or the rows show
       through it. */
    background: var(--color-background, #fff);
}

.sched-daybreak th {
    background: var(--fsgt-zebra);
    border-bottom: 1px solid var(--fsgt-line);
    border-top: 1px solid var(--fsgt-line);
    font-size: 13px;
    padding: 7px 10px;
    text-align: left;
}

.sched-daybreak-label { font-weight: 700; }

.sched-daybreak-n {
    font-weight: 400;
    margin-left: 8px;
    opacity: .6;
}

.sched-daybreak-today {
    background: var(--fsgt-officials);
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    margin-left: 8px;
    padding: 1px 6px;
    text-transform: uppercase;
}

.sched-row > td {
    border-bottom: 1px solid var(--fsgt-line);
    padding: 7px 10px;
    vertical-align: top;
}

.sched-row:nth-of-type(even):not([style]) { background: var(--fsgt-zebra); }
.sched-row:hover:not([style]) { background: var(--fsgt-hover); }

.sched-table .c-time {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 1%;
}

.sched-table .c-class {
    white-space: nowrap;
    width: 1%;
}

.sched-table .c-what { font-weight: 600; min-width: 220px; }
.sched-table .c-where { min-width: 130px; }
.sched-table .c-cat,
.sched-table .c-comp { width: 1%; white-space: nowrap; }
.sched-table .c-notes { color: inherit; opacity: .8; }

.sched-badge {
    border-radius: 4px;
    color: #000;
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.5;
    margin-right: 3px;
    min-width: 18px;
    padding: 1px 5px;
    text-align: center;
}

.sched-badge.is-cv { background: var(--fsgt-cv); }
.sched-badge.is-ev { background: var(--fsgt-ev); }
.sched-badge.is-dv { background: var(--fsgt-dv); }
.sched-badge.is-officials { background: var(--fsgt-officials); color: #fff; }
.sched-badge.is-internal { background: var(--fsgt-internal); color: #fff; }
.sched-badge.is-team {
    background: transparent;
    border: 1px solid var(--fsgt-line);
    font-weight: 600;
}

.sched-tag {
    background: var(--fsgt-zebra);
    border-radius: 5px;
    color: #000;
    display: inline-block;
    font-size: 12px;
    line-height: 1.5;
    margin: 1px 2px 1px 0;
    padding: 1px 6px;
    white-space: nowrap;
}

.sched-none {
    padding: 20px 10px;
    text-align: center;
    opacity: .7;
}

/* ── Overview table in a narrow container ─────────────────────────────────── */
/*
 * Under 700px of its own width the table stops being a table. Seven columns
 * cannot be read at 390px and a horizontally scrolling table is not a schedule
 * anybody can use standing in a paddock, so each row becomes a card: time and
 * badges on one line, the activity as the heading, everything else labelled
 * underneath and dropped entirely when empty.
 */
@container sched (max-width: 700px) {
    .sched-table,
    .sched-table tbody,
    .sched-table tr,
    .sched-table td { display: block; width: auto; }

    .sched-table thead { display: none; }

    .sched-table-wrap { overflow-x: visible; }

    .sched-daybreak th {
        border-radius: 6px;
        display: block;
        margin: 14px 0 8px;
        padding: 8px 10px;
    }

    .sched-row {
        border: 1px solid var(--fsgt-line);
        border-radius: 8px;
        margin-bottom: 8px;
        padding: 10px 12px;
        position: relative;
    }

    .sched-row:nth-of-type(even):not([style]) { background: transparent; }

    .sched-row > td {
        border: 0;
        padding: 0;
    }

    /* An empty cell would otherwise leave its label behind. */
    .sched-row > td:empty { display: none; }

    /* The table rules size these to their content with width:1%, which beats
       the `td { width: auto }` above on specificity. Left in place it means a
       card cell is 1% of the card — three pixels — and every chip wraps onto
       its own line. */
    .sched-table .c-time,
    .sched-table .c-class,
    .sched-table .c-cat,
    .sched-table .c-comp { width: auto; }

    .sched-table .c-time {
        font-size: 13px;
        font-weight: 700;
        margin-bottom: 2px;
    }

    .sched-table .c-class {
        position: absolute;
        right: 12px;
        top: 10px;
    }

    .sched-table .c-what {
        font-size: 15px;
        line-height: 1.3;
        margin-bottom: 4px;
        min-width: 0;
        /* Room for the badge stack pinned top-right. */
        padding-right: 90px;
    }

    .sched-table .c-where,
    .sched-table .c-notes { min-width: 0; white-space: normal; }

    .sched-table .c-cat,
    .sched-table .c-comp { white-space: normal; }

    /* Label the cells that are no longer under a header. Flex rather than plain
       inline so a chip sits beside its label instead of dropping to its own
       line, which on a phone is a wasted row per tag. */
    .sched-table .c-where,
    .sched-table .c-cat,
    .sched-table .c-comp,
    .sched-table .c-notes {
        align-items: baseline;
        column-gap: 5px;
        display: flex;
        flex-wrap: wrap;
        font-size: 13px;
        margin-top: 3px;
        row-gap: 2px;
    }

    .sched-table .c-where::before,
    .sched-table .c-cat::before,
    .sched-table .c-comp::before,
    .sched-table .c-notes::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 11px;
        letter-spacing: .04em;
        opacity: .6;
        text-transform: uppercase;
    }

    .sched-table .c-cat .sched-tag,
    .sched-table .c-comp .sched-tag { margin: 0; }

    .sched-search { flex: 1 1 100%; }
    .sched-search input { width: 100%; }
}

@media print {
    .sched-controls,
    .sched-head,
    .sched-switch { display: none; }
    .sched-row > td { padding: 3px 6px; }
    .sched-table { font-size: 10pt; }
}

/* ── Week grid + list (the client component) ──────────────────────────────── */

/* The component ships its own week/list switch. The page now has a Table/Week
   switch that covers the same ground and more, and two controls for one choice
   is worse than one — but the element has to stay in the DOM, because the
   component wires listeners to it unconditionally and would throw without it. */
.schedule-view-selector { display: none; }

.schedule-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

/* Day chips for the week grid. Same furniture as the table's, because they do
   the same job — the component fills them in, so the container is empty (and
   takes no space) until it has. */
.schedule-days {
    display: flex;
    flex: 1 1 260px;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.schedule-days:empty { display: none; }

/* The grid is 13 days wide at FSG scale. It scrolls in its own box rather than
   compressing days to an unreadable width or pushing the page sideways. */
.schedule-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Schedule view list */
.schedule-view.list > .items > .item {
    display: grid;
    font-size: 12px;
    grid-template-columns: 145px 45px 2fr 1fr 150px 80px 100px;
    padding: 6px;
}
.schedule-view.list > .items > .item:not(.head):hover {
    background-color: var(--color-background-contrast);
    cursor: pointer;
}
.schedule-view.list > .items > .item.head {
    border-bottom: 1px solid var(--color-background-contrast);
    font-weight: bold;
}
.schedule-view.list { min-width: 900px; }

/* Schedule view week */
.schedule-view.week {
    border: 1px solid gray;
    border-radius: var(--border-radius-3);
    overflow: hidden;
}
.schedule-view.week > .items {
    display: flex;
}
.schedule-view.week > .items > .item {
    border-left: 1px solid gray;
    min-width: 150px;
    flex-grow: 1;
}
.schedule-view.week > .items > .item:first-child {
    border-left: 0;
}
.schedule-view.week > .items > .item.item-times {
    font-size: 12px;
    width: 70px;
    min-width: 70px;
    flex-grow: 0;
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--color-background, #fff);
}
.schedule-view.week > .items > .item > .label {
    border-bottom: 1px solid gray;
    padding: 6px 12px;
    height: 46px;
}
/* The rendered window, in hours. Set by the component from the data — an FSG
   day runs roughly 07:00-24:00, and a fixed 24-hour grid spends a third of its
   height on empty night. Falls back to a full day. */
.schedule-view.week > .items > .item > .lines {
    display: flex;
    height: calc(var(--sched-hours, 24) * 30px);
}
.schedule-view.week > .items > .item > .lines > .line {
    flex-grow: 1;
    min-width: 74px;
    padding: 0 2px;
    position: relative;
}
.schedule-view.week > .items > .item.item-times .line {
    padding: 0;
    min-width: 0;
}
.schedule-view.week > .items > .item > .lines > .line > .timestamp  {
    background: var(--color-red);
    border-radius: 1px;
    color: var(--color-red);
    cursor: pointer;
    height: 3px;
    font-size: 12px;
    position: relative;
    text-align: center;
}
.schedule-view.week > .items > .item > .lines > .line > .timestamp > span {
    bottom: 4px;
    left: 0;
    position: absolute;
    width: 100%;
    /* A point-in-time marker is a 3px bar; its label must not wrap into the
       column below it and collide with everything else. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.schedule-view.week > .items > .item > .lines > .line > .time  {
    background: var(--color-blue);
    border-radius: var(--border-radius-4);
    box-sizing: border-box;
    color: #fff;
    cursor: pointer;
    font-size: 10px;
    height: auto;
    position: absolute;
    overflow: hidden;
    width: calc(100% - 4px);
}
.schedule-view.week > .items > .item > .lines > .line > .time:hover {
    box-shadow: var(--shadow-3);
    height: max-content !important;
    min-width: 190px;
    z-index: 50;
}

.schedule-view.week > .items > .item > .lines > .line > .time > .content {
    left: 0;
    padding: 4px;
    width: calc(100% - 4px);
}
.schedule-view.week > .items > .item > .lines > .line > .time > .content > .location {
    font-weight: bold;
    padding: 3px 0;
}
.schedule-view.week > .items > .item .hour {
    border-bottom: 1px solid var(--fsgt-line);
    height: 29px;
    position: absolute;
    text-align: center;
    width: 100%;
}

.tag-category {
    border-radius: 5px;
    padding: 3px;
}

.dialog-schedule-item {
    max-width: min(700px, calc(100vw - 32px));
    width: 700px;
}
.dialog-schedule-item iframe.map {
    border: none;
    border-radius: var(--border-radius-3);
    height: 300px;
    width: 100%;
}

/* ── Calendar subscriptions ───────────────────────────────────────────────── */

.cal-lead {
    margin: 0 0 14px;
    max-width: 60ch;
}

.cal-form {
    align-items: flex-end;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.cal-field {
    display: flex;
    flex: 1 1 220px;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.cal-field > span {
    font-size: 12px;
    letter-spacing: .04em;
    opacity: .7;
    text-transform: uppercase;
}

.cal-field > span small { text-transform: none; letter-spacing: 0; }

.cal-field select,
.cal-field input,
.cal-url input,
.cal-inline input[type="text"] {
    background: transparent;
    border: 1px solid var(--fsgt-line);
    border-radius: 6px;
    color: inherit;
    font: inherit;
    font-size: 14px;
    min-width: 0;
    padding: 7px 10px;
    width: 100%;
}

.cal-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.cal-item {
    border: 1px solid var(--fsgt-line);
    border-radius: 8px;
    padding: 12px;
}

.cal-item.is-new { border-color: var(--color-blue, #004a99); }

.cal-item-head {
    align-items: baseline;
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.cal-item-name { font-size: 16px; font-weight: 600; }

.cal-badge {
    background: var(--color-blue, #004a99);
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    text-transform: uppercase;
}

.cal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

/* The link is long and unmemorable by design — it is the feed's only
   credential — so it gets a full-width field that selects on click rather than
   wrapping across three lines of body text. */
.cal-url {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.cal-url > span {
    font-size: 11px;
    letter-spacing: .04em;
    opacity: .6;
    text-transform: uppercase;
}

.cal-url input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.cal-item-foot {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cal-inline {
    align-items: center;
    display: flex;
    gap: 6px;
    min-width: 0;
}

.cal-inline input[type="text"] { flex: 1 1 180px; }

.cal-danger { border-color: var(--fsgt-officials); color: var(--fsgt-officials); }
.cal-danger:hover { background: var(--fsgt-officials); color: #fff; }

@container sched (max-width: 700px) {
    .cal-form, .cal-item-foot, .cal-inline { flex-direction: column; align-items: stretch; }
}

/* ── Install affordances ──────────────────────────────────────────────────── */

.pwa-hint {
    align-items: center;
    background: var(--fsgt-zebra);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    margin: 0 0 12px;
    padding: 10px 12px;
}

.pwa-dismiss {
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    margin-left: auto;
    padding: 0 4px;
}

.pwa-install { cursor: pointer; font: inherit; font-size: 13px; }

/* ── Notifications ────────────────────────────────────────────────────────── */

.push { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }

.push-status { margin: 0; }
.push-status[data-state="on"]::before  { color: var(--fsgt-internal); content: "● "; }
.push-status[data-state="off"]::before { color: var(--fsgt-line); content: "● "; }

.push-devices, .push-note { font-size: 13px; margin: 8px 0 0; opacity: .75; }

button.sched-switch-btn { cursor: pointer; font: inherit; font-size: 13px; }
button.sched-switch-btn[disabled] { cursor: default; opacity: .6; }

/* ── Revision picker ──────────────────────────────────────────────────────── */

.rev-switch { margin-bottom: 10px; }

/* Loud by design. Reading a draft and believing it is the published schedule
   is how an unreleased time gets quoted to a team. */
.rev-warning {
    align-items: center;
    background: var(--fsgt-officials);
    border-radius: 6px;
    color: #fff;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
    padding: 10px 12px;
}

.rev-warning a { color: #fff; text-decoration: underline; }
