/* ============================================================
   The Axía of Choice — shared artwork page styles

   Each artwork page supplies its own palette by overriding the
   custom properties below in a small <style> block. Pages may
   also override --detail-note and --quote-rule to match the
   rule colours to a painting's palette.
   ============================================================ */

:root {
  /* Base palette — fallbacks if a page forgets to declare one */
  --hero-bg: #252525;
  --hero-ink: #D4C5A8;
  --hero-muted: #A89B87;
  --paper: #f5f1e8;
  --ink: #262824;
  --muted: #77766b;
  --accent: #a84f3b;
  --accent-dark: #793b30;
  --accent-soft: #d18a70;
  --link-line: #c9a59a;
  --ochre: #C9A227;
  --water: #7d8a8c;
  --line: #ddd5c6;
  --fig-bg: #eee8dc;
  --fig-border: #d8cebd;

  /* Secondary rule colours — pages can override to match a painting */
  --detail-note: var(--ochre);
  --quote-rule:  var(--water);
}

/* ============================================================
   Reset and base
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.7;
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(168,79,59,.22); }

/* ============================================================
   Reading progress bar
   ============================================================ */
#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--accent); z-index: 900; pointer-events: none;
}

/* ============================================================
   Skip link
   ============================================================ */
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 2000;
  background: var(--paper); color: var(--ink);
  padding: .6rem 1rem; font-size: .85rem;
}
.skip-link:focus { top: 1rem; }

/* ============================================================
   Hero
   ============================================================ */
.hero-wrapper {
  background: var(--hero-bg);
  color: var(--hero-ink);
  border-bottom: 4px solid var(--accent);
}
.collection-bar {
  max-width: 1700px; margin: 0 auto; padding: 1.25rem 5vw 0;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem;
  color: var(--hero-muted);
  font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
}
.collection-mark { font-weight: 700; color: var(--hero-ink); }
.collection-kicker { text-align: right; }

.hero-section {
  max-width: 1700px; margin: 0 auto; padding: 3.2rem 5vw 4.5rem;
  display: flex; justify-content: center; align-items: center;
  gap: clamp(1.34rem, 3.34vw, 3.66rem);
}
.hero-image {
  position: relative; flex: 0 1 auto; min-width: 0;
  width: fit-content; max-width: 100%;
  overflow: hidden;
  border: 1px solid rgba(212,197,168,.18);
  box-shadow: 0 18px 45px rgba(0,0,0,.32);
  cursor: zoom-in; background: none; padding: 0;
  font: inherit; color: inherit; display: block;
}
.hero-image::after {
  content: ""; pointer-events: none; position: absolute; inset: 0;
  border: 1px solid rgba(255,255,255,.08);
}
.hero-image img {
  display: block; width: auto; height: auto;
  max-width: 100%; max-height: 78vh;
  transition: transform .45s ease;
}
.hero-image:hover img { transform: scale(1.012); }
.hero-image:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; }

.zoom-hint {
  position: absolute; left: .9rem; bottom: .8rem;
  font-size: .66rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--hero-ink); background: rgba(37,37,37,.74);
  padding: .35rem .65rem;
  opacity: 0; transform: translateY(4px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.hero-image:hover .zoom-hint { opacity: 1; transform: none; }
@media (hover: none) { .zoom-hint { display: none; } }

.hero-info { flex: 0 1 auto; min-width: 0; padding: .5rem 0; }
.eyebrow {
  color: var(--accent-soft);
  text-transform: uppercase; letter-spacing: .22em;
  font-size: .7rem; font-weight: 700; margin-bottom: 1.35rem;
}
.hero-info h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(2.4rem, 3.9vw, 4.3rem);
  letter-spacing: -.035em; line-height: 1.04;
  margin-bottom: 1.1rem; color: var(--hero-ink);
}
.hero-info h1 .title-zh {
  display: block; font-size: .55em; letter-spacing: .05em; margin-top: .35rem;
}
.artist {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem; font-style: italic;
  color: var(--hero-muted); margin-bottom: 2rem;
}
.meta-rule {
  width: 64px; border: 0;
  border-top: 2px solid var(--accent);
  margin-bottom: 1.5rem;
}
.artwork-meta { font-size: .95rem; line-height: 1.9; color: var(--hero-ink); }
.artwork-meta span.label {
  display: block; color: var(--hero-muted);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .15em;
  margin-top: .85rem;
}
.artwork-meta span.label:first-child { margin-top: 0; }
.artwork-meta .frame-note {
  display: block; margin-top: .35rem; font-size: .82rem;
  color: var(--hero-muted); font-style: italic; line-height: 1.5;
}

