/* The activities record, on every campus page and both Achievements tabs.

   Fly-posters wheat-pasted on a site hoarding, the month stencilled on the
   boards, the perforated tear-off slip of a freshers' fair flyer for events
   that were only announced, and the union's wall calendar for finding your way. */

.rec { --rec-top: 75px; --rec-cal-h: 70px; }

/* Count line and provenance, above the record */
.rec-lede { margin-top: var(--space-3); color: var(--c-ink-soft); max-width: 62ch; }
.rec-lede strong { color: var(--c-ink); }
.section__head .rec-note,
.rec-note {
    margin-top: var(--space-3);
    max-width: 68ch;
    font-size: 0.86rem;
    color: var(--c-ink-soft);
    border-left: 3px solid var(--c-accent);
    padding-left: var(--space-2);
}
.rec-note a { color: var(--c-ink); text-decoration: underline; text-underline-offset: 3px; }

/* Filter row. Hidden until the script can drive it. */
.rec-filt { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--space-3); }
.rec-filt[hidden] { display: none; }
.rec-filt button {
    min-height: 44px;
    padding: 8px 14px;
    border: 3px solid var(--c-ink);
    background: var(--c-bg);
    color: var(--c-ink);
    font: inherit;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.12s linear, color 0.12s linear;
}
.rec-filt button span { opacity: 0.7; margin-left: 6px; }
.rec-filt button[aria-pressed="true"] { background: var(--c-ink); color: var(--c-bg); }
.rec-filt button:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 3px; }

/* The calendar strip: every month of the record, newest first, matching the
   page below it. Sticks under the header and marks the month you are in. */
.rec-cal {
    position: sticky;
    top: calc(var(--rec-top) - 3px);
    z-index: 15;
    margin-bottom: var(--space-5);
    background: var(--c-bg);
    border: 3px solid var(--c-ink);
    box-shadow: 6px 6px 0 var(--c-accent);
}
.rec-cal__track {
    position: relative;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(62px, 1fr);
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}
.rec-cal__track::-webkit-scrollbar { display: none; }
.rec-cal.is-scroll:not(.is-end) .rec-cal__track {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent);
}
.rec-cal__track li { display: flex; scroll-snap-align: start; }
.rec-cal__m {
    flex: 1;
    display: grid;
    align-content: start;
    gap: 1px;
    min-height: 64px;
    padding: 8px 10px 9px;
    border-left: 1px solid var(--c-line);
    color: var(--c-ink);
    text-decoration: none;
    transition: background 0.12s linear, color 0.12s linear;
}
.rec-cal__track li:first-child .rec-cal__m { border-left: 0; }
.rec-cal__m--yr { border-left: 3px solid var(--c-ink); }
.rec-cal__mm { font-family: var(--f-display); font-size: 1.3rem; line-height: 1; text-transform: uppercase; color: var(--c-head); }
.rec-cal__yy { font-size: 0.6rem; letter-spacing: 0.14em; color: var(--c-ink-soft); }
.rec-cal__n { min-height: 1.1em; font-size: 0.74rem; font-weight: 700; color: var(--c-accent-ink); }
a.rec-cal__m:not(.is-quiet):hover,
.rec-cal__m[aria-current="true"] { background: var(--c-ink); }
a.rec-cal__m:not(.is-quiet):hover *,
.rec-cal__m[aria-current="true"] * { color: var(--c-bg); }
a.rec-cal__m:focus-visible { outline: 3px solid var(--c-focus); outline-offset: -3px; }
/* A quiet month is hatched, the wall planner's mark for time off, and its
   name drops to the soft ink. Not faded: faded text failed contrast. */
.rec-cal__m.is-quiet {
    cursor: default;
    background: repeating-linear-gradient(135deg, transparent 0 6px, var(--c-track) 6px 7px);
}
.rec-cal__m.is-quiet .rec-cal__mm { color: var(--c-ink-soft); }

