/* =========================================================================
   Site styles
   -------------------------------------------------------------------------
   Design tokens live in :root. Change a colour once here and it updates
   everywhere. Nothing below needs a build step.
   ========================================================================= */

:root {
  /* --- Ember: dark warm base, amber/orange/red artwork ----------------- */
  --grad-0:  #0d0908;   /* deepest, top-left        */
  --grad-1:  #1a0f0a;
  --grad-2:  #2b1509;
  --grad-3:  #411d0b;   /* warmest, bottom-right    */

  --amber:   #ffb066;   /* sources, intermediates   */
  --orange:  #f0813a;   /* edges, structure, rules  */
  --hot:     #ff5b2e;   /* the thing being caused   */

  --nav-gradient:
    radial-gradient(120% 240% at 84% 18%, rgba(232,110,30,.22) 0%, rgba(232,110,30,0) 58%),
    linear-gradient(100deg, var(--grad-0) 0%, var(--grad-1) 42%,
                            var(--grad-2) 76%, var(--grad-3) 100%);

  /* --- ink ------------------------------------------------------------- */
  --ink:         #f0ebe6;
  --ink-muted:   #9b8f86;
  --ink-dim:     #6d635b;
  --link:        var(--amber);
  --link-hover:  #ffc48c;
  --rule:        #2a2422;
  --tag-bg:      #241c19;
  --tag-ink:     #b5a79e;
  --tag-bg-on:   var(--orange);
  --tag-ink-on:  #1a0d06;

  --page-bg:     #0c0a09;
  --panel:       #151211;
  --shell:       1920px;
  --nav-h:       64px;

  --font-display: "Chivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body:    "Chivo", -apple-system, BlinkMacSystemFont, "Segoe UI",
                  Roboto, Helvetica, Arial, sans-serif;
}

/* --- reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 219px;
}

/* skip link, keyboard users only */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--amber); color: #1a0d06;
  padding: 10px 16px; z-index: 200; border-radius: 0 0 4px 0;
}
.skip:focus { left: 0; }

/* =========================================================================
   PAGE BACKGROUND  —  the figure field, fixed behind all content
   ========================================================================= */

.page-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(110% 80% at 50% 30%, rgba(232,110,30,.10) 0%, rgba(232,110,30,0) 70%),
    radial-gradient(80% 60% at 90% 95%, rgba(255,91,46,.07) 0%, rgba(255,91,46,0) 72%);
}
.page-field .field { width: 100%; height: 100%; }

/* everything else sits above it */
body > nav, body > main, body > footer, body > .viewer { position: relative; z-index: 1; }

/* =========================================================================
   NAV
   ========================================================================= */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--nav-gradient);
  color: #fff;
}

.nav__inner {
  height: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 219px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* --- wordmark ---------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
  color: #fff;
}
.brand__mark { width: 30px; height: 22px; flex: 0 0 auto; }
.brand__text {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .005em;
  white-space: nowrap;
}
.brand__text .sep {
  font-weight: 300;
  opacity: .65;
  margin: 0 3px;
}

/* --- links ------------------------------------------------------------- */
.nav__links {
  display: flex;
  align-items: center;
  gap: 42px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav__link {
  position: relative;
  display: block;
  padding: 21px 0;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: .012em;
  color: rgba(255,255,255,.94);
  white-space: nowrap;
  transition: color .16s ease;
}
.nav__link:hover,
.nav__link:focus-visible { color: #fff; }

.nav__link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 14px;
  height: 2px;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.nav__link:hover::after,
.nav__link:focus-visible::after { transform: scaleX(1); }
.nav__link[aria-current="page"] { font-weight: 700; }
.nav__link[aria-current="page"]::after { transform: scaleX(1); }

/* --- hamburger (small screens) ----------------------------------------- */
.nav__toggle {
  display: none;
  width: 40px; height: 40px;
  border: 0; padding: 9px;
  background: transparent; color: #fff;
  cursor: pointer;
}
.nav__toggle span {
  display: block; height: 2px; margin: 4px 0;
  background: #fff; border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.nav[data-open="true"] .nav__toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav[data-open="true"] .nav__toggle span:nth-child(2) { opacity: 0; }
.nav[data-open="true"] .nav__toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav__inner { padding: 0 20px; }
  .nav__toggle { display: block; }
  .nav__links {
    position: absolute;
    top: var(--nav-h); left: 0; right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 6px 20px 18px;
    background: var(--grad-1);
    display: none;
  }
  .nav[data-open="true"] .nav__links { display: flex; }
  .nav__link { padding: 13px 0; width: 100%; font-size: 16px; }
  .nav__link::after { bottom: 8px; }
}

/* =========================================================================
   PAGE HEADING  —  big light title with the long hairline running right
   ========================================================================= */

.page { padding: 64px 0 96px; }

.page-head {
  display: flex;
  align-items: center;
  gap: 34px;
  margin: 0 0 46px;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 5.2vw, 52px);
  font-weight: 300;
  letter-spacing: -.012em;
  line-height: 1.06;
  margin: 0;
  white-space: nowrap;
}
.page-head::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--rule);
}
@media (max-width: 620px) {
  .page { padding: 40px 0 64px; }
  .page-head { gap: 18px; margin-bottom: 26px; }
  .page-head h1 { white-space: normal; }
  .page-head::after { display: none; }   /* the trailing rule reads as a stub when short */
}

