/* ================================================================
   TNCC history page (history.html only). Builds on the timeline in
   styles.css (.tl-index, .timeline, .tl-item, .tl-mile) and adds the
   president details, the stalwarts, the stamps and the biography dialog.
   ================================================================ */

/* .container has no gutter of its own, so each band brings var(--px) */
.hist .pagehero, .hist .tl-index, .hist .timeline-wrap { padding-left: var(--px); padding-right: var(--px); }
.hist .tl-index__row a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Timeline: portraits, badges, facts ---- */
/* The site's portraits are 3:4 except a few (one square, two small scans);
   crop them all to one frame so the spine reads evenly. */
.hist .tl-item__img--pres { aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 18%; max-width: 200px; }
/* the date node holds a two-line term ("1940–" / "1952"), not a day and month */
.hist .tl-item__date { font-size: 11.5px; letter-spacing: 0; }
.hist .tl-item__medal { width: 96px; height: 96px; }

.hist-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.hist-badges + .tl-item__h { margin-top: 10px; }
.hist-badge {
  display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .03em; line-height: 1.55;
}
.hist-badge--returned { background: rgba(11, 79, 158, .1); color: var(--blue); }
.hist-badge--incumbent { background: var(--green); color: #fff; }
[data-lang="ta"] .hist-badge { letter-spacing: 0; }

.hist .tl-item__sub { line-height: 1.5; }
.hist-note { margin: 6px 0 0; font-size: 13px; font-weight: 600; font-style: italic; color: var(--muted); }

.hist-facts { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.hist-facts li {
  max-width: 100%; padding: 5px 10px; border-radius: 8px;
  background: #fff; border: 1px solid rgba(20, 24, 28, .1);
  font-size: 12.5px; font-weight: 600; line-height: 1.45; color: var(--body); text-align: left;
}
.tl-item:not(.tl-item--r) .hist-badges,
.tl-item:not(.tl-item--r) .hist-facts { justify-content: flex-end; }

.hist-bio-btn {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
  padding: 8px 17px; border-radius: 999px; border: 1.5px solid var(--blue);
  background: transparent; color: var(--blue); font-size: 13px; font-weight: 800; line-height: 1.3;
  cursor: pointer; transition: background .2s, color .2s;
}
.hist-bio-btn:hover { background: var(--blue); color: #fff; }
.hist-bio-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

/* ---- Stalwarts and stamps bands ---- */
.hist-sec { padding: 90px var(--px); border-top: 1px solid rgba(20, 24, 28, .07); }
.hist-sec--stalwarts { background: #fff; }
.hist-sec__title {
  margin: 12px 0 0; max-width: 820px; font-weight: 800;
  font-size: clamp(28px, 3.6vw, 46px); line-height: 1.1; letter-spacing: -.5px;
}
[data-lang="ta"] .hist-sec__title { line-height: 1.3; letter-spacing: 0; }

.hist-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 20px; margin-top: 34px;
}
.hist-card {
  display: flex; flex-direction: column; align-items: flex-start;
  background: var(--bg); border-radius: 18px; padding: 24px 24px 22px;
  border-top: 4px solid var(--green); box-shadow: 0 12px 30px rgba(20, 24, 28, .08);
}
.hist-card__medal {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(140deg, #0E7B3D, #06522A); color: #fff;
  font-weight: 800; font-size: 19px; box-shadow: 0 8px 20px rgba(20, 24, 28, .16);
}
[data-lang="ta"] .hist-card__medal { font-size: 16px; }
.hist-card__h { margin: 16px 0 4px; font-weight: 800; font-size: 20px; line-height: 1.25; }
.hist-card__sub { font-size: 13px; font-weight: 700; line-height: 1.5; color: var(--blue2); }
.hist-card__text { margin: 10px 0 0; font-size: 14.5px; line-height: 1.65; color: var(--body); }
.hist-card .hist-facts { margin-bottom: 18px; }
.hist-card .hist-bio-btn { margin-top: auto; }

.hist-stamps {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px; margin-top: 34px; align-items: start;
}
.hist-stamp { margin: 0; text-align: center; }
.hist-stamp__frame {
  display: grid; place-items: center; padding: 20px;
  background: #fff; border-radius: 16px; box-shadow: 0 12px 30px rgba(20, 24, 28, .08);
}
.hist-stamp__frame img {
  display: block; width: 100%; height: clamp(150px, 17vw, 230px); object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(20, 24, 28, .18));
}
.hist-stamp figcaption { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.hist-stamp__who { font-weight: 800; font-size: 15px; line-height: 1.4; }
.hist-stamp__when { font-size: 13px; font-weight: 600; color: var(--muted); }
.hist-stamps__credit { margin: 26px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.hist-stamps__credit a { text-decoration: underline; text-underline-offset: 3px; }
.hist-stamps__credit a:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 3px; }

/* ---- Full-biography dialog (built by js/history-bios.js) ---- */
body.bio-open { overflow: hidden; }
.bio {
  width: min(780px, calc(100vw - 32px)); max-width: none;
  max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: 18px; overflow: hidden;
  background: #fff; color: var(--ink); box-shadow: 0 30px 80px rgba(20, 24, 28, .35);
}
.bio[open] { display: flex; flex-direction: column; animation: bioIn .28s cubic-bezier(.2, .7, .2, 1) both; }
.bio::before {
  content: ''; flex: none; height: 5px;
  background: linear-gradient(90deg, var(--saffron) 0 33.4%, #F2ECDF 33.4% 66.7%, var(--green) 66.7% 100%);
}
.bio::backdrop { background: rgba(20, 24, 28, .62); }
@keyframes bioIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.bio__close {
  position: absolute; top: 16px; right: 18px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--bg); color: var(--ink); font-size: 24px; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 12px rgba(20, 24, 28, .12); transition: background .2s, color .2s;
}
.bio__close:hover { background: var(--ink); color: #fff; }
.bio__close:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.bio__sheet { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 28px 34px 36px; }
.bio__head { display: flex; gap: 20px; align-items: center; padding-right: 44px; }
.bio__pic { flex: none; }
.bio__pic img {
  display: block; width: 96px; height: 96px; border-radius: 50%;
  object-fit: cover; object-position: 50% 18%; box-shadow: 0 8px 20px rgba(20, 24, 28, .16);
}
.bio__medal {
  display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%;
  background: linear-gradient(140deg, #0E7B3D, #06522A); color: #fff; font-weight: 800; font-size: 26px;
}
[data-lang="ta"] .bio__medal { font-size: 21px; }
.bio__who { min-width: 0; }
.bio__name { margin: 0; font-weight: 800; font-size: clamp(22px, 3vw, 28px); line-height: 1.2; }
[data-lang="ta"] .bio__name { line-height: 1.35; }
.bio__other { margin: 4px 0 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.bio__role { margin: 8px 0 0; font-size: 13.5px; font-weight: 700; line-height: 1.5; color: var(--blue2); }
.bio__terms { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: var(--body); }
.bio__other:empty, .bio__role:empty, .bio__terms:empty { display: none; }

.bio__body { margin-top: 22px; border-top: 1px solid rgba(20, 24, 28, .1); padding-top: 6px; }
.bio__note {
  margin: 16px 0 0; padding: 10px 14px; border-radius: 10px; border-left: 4px solid var(--saffron);
  background: rgba(246, 178, 107, .16); font-size: 13.5px; font-weight: 700; color: var(--ink);
}
.bio__status { margin: 18px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.bio__facts {
  display: grid; grid-template-columns: max-content 1fr; gap: 0 18px; margin: 16px 0 6px;
  padding: 14px 18px; border-radius: 12px; background: var(--bg); font-size: 14px; line-height: 1.55;
}
.bio__fact { display: contents; }
.bio__facts dt { font-weight: 800; color: var(--ink); padding: 4px 0; }
.bio__facts dd { margin: 0; color: var(--body); padding: 4px 0; }
.bio__h { margin: 24px 0 6px; font-weight: 800; font-size: 18px; line-height: 1.35; }
.bio__p { margin: 10px 0 0; font-size: 15px; line-height: 1.75; color: var(--body); overflow-wrap: break-word; }
.bio__lang[lang="ta"] .bio__p { font-size: 15.5px; line-height: 1.85; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .hist-stamps { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 640px; }
  .hist-sec { padding-top: 76px; padding-bottom: 76px; }
}
@media (max-width: 760px) {
  .tl-item:not(.tl-item--r) .hist-badges,
  .tl-item:not(.tl-item--r) .hist-facts { justify-content: flex-start; }
  .hist .tl-item__img--pres { max-width: 180px; }
  .hist .tl-item__medal { width: 80px; height: 80px; }
  .hist-sec { padding-top: 60px; padding-bottom: 60px; }
  .hist-stamps { gap: 14px; }
  .hist-stamp__frame { padding: 12px; }
  .bio__sheet { padding: 24px 22px 30px; }
  .bio__head { gap: 14px; }
  .bio__pic img, .bio__medal { width: 76px; height: 76px; }
}
@media (max-width: 420px) {
  .bio { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 14px; }
  .bio__sheet { padding: 22px 16px 26px; }
  .bio__head { flex-direction: column; align-items: flex-start; padding-right: 48px; }
  .bio__facts { grid-template-columns: 1fr; padding: 12px 14px; }
  .bio__facts dd { padding-top: 0; }
  .hist-card { padding: 20px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .bio[open] { animation: none; }
  .hist-bio-btn, .bio__close { transition: none; }
}