/* The Achievements tab bar stops sticking where a record is in its panel: the
   calendar takes that job, and two sticky bars plus the header is a third of
   a laptop screen. Relative, not static: the sliding pill is positioned
   against the bar, and without a positioned bar it spans the whole page. */
.tabs:has(.rec) .tab-list { position: relative; top: auto; }

/* A month: the stencilled date on the left, the posters on the boards beside it */
.rec-hoard { display: grid; gap: var(--space-6); }
.rec-run {
    display: grid;
    grid-template-columns: 148px minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
    scroll-margin-top: calc(var(--rec-top) + var(--rec-cal-h) + 16px);
}
.rec-run[hidden], .rec-wall[hidden], .rec-slips[hidden], .rec-run li[hidden] { display: none; }
.rec-run__month {
    position: sticky;
    top: calc(var(--rec-top) + var(--rec-cal-h) + 22px);
    display: grid;
    margin: 0;
    font-family: var(--f-display);
    font-weight: 400;
    font-size: 1rem;
    line-height: 0.86;
    color: var(--c-head);
}
.rec-run__month:focus { outline: none; }
.rec-run__m { font-size: 4.2rem; text-transform: uppercase; letter-spacing: 0.01em; }
.rec-run__y { margin-top: 6px; font-size: 1.7rem; color: var(--c-accent-ink); }
.rec-run__n {
    justify-self: start;
    margin-top: 14px;
    padding: 4px 8px;
    background: var(--c-accent);
    color: #fff;
    font-family: var(--f-body);
    font-size: 0.66rem;
    line-height: 1.4;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

/* The boards: hoarding panels with a seam every 236px */
.rec-wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 28px 22px;
    margin: 0;
    padding: 26px 22px 30px;
    list-style: none;
    background:
        repeating-linear-gradient(90deg, transparent 0 234px, var(--c-line) 234px 236px),
        var(--c-bg);
    border: 3px solid var(--c-ink);
}

/* A short month gets a board cut to its posters, and bigger posters on it,
   so two bills do not sit at one end of an empty hoarding. */
@media (min-width: 761px) {
    .rec-wall:not(:has(> li:nth-child(5))) {
        width: fit-content;
        max-width: 100%;
        grid-template-columns: repeat(4, minmax(0, 214px));
        background: var(--c-bg);
    }
    .rec-wall:not(:has(> li:nth-child(4))) { grid-template-columns: repeat(3, minmax(0, 236px)); }
    .rec-wall:not(:has(> li:nth-child(3))) { grid-template-columns: repeat(2, minmax(0, 236px)); }
    .rec-wall:not(:has(> li:nth-child(2))) { grid-template-columns: minmax(0, 236px); }
}

/* A bill */
.rec-bill {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    position: relative;
    transform: rotate(var(--r));
    transition: transform 0.18s var(--e-out);
}
.rec-bill__paper {
    display: block;
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border: 3px solid var(--c-ink);
    background: var(--c-bg-2);
    box-shadow: 5px 5px 0 var(--c-ink);
    transition: box-shadow 0.18s var(--e-out);
}
.rec-bill__paper img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
/* Paste tape across the top edge */
.rec-bill__paper::before {
    content: "";
    position: absolute;
    z-index: 1;
    top: -2px;
    left: 50%;
    width: 64px;
    height: 16px;
    transform: translateX(-50%) rotate(-2deg);
    background: rgba(255, 245, 225, 0.72);
    border-left: 1px dashed rgba(56, 0, 0, 0.25);
    border-right: 1px dashed rgba(56, 0, 0, 0.25);
}
.rec-bill:hover, .rec-bill:focus-visible { transform: rotate(0deg) translate(-3px, -3px); }
.rec-bill:hover .rec-bill__paper, .rec-bill:focus-visible .rec-bill__paper { box-shadow: 9px 9px 0 var(--c-accent); }
.rec-bill:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 6px; }

