/* Poetry By Heart: timeline pages (4+, 7+, 11+, 14+, 16+)
   Load after pbh.css. Breakpoints as pbh.css: tablet ≤1099px (designed at 810), mobile ≤699px (designed at 390). */

body.page-timeline, .page-timeline main { background: #fff; }

/* ==== BLOCK: timeline ==== */
/* age-group colours: the card's top (light) and lower (mid) panels */
/* --tl-light: the poet half; --tl-mid: the poem and year half; --tl-poem-ink: the poem and year text (Figma: navy on 4+, white on the others) */
.tl { --tl-light: #ade8fa; --tl-mid: #92d1e4; --tl-ink: var(--ink); --tl-poem-ink: var(--ink); }
.tl--7 { --tl-light: #f37f49; --tl-mid: #f06220; --tl-poem-ink: #fff; }   /* oranges */
.tl--11 { --tl-light: #52cb68; --tl-mid: #3dab52; --tl-poem-ink: #fff; }  /* greens */
.tl--14 { --tl-light: #c89f74; --tl-mid: #bd8c58; --tl-poem-ink: #fff; }  /* coffees */
.tl--16 { --tl-light: #db94ff; --tl-mid: #c552ff; --tl-poem-ink: #fff; }  /* lilacs */

.tl { --tl-edge: max(36px, calc((100% - 1228px) / 2)); min-height: calc(100svh - 206px); display: flex; flex-direction: column; justify-content: center; gap: 40px; padding: 80px 0 100px; background: #fff; overflow: hidden; }
.tl-head, .tl-filters { margin-inline: var(--tl-edge); }
.tl-scrub { margin-inline: 24px; } /* the slider runs the width of the window */
.tl [hidden] { display: none !important; }

/* title row: title, age switcher, filter toggle */
.tl-head { position: relative; z-index: 4; /* above the cards, below the site header (z-index 5) so its fly-out menus cover it */  display: flex; align-items: center; gap: 10px; }
.tl-title { font-weight: 800; font-size: 30px; line-height: 38px; letter-spacing: -0.04em; }
.tl-age { position: relative; }
.tl-age-btn { display: flex; align-items: center; gap: 4px; padding: 8px; border: 1px solid var(--neutral-300); border-radius: 4px; background: #fff; color: var(--ink); font: 800 22px/29px var(--font-sans); letter-spacing: -0.02em; cursor: pointer; }
.tl-age-btn svg { width: 24px; height: 25px; fill: var(--orange-600); transition: transform .2s; }
.tl-age-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.tl-age-btn:hover { border-color: var(--ink); }
.tl-ages { position: absolute; left: 0; top: calc(100% + 4px); z-index: 20; min-width: 100%; margin: 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid var(--neutral-300); border-radius: 4px; overflow: hidden; box-shadow: 0 6px 20px rgba(14,5,66,.12); }
.tl-ages a { display: block; padding: 8px 16px; white-space: nowrap; font-weight: 700; font-size: 14px; line-height: 21px; text-decoration: none; }
.tl-ages a:hover, .tl-ages a:focus-visible { background: var(--yellow-100); }
.tl-ages a[aria-current="page"] { color: var(--orange-600); }
.tl-filter-btn { margin-left: auto; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: none; color: var(--orange-600); cursor: pointer; }
.tl-filter-btn svg { width: 35px; height: 37px; fill: currentColor; }
.tl-filter-btn .tl-ic-close { width: 24px; height: 24px; }
.tl-filter-btn { position: relative; }
.tl-filter-btn svg { grid-area: 1 / 1; transition: opacity .25s, transform .3s cubic-bezier(.2,.7,.2,1); } /* the sliders and the X cross-fade with a quarter turn */
.tl-filter-btn .tl-ic-close, .tl-filter-btn[aria-expanded="true"] .tl-ic-open { opacity: 0; transform: rotate(-90deg); }
.tl-filter-btn[aria-expanded="true"] .tl-ic-close { opacity: 1; transform: none; }
.tl-filter-btn:hover { color: var(--orange-800); }

/* search and filters */
.tl-filters { display: flex; flex-direction: column; gap: 27px; margin-top: -13px; } /* 40 - 13 = 27 under the title row */
.tl-search { display: flex; gap: 16px; }
.tl-search-field { position: relative; flex: 1; }
.tl-search input { width: 100%; height: 45px; padding: 6px 40px 6px 14px; border: 1px solid #bebebe; border-radius: 4px; background: #fff; font: 400 14px/19px var(--font-sans); color: var(--ink); -webkit-appearance: none; appearance: none; }
.tl-search input::placeholder { color: #818181; }
.tl-search input::-webkit-search-cancel-button { display: none; }
.tl-search input:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.tl-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; padding: 7px; border: 0; background: none; color: var(--neutral-500); cursor: pointer; }
.tl-clear svg { width: 14px; height: 14px; fill: currentColor; display: block; }
.tl-clear:hover { color: var(--ink); }
.tl-go { flex: none; width: 45px; height: 45px; display: grid; place-items: center; border: 0; border-radius: 4px; background: var(--yellow-500); color: var(--ink); cursor: pointer; }
.tl-go svg { width: 27px; height: 27px; fill: currentColor; }
.tl-go:hover { background: var(--yellow-600); }
.tl-filters-h { font-weight: 700; font-size: 16px; line-height: 24px; color: #000; }
.tl-tags { display: flex; align-items: flex-start; gap: 24px; }
.tl-tagcol { margin: 0; padding: 0 0 0 24px; border: 0; border-left: 1px solid var(--neutral-200); min-width: 0; display: flex; gap: 16px; }
.tl-tagcol--minor { flex-direction: column; align-items: stretch; }
.tl-tagcol--themes { flex: 1; flex-wrap: wrap; }
.tl-tag { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid var(--ink); border-radius: 30px; font-size: 12px; line-height: 18px; color: var(--ink); cursor: pointer; white-space: nowrap; user-select: none; }
.tl-tag input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tl-tag span { display: inline-flex; align-items: center; gap: 4px; }
.tl-tag span::before { content: ""; flex: none; width: 14px; height: 14px; border: .875px solid var(--ink); border-radius: 50%; background: no-repeat center / 10px; }
.tl-tag:hover { background: var(--yellow-100); }
.tl-tag:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: 0 0 0 1px #172c1b; }
.tl-tag input:checked + span::before { border-color: var(--green-400); background-color: var(--green-400); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 5.2 4.1 7.3 8 3' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.tl-tag:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.tl-count, .tl-active-count { font-size: 14px; line-height: 21px; color: var(--neutral-500); }
.tl-active-count { margin: 0; white-space: nowrap; }

/* chosen filters, shown under the title while the panel is closed: labels (not buttons) and "Clear filters" */
.tl-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 26px; margin: -16px var(--tl-edge) 0; } /* 40 - 16 = 24 under the title */
.tl-active-list { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 0; list-style: none; }
.tl-active-tag { display: inline-flex; align-items: center; padding: 3px 8px; border: 1px solid var(--ink); border-radius: 30px; background: none; color: var(--ink); font-size: 12px; line-height: 18px; white-space: nowrap; }

/* the cards: one row that scrolls sideways, edge to edge */
.tl-track { position: relative; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; cursor: grab; outline: none; }
.tl-track::-webkit-scrollbar { display: none; }
.tl-track:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.tl-track.is-dragging { cursor: grabbing; user-select: none; }
.tl-track.is-dragging .tl-link { pointer-events: none; }
.tl-list { display: flex; gap: 10px; width: max-content; margin: 0; padding: 16px 24px 0; list-style: none; } /* 24px at each end, in line with the slider */ /* 16px above: room for the hover lift */
/* card sizes match the live timeline: 245 wide, 225 + 225 tall (a shorter lower half on short screens, below) */
.tl-card { flex: none; width: 245px; position: relative; top: 0; transition: top .12s ease-out; }
.tl-card:hover, .tl-card:focus-within { top: -15px; } /* lifts slightly, as on the live site */
.tl-card[hidden] { display: none; }
.tl-link { display: grid; grid-template-rows: 225px 1fr auto; height: 450px; color: var(--tl-ink); text-decoration: none; -webkit-user-drag: none; }
.tl-poet { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 10px; background: var(--tl-light); text-align: center; }
.tl-pic { width: 125px; height: 125px; flex: none; border-radius: 50%; object-fit: cover; -webkit-user-drag: none; pointer-events: none; }
.tl-pic--none { display: grid; place-items: center; background: var(--tl-mid); font-weight: 800; font-size: 40px; letter-spacing: -0.02em; color: var(--tl-ink); }
.tl-name { display: block; margin-bottom: -10px; font-weight: 700; font-size: 14px; line-height: 18px; text-transform: uppercase; }
.tl-dates { display: block; font-weight: 700; font-size: 14px; line-height: 18px; }
.tl-poem { color: var(--tl-poem-ink); display: grid; place-items: center; padding: 10px 30px; background: var(--tl-mid); text-align: center; font-weight: 500; font-size: 24px; line-height: 32px; letter-spacing: -0.04em; overflow: hidden; }
.tl-year { color: var(--tl-poem-ink); display: grid; place-items: center; padding: 7.5px 10px; background: var(--tl-mid); font-weight: 500; font-size: 24px; line-height: 32px; letter-spacing: -0.04em; }
@media (max-height: 840px) and (min-width: 700px) { /* short screens: a shorter lower half, as the live site */
  .tl-link { height: 375px; }
  .tl-poem, .tl-year { font-size: 18px; line-height: 24px; }
}
.tl-pic { transition: transform .3s cubic-bezier(.2,.7,.2,1); }
.tl-link:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.tl-empty { margin: 0 var(--tl-edge); padding: 120px 0; text-align: center; font-weight: 700; font-size: 16px; line-height: 24px; }

/* scrubber: arrows at the ends, a line with a handle that shows the year in view */
.tl-scrub { display: flex; align-items: flex-start; gap: 0; margin-top: -16px; } /* 40 - 16 = 24 under the cards */
.tl-step { flex: none; width: 24px; height: 24px; padding: 0; border: 0; background: none; color: var(--orange-600); cursor: pointer; }
.tl-step svg { width: 24px; height: 24px; fill: currentColor; display: block; }
.tl-step:disabled { opacity: .3; cursor: default; }
.tl-step:not(:disabled):hover { color: var(--orange-800); }
.tl-bar { position: relative; flex: 1; height: 60px; margin: 0 10px; cursor: pointer; touch-action: none; }
.tl-line { position: absolute; left: 0; right: 0; top: 12px; height: 1px; background: #9195ae; }
.tl-handle { position: absolute; top: 0; left: 0; width: 25px; height: 25px; margin-left: -12.5px; border-radius: 50%; background: #797979; box-shadow: 0 4px 4px rgba(0,0,0,.25); cursor: grab; touch-action: none; }
.tl-handle:active { cursor: grabbing; }
.tl-handle:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.tl-handle-year { position: absolute; top: 31px; left: 50%; transform: translateX(-50%); font-weight: 600; font-size: 16px; line-height: 24px; letter-spacing: -0.04em; color: var(--ink); white-space: nowrap; pointer-events: none; }
.tl.is-empty .tl-scrub { visibility: hidden; }

@media (prefers-reduced-motion: reduce) { .tl-pic, .tl-age-btn svg, .tl-card, .tl-filter-btn svg { transition: none; } }

/* ================= Tablet (810 design) ================= */
@media (max-width: 1099px) {
  .tl { --tl-edge: 24px; min-height: 0; padding: 60px 0 80px; }
  .tl-title { font-size: 26px; line-height: 33px; }
  .tl-age-btn { font-size: 20px; line-height: 26px; }
  .tl-tags { flex-wrap: wrap; row-gap: 24px; }
  .tl-tagcol--themes { flex-basis: 100%; }
}

/* ================= Mobile (390 design) ================= */
@media (max-width: 699px) {
  .tl { --tl-edge: 16px; padding: 40px 0 60px; gap: 32px; }
  .tl-head { flex-wrap: wrap; }
  .tl-title { font-size: 22px; line-height: 28px; }
  .tl-age-btn { padding: 6px 8px; font-size: 18px; line-height: 24px; }
  .tl-age-btn svg { width: 20px; height: 21px; }
  .tl-filters { margin-top: -8px; gap: 20px; }
  .tl-tags { gap: 16px; }
  .tl-tagcol { padding-left: 16px; }
  .tl-tagcol--minor { flex: 1; }
  /* phones: as the live site, the timeline runs down the page. Each card is a row: poet on the left, poem and year on the right */
  .tl-track { overflow: visible; cursor: auto; }
  .tl-list { flex-direction: column; align-items: center; gap: 10px; width: auto; padding: 0 16px; }
  .tl-card, .tl-card:hover, .tl-card:focus-within { top: 0; } /* no lift on touch */
  .tl-card { width: 100%; max-width: 490px; }
  .tl-link { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto; height: auto; min-height: 190px; }
  .tl-poet { grid-row: 1 / span 2; gap: 8px; padding: 16px 10px; }
  .tl-pic { width: 100px; height: 100px; }
  .tl-name, .tl-dates { font-size: 14px; line-height: 18px; }
  .tl-name { margin-bottom: -8px; }
  .tl-link { position: relative; }
  .tl-poem { grid-column: 2; grid-row: 1 / span 2; padding: 44px 10px; font-size: 21px; line-height: 24px; } /* centred in the card's full height; 44px top and bottom keeps clear of the year */
  .tl-year { position: absolute; right: 0; bottom: 0; width: 50%; padding: 10px; background: none; font-size: 21px; line-height: 24px; }
  .tl-scrub { display: none; }
  .tl-empty { padding: 60px 0; }
}
