/* Worksheets library.
   Uses home.css tokens only: no colour, curve or radius is invented here.
   Namespace: ws-. Loaded after home.css on /worksheets/ pages. */

/* ---------------------------------------------------------------- page ---- */
.ws-page { padding: clamp(86px, 8.5vh, 104px) 0 clamp(48px, 7vw, 96px); }

.ws-crumbs { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--ink-soft); margin-bottom: 18px; }
.ws-crumbs a { color: var(--brass-text); text-decoration: none; }
.ws-crumbs a:hover { text-decoration: underline; }
.ws-crumbs span[aria-current] { color: var(--ink); }
.ws-crumbs .ws-sep { opacity: 0.45; margin: 0 7px; }

/* The legacy stylesheet caps every bare h1 and h2 at a headline measure
   (h2 { max-width: 16.5ch }), which is right for prose and wrong for a row in a
   tree: it squeezed the topic triggers to 140px. Undo it where the heading is
   structure rather than a headline. */
.ws-topic-h, .ws-section > h2, .ws-locked-h, .ws-cta h2 { max-width: none; }

.ws-head { max-width: 760px; margin-bottom: clamp(26px, 4vw, 40px); }
.ws-head h1 { max-width: 20ch; }
.ws-head h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(34px, 5vw, 54px); line-height: 1.06; letter-spacing: -0.018em; color: var(--ink); margin: 10px 0 14px; text-wrap: balance; }
.ws-head h1 em { font-style: italic; color: var(--brass); }
.ws-lead { color: var(--ink-soft); font-size: clamp(15.5px, 1.5vw, 17.5px); line-height: 1.72; max-width: 58ch; }

.ws-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }
.ws-chip { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass-text); background: var(--ivory); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 5px 11px; }
.ws-chip-hl { color: var(--ivory); background: var(--navy); border-color: transparent; letter-spacing: 0.1em; }
.ws-chip-free { color: var(--brass-text); border-color: var(--brass-soft); }