/* Hero back-to-collection link (top of page) */
.hero-info > .back-btn {
  display: inline-block; margin-top: 2.4rem; padding: .7rem 0 .35rem;
  border-bottom: 1px solid var(--hero-muted);
  color: var(--hero-ink);
  font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  transition: color .2s, border-color .2s;
}
.hero-info > .back-btn:hover {
  color: var(--accent-soft); border-color: var(--accent-soft);
}

/* ============================================================
   Essay
   ============================================================ */
.essay-section { background: var(--paper); }
.essay-inner {
  max-width: 1250px;
  margin: 0 auto;
  padding: 4.5rem 7vw 4rem;
}
.essay-intro { max-width: 790px; margin-bottom: 4rem; }
.section-label {
  color: var(--accent);
  text-transform: uppercase;
  font-size: .68rem; letter-spacing: .2em; font-weight: 700;
  margin-bottom: 1rem;
}
.essay-text { max-width: 76ch; }
.essay-text p {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem; line-height: 1.85;
  margin-bottom: 1.65rem; color: var(--ink);
}
.essay-text h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 2.4vw, 2.25rem);
  font-weight: 400; line-height: 1.2;
  margin: 3.8rem 0 1.5rem; padding-bottom: .8rem;
  border-bottom: 1px solid var(--line); color: var(--ink);
}
.essay-text h3 {
  font-size: .78rem; font-weight: 700; letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin: 1.8rem 0 .8rem;
}
.essay-text em { color: var(--muted); }
.essay-text a { color: var(--accent-dark); border-bottom: 1px solid var(--link-line); }
.essay-text a.table-link { cursor: pointer; }

/* ============================================================
   Figures
   ============================================================ */
figure.inline-figure, figure.figure-section {
  background: var(--fig-bg);
  border: 1px solid var(--fig-border);
  margin: 2rem 0 2.2rem;
}
figure.inline-figure {
  float: right; width: 36%;
  margin: .35rem 0 1.5rem 2rem;
}
figure.figure-section { width: 100%; }
figure.inline-figure img, figure.figure-section img {
  display: block; width: 100%; height: auto; cursor: zoom-in;
}
figure.inline-figure .detail-crop {
  display: block; width: 100%; height: 260px;
  background-repeat: no-repeat; background-size: 260%;
  cursor: zoom-in;
}
figure figcaption {
  padding: .9rem 1rem 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: .76rem; line-height: 1.55;
  color: var(--muted);
  border-top: 1px solid var(--fig-border);
}
figure figcaption strong { color: var(--accent-dark); font-weight: 700; }

/* ============================================================
   Detail note and pull-quote
   ============================================================ */
.detail-note {
  border-left: 3px solid var(--detail-note);
  padding: .3rem 0 .3rem 1.2rem;
  margin: 2.3rem 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem; font-style: italic;
}

.essay-text blockquote {
  margin: 2.8rem 0; padding: .4rem 0 .4rem 1.5rem;
  border-left: 2px solid var(--quote-rule);
}
.essay-text blockquote p {
  font-size: 1.28rem; font-style: italic; line-height: 1.6;
  margin-bottom: .6rem;
}
.essay-text blockquote .quote-attrib {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: .78rem; color: var(--muted);
  text-align: right; margin: .5rem 0 0; font-style: normal;
}

