/**
 * Timeplan (ukeplan) list type.
 *
 * One card per weekday, since a recurring schedule is read by finding your day
 * first and a time that fits second. Each card carries its own table so the
 * weekday reads as a heading rather than as a row inside a long table.
 *
 * Colours come from custom properties only, so a theme can restyle the cards
 * without overriding layout rules.
 */

#ka .ka-timeplan {
    /* Prefer the design tokens from Kursdesign (advanced colours), so a change
       to “Bakgrunn fremhevede områder” / “Alternativ farge for bokser” / main
       colour lands here without per-view overrides. */
    --ka-timeplan-border: color-mix(in srgb, var(--ka-box-background) 97%, black 3%);
    --ka-timeplan-line: color-mix(in srgb, var(--ka-box-background) 97%, black 3%);
    --ka-timeplan-card-bg: var(--ka-box-background, transparent);
    --ka-timeplan-card-radius: var(--ka-radius-md, 12px);
    --ka-timeplan-chip-bg: var(--ka-highlight-background, var(--ka-alt-background, #f3f2f5));
    --ka-timeplan-muted: var(--ka-color-filter, #6b6b6b);
    --ka-timeplan-strong: inherit;
    width: 100%;
}

#ka .ka-timeplan-heading {
    margin: 0 0 1.5em;
    color: var(--ka-timeplan-strong);
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
}

#ka .ka-timeplan-empty {
    margin: 1em 0;
    color: var(--ka-timeplan-muted);
}

/* Day card
   ------------------------------------------------------------------------- */

#ka .ka-timeplan-day {
    margin-bottom: 1.25em;
    padding: 1.1em 1.25em 0.75em;
    border: 1px solid var(--ka-timeplan-border);
    border-radius: var(--ka-timeplan-card-radius);
    background: var(--ka-timeplan-card-bg);
}

#ka .ka-timeplan-day:last-of-type {
    margin-bottom: 0;
}

#ka .ka-timeplan-day-head {
    display: flex;
    align-items: center;
    gap: 1em;
    flex-wrap: wrap;
    margin-bottom: 1em;
}

#ka .ka-timeplan-day-name {
    margin: 0;
    color: var(--ka-timeplan-strong);
    font-size: 1.05em;
    font-weight: 700;
    line-height: 1.2;
}

#ka .ka-timeplan-day-range {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    margin: 0;
    padding: 0.2em 0.6em;
    border-radius: 999px;
    color: var(--ka-timeplan-muted);
    font-size: 1em;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#ka .ka-timeplan-day-icon {
    flex: 0 0 auto;
    width: 1.1em;
    height: 1.1em;
}

/* Table
   ------------------------------------------------------------------------- */

#ka .ka-timeplan-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.9em;
}

/* The header row exists for screen readers only. The cells are collapsed rather
   than the <thead>, because browsers ignore `position` on a table-header-group
   and the row would stay visible. The label itself is hidden by the span. */
#ka .ka-timeplan .ka-timeplan-table thead th {
    height: 0;
    padding: 0;
    border: 0;
    line-height: 0;
    font-size: 0;
}

#ka .ka-timeplan .ka-timeplan-room-header th {
    padding: 1.8em 0.6em 0.3em;
    color: var(--ka-timeplan-strong);
    font-size: 1.1em;
    font-weight: 700;
    text-align: left;
}

#ka .ka-timeplan .ka-timeplan-room-header th::after {
    content: ":";
}

#ka .ka-timeplan-room-group:first-of-type .ka-timeplan-room-header th {
    padding-top: 0.3em;
}

#ka .ka-timeplan-row td {
    padding: 0.55em 0.6em;
    vertical-align: top;
}

/* Border between course rows only. :first-child/:first-of-type fail here because
   they mean “first <tr>”, not “first .ka-timeplan-row” – a room header in the
   same <tbody> steals both, and the course row keeps its border. */
#ka .ka-timeplan-row + .ka-timeplan-row td {
    border-top: 1px solid var(--ka-timeplan-line);
}

#ka .ka-timeplan-row.is-full {
    opacity: 0.65;
}

#ka .ka-timeplan-time {
    width: 14%;
    color: var(--ka-timeplan-strong);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#ka .ka-timeplan-frequency {
    display: block;
    color: var(--ka-timeplan-muted);
    font-size: 0.85em;
}

#ka .ka-timeplan-name {
    width: 34%;
    color: var(--ka-timeplan-strong);
    font-weight: 700;
}

/* Scoped one level deeper than the theme's own link rules, so the plan keeps a
   calm two-colour look instead of inheriting the site's accent on every row. */