/* ---------------------------------------------------------------- cards ---- */
.ws-section { margin-bottom: clamp(30px, 4.5vw, 52px); }
.ws-section > h2 { font-family: var(--mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass-text); padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ws-card { display: block; background: var(--ivory); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px 22px; text-decoration: none; color: inherit; transition: border-color 0.28s var(--ease-out), transform 0.28s var(--ease-out), box-shadow 0.28s var(--ease-out); }
.ws-card:hover { border-color: var(--brass-soft); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(14, 38, 56, 0.07); }
.ws-card:active { transform: translateY(0); }
.ws-card:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
/* Each part of a card is its own line. These are spans inside an anchor, so
   without an explicit display they run together: the description and the topic
   count printed as one inline string. */
.ws-card-title { font-family: var(--serif); font-size: 21px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.ws-card-desc { display: block; color: var(--ink-soft); font-size: 14.5px; line-height: 1.6; margin-top: 7px; }
.ws-card-meta { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brass-text); margin-top: 12px; }
.ws-arrow { width: 14px; height: 14px; flex: none; transition: transform 0.28s var(--ease-out); }
.ws-card:hover .ws-arrow { transform: translateX(3px); }

/* --------------------------------------------------------- level toggle ---- */
.ws-level { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.ws-level-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.ws-level-group { display: inline-flex; background: var(--ivory); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; }
.ws-level-btn { appearance: none; border: 0; background: transparent; font-family: var(--sans); font-weight: 600; font-size: 13px; color: var(--ink-soft); padding: 8px 18px; min-height: 44px; border-radius: var(--r-pill); cursor: pointer; transition: background-color 0.26s var(--ease-out), color 0.26s var(--ease-out); }
.ws-level-btn[aria-pressed="true"] { background: var(--navy); color: var(--ivory); }
.ws-level-btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.ws-level-note { font-size: 13px; color: var(--ink-soft); }

/* ----------------------------------------------------------------- tree ---- */
.ws-topics { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ws-topic { border-bottom: 1px solid var(--line); }
.ws-topic-h { margin: 0; font-size: inherit; font-weight: inherit; }

.ws-trigger {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px;
  appearance: none; background: transparent; border: 0; cursor: pointer; text-align: left;
  padding: 18px 4px; min-height: 44px; color: var(--ink);
  transition: background-color 0.24s var(--ease-out);
}
.ws-trigger:hover { background: rgba(251, 247, 239, 0.7); }
.ws-trigger:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; border-radius: var(--r-sm); }
.ws-num { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; color: var(--brass-text); }
.ws-name { font-family: var(--serif); font-size: clamp(18px, 2vw, 22px); line-height: 1.25; color: var(--ink); display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ws-count { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }
.ws-caret { width: 13px; height: 13px; color: var(--brass); transition: transform 0.34s var(--ease-out); }
.ws-topic.is-open .ws-caret { transform: rotate(180deg); }
.ws-topic.is-open .ws-name { color: var(--navy); }

/* The height animation: 0fr to 1fr animates to the content's true height with
   no JS measurement, and a 1fr track keeps tracking if the content reflows. */
.ws-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.38s var(--ease-out); }
.ws-topic.is-open > .ws-body { grid-template-rows: 1fr; }
.ws-body-inner { overflow: hidden; min-height: 0; }

.ws-subtopics { list-style: none; margin: 0; padding: 0 4px 14px 30px; }
.ws-subtopic { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.ws-subtopics > .ws-subtopic:first-child { border-top: 0; }
.ws-sub-name { font-size: 15.5px; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ws-files { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.ws-file { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 36px; border-radius: var(--r-pill); border: 1px solid transparent; white-space: nowrap; }
a.ws-file { min-height: 44px; text-decoration: none; color: var(--brass-text); background: var(--ivory); border-color: var(--brass-soft); transition: background-color 0.24s var(--ease-out), color 0.24s var(--ease-out), transform 0.16s var(--ease-out); }
a.ws-file:hover { background: var(--brass-text); color: var(--ivory); border-color: transparent; }
a.ws-file:active { transform: scale(0.97); }
a.ws-file:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.ws-soon { color: var(--ink-soft); background: transparent; border-color: var(--line); border-style: dashed; }
.ws-students { color: var(--brass-text); background: transparent; border-color: var(--line); }
.ws-lock { width: 11px; height: 11px; flex: none; }

/* --------------------------------------------------------- locked block ---- */
/* The card and the blurred list share one grid cell, so the block is always as
   tall as whichever is the taller of the two. Absolute centring was wrong: a
   subject with only three locked topics has a list shorter than the card, and
   on a short viewport (a phone held sideways) the card spilled out of its own
   block and over the free topics above it. */
.ws-locked { display: grid; grid-template-rows: auto 1fr; margin-top: clamp(30px, 4vw, 46px); }
.ws-locked-h { grid-row: 1; }
.ws-locked-list, .ws-locked-card { grid-row: 2; grid-column: 1; }
.ws-locked-h { font-family: var(--mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass-text); padding-bottom: 10px; border-bottom: 1px solid var(--line); margin: 0 0 4px; }
.ws-locked-list { list-style: none; margin: 0; padding: 0; filter: blur(4.5px); opacity: 0.68; pointer-events: none; user-select: none; -webkit-user-select: none; }
.ws-topic-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 18px 4px; border-bottom: 1px solid var(--line); }
.ws-topic-row .ws-name { font-size: clamp(18px, 2vw, 22px); }

.ws-locked-card {
  /* The list carries a blur, and a filtered element paints as its own stacking
     context, so without this the blurred names sat ON TOP of the card. */
  position: relative; z-index: 1;
  align-self: center; justify-self: center;
  width: min(100%, 560px); background: var(--ivory);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 18px 50px rgba(14, 38, 56, 0.16);
  padding: clamp(22px, 3vw, 32px); text-align: center;
}
.ws-locked-title { font-family: var(--serif); font-size: clamp(20px, 2.4vw, 26px); color: var(--ink); margin: 0 0 8px; }
.ws-locked-card p { color: var(--ink-soft); font-size: 15px; line-height: 1.65; margin: 0 auto 18px; max-width: 42ch; }
.ws-locked-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.ws-locked-alt { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.06em; color: var(--brass-text); text-decoration: none; padding: 10px 12px; min-height: 44px; display: inline-flex; align-items: center; border-radius: var(--r-pill); transition: background-color 0.24s var(--ease-out); }
.ws-locked-alt:hover { background: var(--ivory-edge); text-decoration: underline; }
.ws-locked-alt:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ------------------------------------------------------- siblings + CTA ---- */
.ws-siblings { margin-top: clamp(30px, 4vw, 48px); font-size: 14.5px; color: var(--ink-soft); }
.ws-siblings a { color: var(--brass-text); text-decoration: none; }
.ws-siblings a:hover { text-decoration: underline; }

.ws-cta { margin-top: clamp(34px, 5vw, 64px); background: linear-gradient(180deg, var(--navy), var(--navy-deep)); border-radius: var(--r-lg); padding: clamp(28px, 4vw, 46px); color: var(--ivory); text-align: center; }
.ws-cta h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(24px, 3vw, 34px); margin: 0 0 10px; color: var(--ivory); }
.ws-cta p { color: rgba(248, 244, 236, 0.78); max-width: 48ch; margin: 0 auto 20px; line-height: 1.68; }

/* The site's primary button is a navy fill, which vanishes on a navy band. The
   brand's rule for this case is a brass fill with navy text, so say so here
   rather than leaving a button the eye has to hunt for. */
.ws-cta .button.primary {
  background: var(--brass-on-navy);
  color: var(--navy-deep);
  border-color: var(--brass-on-navy);
  box-shadow: 0 16px 40px -22px rgba(0, 0, 0, 0.7);
}
.ws-cta .button.primary:hover { background: var(--brass-soft); border-color: var(--brass-soft); }

/* Its own line: a secondary link sitting on the button's baseline reads as a
   second button and pulls the eye off the thing we actually want clicked. */
.ws-back { display: block; margin-top: 20px; font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brass-on-navy); text-decoration: none; }
.ws-back:hover { text-decoration: underline; }
.ws-back:focus-visible { outline: 2px solid var(--brass-on-navy); outline-offset: 3px; }

/* ------------------------------------------------------------- SL filter ---- */
/* Presentation only. Every row stays in the document for crawlers and for the
   student who switches back; the server never trusts this view.
   Scoped to the tree deliberately: the HL button itself carries
   data-level="hl", so an unscoped rule hid the one control that turns HL back
   on, and the choice persists in localStorage, so the student stayed stuck on
   every IB page and across reloads. */
.ws-sl-view .ws-tree [data-level="hl"] { display: none; }

/* ------------------------------------------------------------- responsive ---- */
/* A subtopic row is a name plus two pills. Below about 900px the pills take
   more width than the name and the name starts wrapping mid-row, so the row
   stacks here rather than waiting for the phone breakpoint. Measured at 768px,
   where a side by side row ran to 104px tall; raised to 1024 because the long
   names (Edexcel IAL, OxfordAQA biology) still wrapped up to about 1015px. */
@media (max-width: 1024px) {
  .ws-subtopic { flex-direction: column; align-items: flex-start; gap: 10px; }
  .ws-files { justify-content: flex-start; }
}

@media (max-width: 720px) {
  .ws-trigger { grid-template-columns: auto 1fr auto; row-gap: 4px; padding: 16px 2px; }
  .ws-count { display: none; }
  .ws-subtopics { padding-left: 16px; }
  .ws-subtopic { flex-direction: column; align-items: flex-start; gap: 10px; }
  .ws-files { justify-content: flex-start; }
  .ws-file { min-height: 44px; padding: 10px 14px; }
  .ws-locked-card { width: 100%; }
  .ws-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .ws-body, .ws-caret, .ws-card, .ws-file, .ws-trigger, .ws-level-btn { transition: none !important; }
  .ws-card:hover { transform: none; }
}

/* The worksheet opens in the browser; the PDF copy is the smaller, quieter
   second action beside it. */
.ws-file.ws-dl { margin-left: 8px; font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brass-text, #7d5314); border-bottom: 1px solid rgba(125,83,20,.35); }
.ws-file.ws-dl:hover { color: var(--ink, #14130f); border-bottom-color: currentColor; }