/* --- tag filter row ---------------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: -26px 0 40px;
}
.filters__label {
  font-size: 12px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-right: 6px;
}
.chip {
  border: 0;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-ink);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.chip:hover { background: #302623; }
.chip[aria-pressed="true"] { background: var(--tag-bg-on); color: var(--tag-ink-on); }

@media (max-width: 620px) { .filters { margin: 0 0 30px; } }

/* =========================================================================
   CARD GRID
   ========================================================================= */

/* Three across, stacked cards (thumbnail above the text). Add more documents
   and they wrap onto further rows of three. */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 219px;
  row-gap: 52px;
}
@media (max-width: 1040px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; row-gap: 44px; }
}
@media (max-width: 680px) {
  .grid { grid-template-columns: 1fr; row-gap: 36px; }
}

.card {
  display: block;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: 100%;
}
.card:focus-visible { outline: 2px solid var(--link); outline-offset: 6px; }

.card__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9.2;
  border-radius: 2px;
  overflow: hidden;
  background: var(--grad-1);
  margin-bottom: 18px;
}
.card__thumb svg { width: 100%; height: 100%; }

.card__body { display: block; min-width: 0; }

.card__title {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.32;
  letter-spacing: -.004em;
  color: var(--link);
  margin: -4px 0 9px;
  transition: color .15s ease;
}
.card:hover .card__title { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }

.card__meta {
  display: block;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-muted);
  margin: 0 0 9px;
}
.card__venue {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 11px;
}
.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.card__tags li {
  font-size: 12.5px;
  line-height: 1;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-ink);
}

/* --- reserved slot ------------------------------------------------------
   A placeholder card holds a space in the row for a document that isn't
   here yet. Not a button, not clickable, no hover. */
.card--slot { cursor: default; }
.card--slot .card__thumb {
  background: none;
  border: 1px dashed var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card--slot .card__thumb svg { width: 34px; height: 34px; opacity: .3; }
/* a reserved slot may instead show its structure, ghosted */
.card--slot .card__ghost { display: block; width: 100%; height: 100%; opacity: .40; }
.card--slot .card__ghost svg { width: 100%; height: 100%; }
.card--slot .card__title { color: var(--ink-dim); }
.card--slot .card__meta  { color: #574c45; }

.empty {
  border: 1px dashed var(--rule);
  border-radius: 3px;
  padding: 44px 32px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 15px;
}
.empty code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--tag-bg);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--amber);
}

/* =========================================================================
   INLINE PDF VIEWER
   ========================================================================= */

.viewer[hidden] { display: none; }
.viewer {
  position: fixed;
  inset: var(--nav-h) 0 0 0;   /* sits below the nav, which stays visible */
  z-index: 90;
  background: #fff;
  display: flex;
  flex-direction: column;
  animation: viewer-in .18s ease-out;
}
@keyframes viewer-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.viewer__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 13px 32px;
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
}
.viewer__title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer__actions { display: flex; gap: 8px; flex: 0 0 auto; }

.btn {
  font: inherit;
  font-size: 13.5px;
  line-height: 1;
  padding: 9px 14px;
  border-radius: 3px;
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--tag-bg); border-color: #3d3330; }
.btn--primary { background: var(--orange); border-color: var(--orange); color: #1a0d06; }
.btn--primary:hover { background: var(--amber); border-color: var(--amber); }

.viewer__frame { flex: 1 1 auto; position: relative; background: var(--nav-gradient); }
.viewer__frame iframe,
.viewer__frame object { width: 100%; height: 100%; border: 0; display: block; }

.viewer__fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #fff;
  text-align: center;
  padding: 32px;
  font-size: 15.5px;
}
.viewer__fallback p { margin: 0; max-width: 34ch; line-height: 1.5; }

@media (max-width: 620px) {
  .viewer__bar { padding: 11px 16px; gap: 10px; flex-wrap: wrap; }
  .viewer__title { flex-basis: 100%; }
}

