/* ==========================================================================
   The History of Clothing
   Museum-editorial stylesheet. Serif text, grotesque labels, hairline rules.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */

:root {
  /* Color. Warm-white ground and near-black ink so photography reads true.
     The accent is for links; it is never decorative. */
  --paper:     #fdfcfa;
  --paper-alt: #f6f4f0;
  --ink:       #1a1a1a;
  --ink-soft:  #5a5a58;
  --rule:      #e2ded6;
  --accent:    #7c2d12;

  /* Type */
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans:  "Archivo", "Helvetica Neue", Arial, sans-serif;

  --fs-label: 0.75rem;
  --fs-meta:  0.8125rem;
  --fs-small: 0.9375rem;
  --fs-base:  1.0625rem;
  --fs-lead:  1.1875rem;
  --fs-h3:    1.3125rem;
  --fs-h2:    1.625rem;
  --fs-h1:    clamp(2rem, 1.4rem + 2.4vw, 2.75rem);
  --fs-display: clamp(2.25rem, 1.2rem + 4vw, 3.5rem);

  /* Space */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* Structure */
  --measure:   68ch;
  --container: 1120px;
  --radius:    2px;
}

/* --- Reset ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs-base);
  line-height: 1.65;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }

table { border-collapse: collapse; }

input { font: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Utilities ------------------------------------------------------------ */

/* Load-bearing: the glossary search and timeline filter toggle .hidden. */
.hidden { display: none !important; }

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Small letterspaced grotesque caps. The site's one structural label. */
.label {
  font-family: var(--sans);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* --- Shell ---------------------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.masthead__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-6);
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--sans);
  font-size: var(--fs-meta);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.wordmark:hover { color: var(--accent); }

.site-nav {
  display: flex;
  gap: var(--sp-6);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.site-nav a { color: var(--ink-soft); }
.site-nav a:hover { color: var(--accent); }

main {
  flex: 1;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--sp-12) var(--sp-6) var(--sp-16);
}

.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: var(--sp-16);
}

.site-footer__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

/* --- Page headers --------------------------------------------------------- */

.page-head {
  max-width: var(--measure);
  margin-bottom: var(--sp-12);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--rule);
}

.page-head h1 {
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -0.015em;
}

.page-head__standfirst {
  margin-top: var(--sp-3);
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Homepage masthead: the site's largest type, set left. */
.hero {
  max-width: 32ch;
  margin-bottom: var(--sp-6);
}

.hero h1 {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.022em;
}

.hero__standfirst {
  max-width: 52ch;
  margin-top: var(--sp-4);
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--ink-soft);
}

.hero__meta {
  max-width: none;
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--rule);
}

/* --- Section headings ----------------------------------------------------- */

.section {
  margin-top: var(--sp-16);
}

.section__head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--rule);
}

.section__head h2 {
  font-family: var(--sans);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

.section__note {
  font-size: var(--fs-meta);
  color: var(--ink-soft);
  font-style: italic;
}

/* --- Article rows (replaces lift-on-hover cards) -------------------------- */

.rows { border-top: 1px solid var(--rule); }

.row {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: var(--sp-5);
  align-items: start;
  padding: var(--sp-5) 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}

.row__figure {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--paper-alt);
  aspect-ratio: 4 / 3;
}

.row__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row__title {
  display: block;
  font-size: var(--fs-h3);
  font-weight: 600;
}

.row:hover .row__title {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.row__summary {
  display: block;
  margin-top: var(--sp-2);
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--ink-soft);
}

.row__meta {
  display: block;
  margin-top: var(--sp-2);
}

/* Rows without a figure collapse to a single column. */
.rows--plain .row { grid-template-columns: 1fr; }

/* --- The matrix ----------------------------------------------------------- */

.matrix-wrap { overflow-x: auto; }

.matrix {
  width: 100%;
  font-size: var(--fs-small);
}

.matrix th,
.matrix td {
  border-bottom: 1px solid var(--rule);
  padding: var(--sp-3) var(--sp-3);
  text-align: left;
  vertical-align: baseline;
}

.matrix thead th {
  border-bottom: 1px solid var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}

.matrix thead th a { color: inherit; }
.matrix thead th a:hover { color: var(--accent); }

.matrix tbody th {
  white-space: nowrap;
  padding-right: var(--sp-6);
}

.matrix__era {
  font-weight: 600;
  font-size: var(--fs-base);
}

.matrix tbody th a { color: var(--ink); }
.matrix tbody th a:hover { color: var(--accent); }

.matrix__period {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-meta);
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
}

.matrix td a { color: var(--ink-soft); }

.matrix td a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.matrix td .empty { color: var(--rule); }

/* --- Stacked index (mobile matrix, region/era index pages) ---------------- */

.stack { margin: 0; }

.stack__group + .stack__group { margin-top: var(--sp-12); }

.stack__head {
  padding-bottom: var(--sp-3);
  margin-bottom: 0;
  border-bottom: 1px solid var(--ink);
}

.stack__head h2,
.stack__head h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
}

.stack__period {
  margin-top: var(--sp-1);
  font-size: var(--fs-meta);
  font-style: italic;
  color: var(--ink-soft);
}

.stack__item {
  display: block;
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}

.stack__item-title {
  display: block;
  font-size: var(--fs-base);
  font-weight: 600;
}

.stack__item:hover .stack__item-title {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.stack__item-summary {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--ink-soft);
}

.stack__item--empty {
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
}

.stack__item--empty .stack__item-title { font-weight: 400; color: var(--ink-soft); }
.stack__item--empty em { font-size: var(--fs-small); }