#ka .ka-timeplan .ka-timeplan-name a {
    color: var(--ka-timeplan-strong);
    text-decoration: none;
    text-underline-offset: 0.25em;
    text-decoration-color: color-mix(in srgb, var(--ka-timeplan-muted) 20%, transparent 80%);
}

#ka .ka-timeplan .ka-timeplan-name a:hover,
#ka .ka-timeplan .ka-timeplan-name a:focus {
    color: var(--ka-timeplan-strong);
    text-decoration: underline;
    text-underline-offset: 0.25em;
    text-decoration-color: color-mix(in srgb, var(--ka-timeplan-muted) 20%, transparent 80%);
}

#ka .ka-timeplan-room {
    display: block;
    color: var(--ka-timeplan-muted);
    font-size: 0.85em;
}

#ka .ka-timeplan-level {
    width: 12%;
    color: var(--ka-timeplan-muted);
    font-size: var(--ka-font-s);
}

#ka .ka-timeplan-instructor {
    width: 35%;
    color: var(--ka-timeplan-muted);
}

#ka .ka-timeplan .ka-timeplan-instructor a {
    color: var(--ka-timeplan-muted)!important;
    font-size: var(--ka-font-s);
    text-underline-offset: 0.25em;
    text-decoration-color: color-mix(in srgb, var(--ka-timeplan-muted) 20%, transparent 80%);
}

#ka .ka-timeplan .ka-timeplan-instructor a:hover,
#ka .ka-timeplan .ka-timeplan-instructor a:focus {
    color: var(--ka-timeplan-strong);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--ka-timeplan-muted) 20%, transparent 80%);
}

#ka .ka-timeplan-signup {
    width: 15%;
    text-align: right;
    white-space: nowrap;
}

#ka .ka-timeplan .ka-timeplan-signup .signup-link {
    cursor: pointer;
    color: var(--ka-timeplan-strong)!important;
    font-size: var(--ka-font-s);
    text-underline-offset: 0.25em;
    text-decoration-color: color-mix(in srgb, var(--ka-timeplan-muted) 20%, transparent 80%);
}

#ka .ka-timeplan .ka-timeplan-signup .signup-link::after {
    content: "\2192";
    margin-left: 0.25em;
    text-decoration: none;
}

#ka .ka-timeplan .ka-timeplan-signup .signup-link:hover,
#ka .ka-timeplan .ka-timeplan-signup .signup-link:focus {
    text-decoration: underline;
    text-underline-offset: 0.25em;
    text-decoration-color: color-mix(in srgb, var(--ka-timeplan-muted) 20%, transparent 80%);
}

#ka .ka-timeplan-status.ka-full {
    color: var(--ka-timeplan-muted);
    font-size: 0.9em;
}

#ka .ka-timeplan-status.ka-few {
    color: #b36b00;
    font-size: 0.9em;
    font-weight: 600;
}

/* Admin-only notice
   ------------------------------------------------------------------------- */

#ka .ka-timeplan-other {
    margin-top: 2em;
    padding: 0.9em 1em;
    border: 1px dashed var(--ka-timeplan-border);
    border-radius: var(--ka-radius-sm, 4px);
    font-size: 0.95em;
    background: var(--ka-timeplan-chip-bg);
}

#ka .ka-timeplan-other-badge {
    margin: 0 0 0.4em;
    color: var(--ka-timeplan-muted);
    font-size: 0.75em;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#ka .ka-timeplan-other summary {
    cursor: pointer;
    color: var(--ka-timeplan-muted);
}

#ka .ka-timeplan-other-list {
    margin: 0.6em 0 0;
    padding-left: 1.2em;
}

#ka .ka-timeplan-other-reason {
    color: var(--ka-timeplan-muted);
    font-size: 0.85em;
}

#ka .ka-timeplan-other-reason::before {
    content: " – ";
}

/* Phone: five columns cannot be read side by side, so each row becomes a small
   block with the time as its anchor. */
@media (max-width: 640px) {
    #ka .ka-timeplan-heading {
        font-size: 1.25em;
    }

    #ka .ka-timeplan-day {
        padding: 1em 0.9em 0.6em;
    }

    #ka .ka-timeplan-row {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 0 0.75em;
        padding: 0.7em 0;
        border-top: 1px solid var(--ka-timeplan-line);
    }

    #ka .ka-timeplan-row td {
        width: auto;
        padding: 0;
        border: 0;
    }

    #ka .ka-timeplan-row:hover td {
        background: none;
    }

    #ka .ka-timeplan-time {
        grid-row: 1 / span 4;
        font-weight: 600;
    }

    #ka .ka-timeplan-name {
        font-weight: 600;
    }

    #ka .ka-timeplan-signup {
        margin-top: 0.2em;
        text-align: left;
    }
}