body.viewer-open { overflow: hidden; }

/* =========================================================================
   PLACEHOLDER PAGES  —  background graphic only
   ========================================================================= */

.hero {
  position: relative;
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--ink);
  /* deliberately much darker than the nav strip: a full page of the nav
     gradient washes out the line art drawn on top of it */
  background:
    radial-gradient(120% 95% at 50% 38%, rgba(232,110,30,.17) 0%, rgba(232,110,30,0) 68%),
    radial-gradient(90% 70% at 88% 92%, rgba(255,91,46,.10) 0%, rgba(255,91,46,0) 70%),
    var(--page-bg);
}
.hero .field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.hero__inner {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px 32px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(38px, 7vw, 76px);
  font-weight: 300;
  letter-spacing: -.02em;
  line-height: 1.05;
  margin: 0;
}
.hero p {
  margin: 18px 0 0;
  font-size: 15px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* =========================================================================
   FOOTER
   ========================================================================= */

.foot {
  border-top: 1px solid var(--rule);
  padding: 26px 0;
  font-size: 13px;
  color: var(--ink-muted);
}
.foot .shell { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}


/* -------------------------------------------------------------------------
   Pre-existing fix, additive. The stacking rule further up this file,

       body > nav, body > main, body > footer, body > .viewer
         { position: relative; z-index: 1; }

   is more specific than `.viewer { position: fixed }` (0-1-1 against 0-1-0),
   so it was winning, and BOTH viewers were being laid out in the document
   flow instead of pinned to the viewport. Opening a document scrolled down
   the page put the viewer off-screen with scrolling already locked. This
   restores the original intent for both, without editing the rule above.
   ------------------------------------------------------------------------- */
body > .viewer { position: fixed; z-index: 90; }

/* =========================================================================
   FIGURES PAGE
   -------------------------------------------------------------------------
   A grouped gallery. Two across, because these are wide landscape diagrams
   and the panel labels have to stay legible in the thumbnail. Everything
   here is additive: nothing above is changed by this block.
   ========================================================================= */

.figgroup { margin: 0 0 64px; }
.figgroup:last-child { margin-bottom: 0; }

.figgroup__title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 400;
  color: var(--ink);
  margin: 0 0 8px;
}

.figgroup__note {
  color: var(--ink-muted);
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 92ch;
  margin: 0 0 30px;
}

/* Two across; one across on narrow windows. */
.grid--figures {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 48px;
  row-gap: 46px;
}
@media (max-width: 1040px) {
  .grid--figures { grid-template-columns: 1fr; row-gap: 38px; }
}

/* The diagrams are dark ink on white, so they need a light plate to sit on
   rather than the page's dark background. `contain` keeps varying aspect
   ratios uncropped. */
.card__thumb--figure {
  aspect-ratio: 16 / 10;
  background: #f7f4f1;
  border: 1px solid var(--rule);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s ease;
}
.card__thumb--figure img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.card--figure:hover .card__thumb--figure { border-color: var(--orange); }

.badge {
  display: inline-block;
  vertical-align: 2px;
  margin-left: 10px;
  padding: 2px 7px;
  border-radius: 2px;
  font-family: var(--font-ui, inherit);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--tag-bg);
  color: var(--tag-ink);
}
.badge--on { background: var(--tag-bg-on); color: var(--tag-ink-on); }

/* Full-screen figure viewer. Reuses .viewer, .viewer__bar and .btn from the
   document viewer above; only the image plate and the note are new. */
.viewer__frame--figure {
  background: #f7f4f1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  overflow: auto;
  cursor: zoom-out;
}
.viewer__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  cursor: default;
}
.viewer__note {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 32px 14px;
  background: var(--panel);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: 13.5px;
  line-height: 1.55;
}

@media (max-width: 760px) {
  .viewer__frame--figure { padding: 12px; }
  .viewer__note { padding: 10px 16px 12px; }
}

/* One figure per row, centred, and larger by the golden ratio: the two-across
   card measures 717px at the 1920px shell, so 717 x 1.618 = 1160px. Opt in per
   group with "layout": "solo" in figures-manifest.js. Groups without that key
   are untouched and stay two across. */
.grid--figures--solo {
  grid-template-columns: minmax(0, 1160px);
  justify-content: center;
  row-gap: 64px;
}
/* Scale the plate's inner padding by the same ratio, 14px x 1.618 = 22.65px.
   Without this the padding stays fixed while the plate grows, and the artwork
   inside ends up 1.660x rather than 1.618x. */
.grid--figures--solo .card__thumb--figure { padding: 22.65px; }
