/* =========================================================
   Exam updates and study materials (homepage, /updates, /materials
   and each post). Colours, type and buttons come from styles.css.
   ========================================================= */

/* A post holds both languages: show the one the visitor has chosen */
:root[lang="ta"] [data-l10n="en"], :root:not([lang="ta"]) [data-l10n="ta"] { display: none; }

.btn-soft { background: var(--bg-soft); color: var(--fg); }
.btn-soft:hover { background: var(--line); }

/* ---------- Page frame ---------- */
.page { min-height: 70vh; padding: 148px 0 112px; }
.page-head { max-width: 44rem; margin-bottom: 40px; }
.page-head h1, .page-message h1, .post h1 { font-size: clamp(2.1rem, 1.4rem + 2.8vw, 3.6rem); letter-spacing: var(--track-tight); text-wrap: balance; }
.page-head p { margin: 16px 0 0; color: var(--muted); font-size: 1.15rem; }
.page-message { display: grid; justify-items: start; gap: 18px; }
.page-message p { margin: 0; color: var(--muted); font-size: 1.1rem; }
:root[lang="ta"] .page-head h1, :root[lang="ta"] .page-message h1, :root[lang="ta"] .post h1, .post h1 [lang="ta"], .post h1 > span[lang="ta"] { line-height: 1.3; }
:root[lang="ta"] .page-head h1, :root[lang="ta"] .page-message h1, :root[lang="ta"] .post h1 { font-size: clamp(1.75rem, 1.3rem + 1.9vw, 2.8rem); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border: 0; border-radius: var(--r-pill); background: var(--bg-soft); color: var(--fg-2);
  font: 500 .95rem/1.2 var(--body); text-align: left; text-decoration: none; cursor: pointer; transition: background-color .2s, color .2s;
}
.chip span { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.chip:hover { background: var(--line); }
.chip[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-fg); }
.chip[aria-pressed="true"] span { color: inherit; }
.lib-state { display: grid; justify-items: start; gap: 16px; padding: 24px 0; }
.lib-state p { margin: 0; color: var(--muted); font-size: 1.1rem; }

