/* Term attendance (docs/24 §7.7): the laptop nav foot and, on a phone, the Month view's bottom area.
   One line per course; amber with one absence left, red at the allowance. Theme tokens only. */
:root {
    --term-ease: cubic-bezier(.2, .8, .2, 1);
}

/* Without the feature the nav foot is empty: no divider either. */
.nav-foot:has(> #navTerm[hidden]) {
    display: none;
}

.term-panel {
    color: var(--color-text);
    font-size: .8rem;
}

.term-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0 0 8px;
    border: 0;
    background: none;
    color: var(--color-text-muted);
    font: inherit;
    text-align: left;
}

.term-nav .term-head {
    min-height: 40px;
    padding: 0 8px;
    border-radius: 10px;
    cursor: pointer;
}

.term-nav .term-head:hover {
    background: var(--color-surface-hover);
}

.term-nav .term-head:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

.term-title {
    color: var(--color-text);
    font-family: var(--font-display);
    font-size: .85rem;
    font-weight: 700;
}

.term-stamp {
    flex: 1 1 auto;
    font-size: .72rem;
    text-align: right;
}

.term-chevron {
    flex: none;
    width: 6px;
    height: 6px;
    margin: 0 2px 3px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 320ms var(--term-ease);
}

.term-nav[data-open="false"] .term-chevron {
    margin-bottom: 0;
    transform: rotate(-45deg);
}

/* The rows collapse by animating the grid track from 1fr to 0fr. */
.term-body {
    display: grid;
    grid-template-rows: 1fr;
}

.term-nav .term-body {
    transition: grid-template-rows 320ms var(--term-ease), opacity 220ms ease, transform 320ms var(--term-ease);
}

.term-nav[data-open="false"] .term-body {
    grid-template-rows: 0fr;
    opacity: 0;
    transform: translateY(6px);
}

.term-inner {
    min-height: 0;
    overflow: hidden;
}

.term-rows {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.term-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 0 8px;
    border-radius: 8px;
}

.term-code {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.term-count {
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.term-dots {
    display: inline-flex;
    flex: none;
    justify-content: flex-end;
    gap: 3px;
    width: 33px;
}

.term-dot {
    flex: none;
    width: 6px;
    height: 6px;
    box-sizing: border-box;
    border: 1.5px solid var(--color-border-strong);
    border-radius: 50%;
}

.term-dot[data-used="true"] {
    border: 0;
    background: var(--status-absent);
}

.term-row[data-level="warn"] {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.term-row[data-level="danger"] {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.term-row[data-level="warn"] .term-count,
.term-row[data-level="danger"] .term-count {
    color: inherit;
}

.term-row[data-level="warn"] .term-dot[data-used="true"],
.term-row[data-level="danger"] .term-dot[data-used="true"] {
    background: currentColor;
}

/* A sync is running: greyed, bars instead of numbers. */
.term-panel[data-kind="updating"] .term-rows {
    opacity: .55;
}

.term-panel[data-kind="updating"] .term-row {
    background: transparent;
    color: var(--color-text-muted);
}

.term-skeleton {
    flex: none;
    width: 64px;
    height: 10px;
    border-radius: 5px;
    background: var(--status-loading-bg);
}

.term-notice {
    margin: 0 0 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--color-warning-bg);
    color: var(--color-warning);
    font-size: .75rem;
    line-height: 1.4;
}

.term-empty {
    margin: 4px 8px;
    color: var(--color-text-muted);
}

/* Phone: the panel fills the day area; the toggle above the section bar switches to the day's list. */
.term-flat {
    font-size: .9rem;
}

.term-flat .term-row {
    gap: 12px;
    min-height: 34px;
    padding: 0 10px;
}

.term-flat .term-dots {
    gap: 4px;
    width: 44px;
}

.term-flat .term-dot {
    width: 8px;
    height: 8px;
}

.day-toggle {
    display: none;
}

@media (max-width: 720px) {
    #viewContainer.view-collapsed .day-toggle:not([hidden]) {
        display: flex;
        flex: none;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: var(--touch-target);
        border: 0;
        background: var(--color-surface);
        color: var(--color-text-muted);
        font: inherit;
        font-size: .8rem;
        font-weight: 600;
        cursor: pointer;
    }
}

.day-toggle::after {
    content: "";
    width: 6px;
    height: 6px;
    margin-bottom: 3px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 320ms var(--term-ease);
}

.day-toggle[aria-expanded="true"]::after {
    margin: 3px 0 0;
    transform: rotate(-135deg);
}

@media (prefers-reduced-motion: reduce) {
    .term-nav .term-body,
    .term-chevron,
    .day-toggle::after {
        transition: none;
    }
}