/* No poster to show: the title is the poster */
.rec-bill--type .rec-bill__paper { display: flex; align-items: flex-end; padding: 16px; background: var(--c-accent); }
.rec-wall li:nth-child(3n) .rec-bill--type .rec-bill__paper { background: #6d0000; }
.rec-bill__type {
    display: -webkit-box;
    -webkit-line-clamp: 7;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: var(--f-display);
    font-size: 1.45rem;
    line-height: 1.02;
    color: #fff;
    text-transform: uppercase;
}

/* On a campus page, work its own groups did not run; on the ASAP tab, work
   ASAP backed rather than organised: a rubber stamp in the corner */
.rec-bill[data-stamp]::after {
    content: attr(data-stamp);
    position: absolute;
    z-index: 2;
    top: 14px;
    right: -6px;
    transform: rotate(6deg);
    padding: 3px 8px;
    border: 2px solid var(--c-accent);
    background: var(--c-bg);
    color: var(--c-accent-ink);
    font-size: 0.6rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.rec-bill__cap { display: grid; gap: 4px; margin-top: 14px; }
.rec-bill__date { font-size: 0.64rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--c-accent-ink); }
.rec-bill__t {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: var(--f-display);
    font-size: 1.08rem;
    line-height: 1.12;
    color: var(--c-head);
}
.rec-bill--type .rec-bill__t { display: none; }
.rec-bill__who {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.8rem;
    color: var(--c-ink-soft);
    overflow-wrap: anywhere;
}

/* Announced only: perforated slips under the month */
.rec-slips { margin-top: 22px; }
.rec-slips__h { margin-bottom: 10px; font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--c-ink-soft); }
.rec-slips ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.rec-slip {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    min-height: 44px;
    max-width: 100%;
    padding: 10px 14px 10px 18px;
    background: var(--c-bg);
    color: var(--c-ink);
    border: 2px solid var(--c-ink);
    border-left: 2px dashed var(--c-ink);
    font: inherit;
    font-size: 0.84rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s linear, color 0.12s linear;
}
.rec-slip:hover, .rec-slip:focus-visible { background: var(--c-ink); color: var(--c-bg); }
.rec-slip:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 3px; }
.rec-slip__date { font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }

/* Paste-up: a month's bills go up in a quick run as it scrolls in. Only once
   the script is running, so with no script nothing is ever left hidden. */
.rec.is-live .rec-run .rec-wall li {
    opacity: 0;
    transform: translateY(-18px) rotate(3deg) scale(1.05);
    transition: opacity 0.32s var(--e-out), transform 0.42s var(--e-out);
    transition-delay: calc(var(--i) * 45ms);
}
.rec.is-live .rec-run.is-up .rec-wall li { opacity: 1; transform: none; }

/* Nothing on the record */
.rec-empty { max-width: 62ch; padding: var(--space-5); border: 3px dashed var(--c-line); }
.rec-empty p + p { margin-top: 10px; color: var(--c-ink-soft); }
.rec-empty::before {
    content: "";
    display: block;
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-3);
    background: var(--c-accent-ink);
    -webkit-mask: url("../assets/tatreez-star.svg") center / contain no-repeat;
    mask: url("../assets/tatreez-star.svg") center / contain no-repeat;
}
.rec-empty a { text-decoration: underline; text-underline-offset: 3px; }