/* ---------- Tear-off calendar page: the last date to apply ---------- */
.calendar {
  flex: none; display: grid; grid-template-rows: auto 1fr; width: 84px; height: 94px; overflow: hidden;
  border-radius: 10px; background: #FFFFFF; color: #101632; text-align: center;
  box-shadow: 0 0 0 1px rgba(16,22,50,.14), 0 3px 0 1px #FFFFFF, 0 3px 0 2px rgba(16,22,50,.16); /* the pages underneath */
}
.calendar > span { display: block; padding: 5px 4px; background: var(--red); color: #FFFFFF; font-weight: 600; font-size: .92rem; line-height: 1.3; }
.calendar b { align-self: center; font: 800 2.5rem/1 "Bricolage Grotesque", sans-serif; letter-spacing: -.03em; }
.calendar.is-closed > span { background: #6A718A; }
.calendar.is-closed b { color: #6A718A; }
.calendar-plain { display: grid; grid-template-rows: none; place-items: center; background: var(--bg-soft); color: var(--muted); box-shadow: none; }
.calendar-plain svg { width: 34px; height: 34px; stroke-width: 1.8; }

.post-status { margin: 0; font-weight: 700; }
.post-status.is-urgent { color: var(--red-text); }
.post-status.is-open { color: var(--soon-fg); }
.post-status.is-upcoming { color: var(--fg); }
.post-status.is-closed { color: var(--muted); font-weight: 500; }

/* ---------- List of updates ---------- */
.updates { padding: 104px 0 24px; }
.updates[hidden] { display: none; }
.updates .sec-head { margin-bottom: 36px; }
.notices { border-top: 1px solid var(--line); }
.notices:empty { border: 0; }
#updates-filter { margin-bottom: 28px; }
.notice { position: relative; display: grid; grid-template-columns: 84px minmax(0, 1fr) minmax(150px, auto); gap: 8px 28px; align-items: center; padding: 26px 0; border-bottom: 1px solid var(--line); }
.notice h2, .notice h3 { font-size: clamp(1.25rem, 1.1rem + .6vw, 1.6rem); font-weight: 700; letter-spacing: var(--track); line-height: 1.25; overflow-wrap: anywhere; }
.notice a, .material a { text-decoration: none; }
.notice a::after, .material a::after { content: ""; position: absolute; inset: 0; border-radius: 12px; } /* the whole row opens it */
.notice:hover a, .material:hover a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.notice a:focus-visible, .material a:focus-visible { outline: none; }
.notice a:focus-visible::after, .material a:focus-visible::after { outline: 3px solid var(--gold); outline-offset: -2px; }
.notice-summary { max-width: 44rem; margin: 6px 0 0; color: var(--fg-2); overflow-wrap: anywhere; }
.notice-meta { display: flex; flex-wrap: wrap; gap: 2px 18px; margin: 8px 0 0; color: var(--muted); font-size: .95rem; }
.notice-course { color: var(--fg); font-weight: 600; }
.notice .post-status { text-align: right; }

/* ---------- One update ---------- */
.post { max-width: 46rem; margin: 0 auto; }
.post-back { display: inline-block; padding: 8px 0; }
.post-course { margin: 28px 0 8px; color: var(--red-text); font-weight: 700; }
.post h1 { overflow-wrap: anywhere; }
.post h1 [lang="en"] { font-family: inherit; } /* keep the heading font */
.post-back + h1 { margin-top: 28px; }
.post-date { margin: 14px 0 0; color: var(--muted); }
.post-summary { margin: 24px 0 0; font-size: 1.25rem; line-height: 1.55; color: var(--fg-2); overflow-wrap: anywhere; }
.post-photo { width: 100%; max-height: 460px; margin-top: 32px; border-radius: var(--r-lg); object-fit: cover; filter: var(--img-filter); }
.post-key { display: flex; gap: 32px; align-items: flex-start; margin: 36px 0 0; padding: 32px; border-radius: var(--r-lg); background: var(--bg-soft); }
.post-key .calendar { width: 112px; height: 126px; }
.post-key .calendar > span { font-size: 1.1rem; }
.post-key .calendar b { font-size: 3.5rem; }
.post-key-text { display: grid; flex: 1; gap: 18px; justify-items: start; min-width: 0; }
.post-key .post-status { font-size: 1.15rem; }
.post-facts { display: grid; gap: 10px; width: 100%; margin: 0; }
.post-facts div { display: grid; grid-template-columns: minmax(0, 190px) minmax(0, 1fr); gap: 4px 16px; }
.post-facts dt { color: var(--muted); }
.post-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.post-body { margin-top: 36px; font-size: 1.12rem; line-height: 1.75; overflow-wrap: anywhere; }
.post-body > * { margin: 0 0 1.1em; }
.post-body h2 { margin-top: 1.5em; font-size: 1.6rem; letter-spacing: var(--track); line-height: 1.25; }
.post-body ul, .post-body ol { padding-left: 1.4em; }
.post-body ul { list-style: disc; }
.post-body ol { list-style: decimal; }
.post-body li { margin-bottom: .4em; padding-left: .2em; }
.post-body li::marker { color: var(--red-text); font-weight: 700; }
.post-body a { color: var(--red-text); text-underline-offset: 3px; }
.post-note { margin: 32px 0 0; padding-left: 18px; border-left: 4px solid var(--gold); color: var(--fg-2); }
.post-share, .post-help-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.post-share { margin-top: 28px; }
.post-help { margin-top: 56px; padding: 36px; border-radius: var(--r-lg); background: var(--panel); color: #FFFFFF; }
.post-help h2 { color: #FFFFFF; font-size: 1.7rem; letter-spacing: var(--track); }
.post-help p { margin: 10px 0 22px; color: rgba(255,255,255,.82); }
.post-help [hidden] { display: none; }

/* ---------- Study materials ---------- */
.lib-tools { display: grid; gap: 18px; margin-bottom: 16px; }
.lib-tools[hidden], .chips[hidden], .lib-state[hidden] { display: none; }
.lib-search { position: relative; max-width: 460px; color: var(--muted); }
.lib-search svg { position: absolute; top: 15px; left: 18px; width: 20px; height: 20px; pointer-events: none; }
.lib-search input { width: 100%; min-height: 50px; padding: 10px 18px 10px 50px; border: 1px solid #878EA6; border-radius: var(--r-pill); background: var(--card); color: var(--fg); font: 400 1rem/1.3 var(--body); }
.lib-search input::placeholder { color: var(--muted); opacity: 1; }
.lib-search input:focus-visible { border-radius: var(--r-pill); outline-offset: 1px; }
.material-group { margin-top: 48px; }
.material-group h2 { margin-bottom: 14px; font-size: clamp(1.5rem, 1.3rem + .8vw, 2rem); letter-spacing: var(--track); }
.materials { border-top: 1px solid var(--line); }
.material { position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 4px 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.material-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--bg-soft); color: var(--red-text); }
.material-icon svg { width: 24px; height: 24px; stroke-width: 1.8; }
.material h3 { overflow-wrap: anywhere; }
.material-text p { max-width: 44rem; margin: 3px 0 0; color: var(--muted); font-size: .98rem; overflow-wrap: anywhere; }
.material-action { color: var(--fg-2); font-weight: 600; font-size: .95rem; font-variant-numeric: tabular-nums; }

/* On the homepage: a link on each course card, and a panel below the courses */
.c-materials { align-self: flex-start; margin-top: 6px; padding: 8px 0 2px; color: var(--red-text); font-weight: 600; font-size: .95rem; text-underline-offset: 4px; }
.course-feature .c-materials { color: var(--gold); }
.materials-band { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: center; margin-top: 40px; padding: 40px; border-radius: var(--r-lg); background: var(--panel); color: #FFFFFF; scroll-margin-top: 110px; }
.materials-band[hidden] { display: none; }
.materials-band h3 { color: #FFFFFF; font-size: clamp(1.5rem, 1.3rem + .9vw, 2.1rem); font-weight: 700; letter-spacing: var(--track); }
.materials-band p { margin: 8px 0 0; color: rgba(255,255,255,.82); }
.materials-band .chips { grid-column: 1 / -1; grid-row: 2; }
.materials-band .chip { background: rgba(255,255,255,.12); color: #FFFFFF; }
.materials-band .chip:hover { background: rgba(255,255,255,.22); }
.materials-band .chip span { color: var(--gold); font-weight: 700; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .page { padding: 116px 0 80px; }
  .page-head { margin-bottom: 28px; }
  /* Filters: one row to swipe, edge to edge, so the list stays near the top */
  .lib .chips { flex-wrap: nowrap; margin-inline: calc(var(--gutter) * -1); padding: 4px var(--gutter); overflow-x: auto; scrollbar-width: none; }
  .lib .chips::-webkit-scrollbar { display: none; }
  .lib .chip { flex: none; }
  .updates { padding: 72px 0 8px; }
  .notice { grid-template-columns: 68px minmax(0, 1fr); gap: 10px 18px; align-items: start; padding: 22px 0; }
  .notice .calendar { width: 68px; height: 80px; grid-row: span 2; }
  .notice .calendar b { font-size: 2rem; }
  .notice .post-status { grid-column: 2; text-align: left; }
  .post-key { gap: 20px; padding: 22px 20px; }
  .post-key .calendar { width: 84px; height: 96px; }
  .post-key .calendar > span { font-size: .95rem; }
  .post-key .calendar b { font-size: 2.6rem; }
  .post-facts div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .post-summary { font-size: 1.15rem; }
  .post-help, .materials-band { padding: 28px 22px; }
  .materials-band { grid-template-columns: minmax(0, 1fr); }
  .materials-band .chips { grid-row: auto; }
  .materials-band .btn { justify-self: start; }
  .material { grid-template-columns: 48px minmax(0, 1fr); align-items: start; }
  .material-action { grid-column: 2; }
}
@media (max-width: 420px) {
  .post-key { flex-direction: column; }
}