/* --- Article -------------------------------------------------------------- */

.article { max-width: var(--measure); }

.breadcrumb {
  margin-bottom: var(--sp-6);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  color: var(--ink-soft);
}

.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 var(--sp-2); color: var(--rule); }

.article__head {
  margin-bottom: var(--sp-10);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--ink);
}

.article__kicker { margin-bottom: var(--sp-3); }

.article__head h1 {
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -0.015em;
}

.article__summary {
  margin-top: var(--sp-4);
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--ink-soft);
}

.article__dateline {
  margin-top: var(--sp-5);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  color: var(--ink-soft);
}

/* .article-content is load-bearing: .eleventy.js finds this exact class
   string and counts <div> nesting to inject glossary cross-links.
   Do not rename it or nest extra divs inside it. */
.article-content {
  font-size: var(--fs-lead);
  line-height: 1.7;
}

.article-content > * + * { margin-top: var(--sp-5); }

.article-content h2 {
  margin-top: var(--sp-12);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--rule);
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.article-content h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.article-content h3 {
  margin-top: var(--sp-8);
  font-size: var(--fs-h3);
  font-weight: 600;
}

.article-content strong { font-weight: 600; }

.article-content a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--rule);
}

.article-content a:hover { text-decoration-color: var(--accent); }

.article-content ul { padding-left: var(--sp-5); }
.article-content li + li { margin-top: var(--sp-2); }

.article-content img {
  width: 100%;
  border-radius: var(--radius);
  cursor: zoom-in;
}

/* Markdown wraps a standalone image in its own paragraph and renders the
   italic line beneath it as the next paragraph. Match that exact pair so
   ordinary italic asides are not restyled as captions. Browsers without
   :has() simply show captions as italic body text, which still reads fine. */
.article-content p:has(> img:only-child) { margin-top: var(--sp-8); }

.article-content p:has(> img:only-child) + p:has(> em:only-child) {
  margin-top: var(--sp-2);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  line-height: 1.5;
  color: var(--ink-soft);
}

.article-content p:has(> img:only-child) + p:has(> em:only-child) em {
  font-style: normal;
}

/* --- Related ------------------------------------------------------------- */

.related {
  max-width: var(--measure);
  margin-top: var(--sp-16);
  padding-top: var(--sp-8);
  border-top: 1px solid var(--ink);
}

.related__group + .related__group { margin-top: var(--sp-10); }

.related__group > h2 {
  font-family: var(--sans);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: var(--sp-4);
}

/* --- Timeline ------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  align-items: baseline;
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-10);
  border-bottom: 1px solid var(--rule);
}

.filters__label { margin-right: var(--sp-1); }

.region-pill {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0 0 2px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.region-pill:hover { color: var(--accent); }

.region-pill.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.timeline__era + .timeline__era { margin-top: var(--sp-12); }

.timeline__era-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--ink);
}

.timeline__era-head h2 {
  font-size: var(--fs-h3);
  font-weight: 600;
}

.timeline__era-period {
  font-size: var(--fs-meta);
  font-style: italic;
  color: var(--ink-soft);
}

.timeline-card {
  display: block;
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}

.timeline-card__region {
  display: block;
  font-size: var(--fs-base);
  font-weight: 600;
}

.timeline-card:hover .timeline-card__region {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.timeline-card__summary {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--ink-soft);
}

/* --- Glossary ------------------------------------------------------------- */

.glossary { max-width: var(--measure); }

.glossary__search {
  width: 100%;
  padding: var(--sp-3) 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  font-size: var(--fs-lead);
  color: var(--ink);
}

.glossary__search::placeholder { color: var(--ink-soft); }
.glossary__search:focus { outline: 0; border-bottom-color: var(--accent); }

.alpha-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
  margin-bottom: var(--sp-8);
  border-bottom: 1px solid var(--rule);
}

.alpha-nav a {
  font-family: var(--sans);
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--ink-soft);
}

.alpha-nav a:hover { color: var(--accent); }

.glossary__letter {
  margin: var(--sp-10) 0 var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.1em;
}

.glossary-entry {
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--rule);
}

.glossary-entry__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
}

.glossary-entry__term {
  font-size: var(--fs-base);
  font-weight: 600;
}

.glossary-entry__context {
  margin-top: var(--sp-2);
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--ink-soft);
}

.glossary-entry__link {
  display: inline-block;
  margin-top: var(--sp-2);
  font-family: var(--sans);
  font-size: var(--fs-meta);
}

.glossary-entry__link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.glossary__empty {
  padding: var(--sp-16) 0;
  color: var(--ink-soft);
  font-style: italic;
}

/* --- Lightbox ------------------------------------------------------------- */

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 18, 16, 0.92);
  cursor: zoom-out;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--sp-8);
}

.lightbox-overlay.active { display: flex; }

.lightbox-overlay img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
}

.lightbox-caption {
  max-width: 60ch;
  margin-top: var(--sp-4);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  line-height: 1.5;
  text-align: center;
  color: rgba(253, 252, 250, 0.72);
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 900px) {
  :root { --measure: 100%; }
  .matrix { display: none; }
}

@media (min-width: 901px) {
  .stack--matrix-fallback { display: none; }
}

@media (max-width: 600px) {
  main { padding: var(--sp-8) var(--sp-4) var(--sp-12); }
  .masthead__inner,
  .site-footer__inner { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .row { grid-template-columns: 5.5rem 1fr; gap: var(--sp-4); }
  .article-content { font-size: var(--fs-base); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