/* ============================================================
   Bottom page navigation — Back to Collection + Top

   max-width: 76ch matches .essay-text so the two links sit at
   the left and right edges of the essay column. This works
   whether the nav sits inside .essay-inner (artwork3–21) or
   directly inside .essay-section (artwork0–2). The `↑` arrow
   for .to-top is added by the ::before rule, so the page markup
   only needs "Top".
   ============================================================ */
.footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: 76ch;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.footer-nav .back-btn,
.footer-nav .to-top {
  display: inline-block;
  margin: 0;
  padding: .55rem 0 .35rem;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: color .2s, border-color .2s;
}
.footer-nav .back-btn:hover,
.footer-nav .to-top:hover {
  color: var(--accent-dark);
  border-bottom-color: var(--accent-dark);
}
.footer-nav .to-top::before {
  content: "↑ ";
  font-size: .95rem;
  line-height: 1;
}

/* ============================================================
   Colophon
   The inline "↑ Top" inside the colophon is hidden — the
   .footer-nav above now carries it — so the footer text stays
   as a simple two-part credit.
   ============================================================ */
.colophon {
  background: var(--fig-bg);
  border-top: 1px solid var(--line);
  padding: 1.7rem 7vw;
  color: var(--muted);
  font-size: .72rem; letter-spacing: .06em;
}
.colophon-inner {
  max-width: 1250px; margin: 0 auto;
  display: flex; justify-content: space-between; gap: 1rem;
}
.colophon a.to-top { display: none; }

/* ============================================================
   Lightbox
   ============================================================ */
#lightbox {
  display: none; position: fixed; z-index: 1000; inset: 0;
  background: rgba(20,23,22,.97); cursor: zoom-out;
}
#lightbox img {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: auto; height: auto; max-width: 95vw; max-height: 95vh;
  object-fit: contain;
  border: 1px solid rgba(212,197,168,.3);
  box-shadow: 0 15px 60px rgba(0,0,0,.5);
}
#lightbox-caption {
  position: absolute; top: 3vh; left: 50%; transform: translateX(-50%);
  color: var(--hero-ink); text-align: center;
  font-size: .95rem; max-width: 80%; line-height: 1.5;
  opacity: .95; text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
.close-lightbox {
  position: absolute; top: 18px; right: 28px;
  color: var(--hero-ink); background: none; border: 0;
  font-size: 2.5rem; line-height: 1; cursor: pointer;
  font-family: system-ui, sans-serif;
}
.close-lightbox:focus-visible {
  outline: 2px solid var(--accent-soft); outline-offset: 4px; border-radius: 2px;
}

/* ============================================================
   Table modal (used by pages that expand a data table)
   ============================================================ */
#table-modal {
  display: none; position: fixed; z-index: 2000; inset: 0;
  background: rgba(0,0,0,.8);
}
#table-modal .table-content {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--paper); color: var(--ink);
  padding: 2.5rem; width: 90%; max-width: 900px;
  max-height: 90vh; overflow-y: auto;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
#table-modal h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem; font-weight: 400;
  color: var(--ink);
  margin-bottom: 1.5rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}
#table-modal table {
  width: 100%; border-collapse: collapse;
  font-size: .9rem; line-height: 1.5;
}
#table-modal th, #table-modal td {
  border: 1px solid #d0d0d0; padding: .7rem;
  vertical-align: top; text-align: left;
}
#table-modal th { background: #ece5d7; font-weight: 700; }
#table-modal .close-table {
  position: absolute; top: 1rem; right: 1.5rem;
  font-size: 1.5rem; cursor: pointer;
  color: var(--muted); background: none; border: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .hero-section { flex-direction: column; gap: 2.2rem; padding: 2.3rem 6vw 3rem; }
  .hero-image img { max-height: 65vh; }
  .hero-info { max-width: 680px; }
  .hero-info h1 { font-size: clamp(2.7rem, 9vw, 4rem); }
  .essay-inner { padding: 3rem 6vw 3rem; }
  figure.inline-figure { float: none; width: 100%; margin: 1.5rem 0 2rem; }
  figure.inline-figure .detail-crop { height: 220px; }
  .footer-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.4rem;
  }
  .colophon-inner { flex-direction: column; }
  #table-modal .table-content { padding: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}