/* The entry sheet: the full entry, in a modal dialog */
.rec-sheet {
    width: min(880px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 3px solid var(--c-ink);
    background: var(--c-bg);
    color: var(--c-ink);
    box-shadow: 10px 10px 0 var(--c-accent);
    overflow: auto;
    overscroll-behavior: contain;
}
.rec-sheet::backdrop { background: rgba(56, 0, 0, 0.62); }
.rec-sheet__in { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: var(--space-4); padding: var(--space-4); }
.rec-sheet__in--text { grid-template-columns: minmax(0, 1fr); }
.rec-sheet__img img { width: 100%; height: auto; border: 3px solid var(--c-ink); }
.rec-sheet__cat { font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--c-accent-ink); }
.rec-sheet__t {
    margin: 8px 0 14px;
    font-family: var(--f-display);
    font-weight: 400;
    font-size: clamp(1.6rem, 4vw, 2.3rem);
    line-height: 1.02;
    color: var(--c-head);
}
.rec-sheet p { margin-bottom: 12px; line-height: 1.65; max-width: 62ch; }
.rec-sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 18px 0 0; font-size: 0.88rem; }
.rec-sheet dt { padding-top: 3px; font-size: 0.64rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--c-ink-soft); }
.rec-sheet dd { margin: 0; overflow-wrap: anywhere; }
.rec-sheet dd a { text-decoration: underline; text-underline-offset: 3px; }
.rec-sheet__close {
    position: sticky;
    top: 0;
    float: right;
    z-index: 2;
    min-width: 44px;
    min-height: 44px;
    margin: 8px 8px 0 0;
    border: 3px solid var(--c-ink);
    background: var(--c-bg);
    color: var(--c-ink);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}
.rec-sheet__close:focus-visible, .rec-sheet a:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 3px; }

/* Phones. The calendar becomes a strip you swipe, and is the only thing that
   sticks under the header; the filters swipe too, so they take one row; the
   month heads sit inline above two columns of bills; the sheet rises from the
   bottom of the screen. */
@media (max-width: 760px) {
    .rec { --rec-cal-h: 58px; }
    .rec-filt { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: -4px -4px var(--space-2); padding: 4px; }
    .rec-filt::-webkit-scrollbar { display: none; }
    .rec-filt button { flex: none; min-height: 44px; padding: 8px 12px; }
    .rec-cal { margin-bottom: var(--space-4); box-shadow: 4px 4px 0 var(--c-accent); }
    .rec-cal__track { grid-auto-columns: 60px; }
    .rec-cal__m { min-height: 52px; padding: 6px 8px 7px; }
    .rec-cal__mm { font-size: 1.1rem; }
    .rec-hoard { gap: var(--space-5); }
    .rec-run { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
    .rec-run__month { position: static; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
    .rec-run__m { font-size: 2.6rem; }
    .rec-run__y { margin-top: 0; font-size: 1.3rem; }
    .rec-run__n { margin-top: 0; align-self: center; }
    .rec-wall { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; padding: 18px 12px 22px; background: var(--c-bg); }
    .rec-bill { transform: rotate(calc(var(--r) * 0.6)); }
    .rec-bill[data-stamp]::after { top: 10px; right: 4px; font-size: 0.56rem; padding: 2px 6px; }
    .rec-bill__paper::before { width: 48px; height: 13px; }
    .rec-bill--type .rec-bill__paper { padding: 12px; }
    .rec-bill__type { font-size: 1.08rem; -webkit-line-clamp: 6; }
    .rec-bill__cap { margin-top: 10px; }
    .rec-bill__t { font-size: 0.98rem; }
    .rec-bill__who { font-size: 0.74rem; -webkit-line-clamp: 2; }
    .rec-slips ul { flex-direction: column; }
    .rec-slip { width: 100%; }
    .rec-sheet {
        width: 100vw;
        max-height: 92dvh;
        margin: auto 0 0;
        border-width: 3px 0 0;
        box-shadow: none;
    }
    .rec-sheet__in { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); padding: var(--space-3); }
    .rec-sheet__img img { width: auto; max-width: 100%; max-height: 42dvh; }
}
@media (prefers-reduced-motion: reduce) {
    .rec.is-live .rec-run .rec-wall li { opacity: 1; transform: none; transition: none; }
    .rec-bill, .rec-bill__paper, .rec-cal__m, .rec-filt button, .rec-slip { transition: none; }
}
