/* The Fallen: every boar of the hunt, one chapter at a time, as a wall of
   pictures in ink mounts with a gold keyline. A boar the stream named keeps the
   parchment tag it wore on stream (the overlay's tag), tied to a brass pin in the
   top of its mount. The chapter's number rides on the Chronicle's oxblood ribbon. */

:root {
  --oxblood: #6b1e1b;
  --oxblood-deep: #4a1210;
  --oxblood-light: #8c2b25;
  --tag-paper: #e9d8ae;
  --tag-ink: #2a1c0e;
  --tag-soft: #5a3f22;
  --tag-red: #7a1f1f;
  --serif-sc: "IM Fell English SC", "IM Fell English", Georgia, serif;
}

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Top line, as on the Chronicle */
.chron-nav {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.6rem 1.4rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--gold-dim);
}
.chron-nav a { color: var(--gold-text); text-decoration: none; font-family: var(--serif); font-size: 1.15rem; }
.chron-nav a:hover { color: var(--gold-bright); text-decoration: underline; }
.chron-nav a[aria-current="page"] { color: var(--ivory); }
.chron-home { display: flex; align-items: center; gap: 0.7rem; }
.chron-home img { width: 3.875rem; height: auto; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5)); }
.nav-pages { display: flex; flex-wrap: wrap; gap: 0.3rem 1.4rem; }

/* Heading */
.fallen-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem 2rem; align-items: end;
  margin: 2.4rem 0 1.8rem;
}
.kicker { font-family: var(--serif); font-style: italic; font-size: 1.35rem; color: var(--gold-text); }
.fallen-title { margin-top: 0.1rem; font-family: var(--serif); font-weight: 400; font-size: clamp(2.6rem, 6vw, 4.1rem); line-height: 1.02; }
.lede { margin-top: 0.75rem; max-width: 38rem; font-size: 1.1rem; color: var(--ivory-soft); text-wrap: pretty; }
.tally { display: flex; gap: 2rem; }
.tally dt { font-size: 0.9rem; color: var(--ivory-soft); }
.tally dd { margin: 0; font-family: var(--serif); font-size: 2.6rem; line-height: 1; color: var(--gold-bright); }
.tally div:last-child dd { color: var(--ivory); }

/* Chapters, and every boar or only the named */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.9rem 2rem;
  padding: 0.85rem 0; border-top: 1px solid var(--gold-dim); border-bottom: 1px solid var(--gold-dim);
}
.chapters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.controls-label { margin-right: 0.35rem; font-size: 0.95rem; color: var(--ivory-soft); }
.chip {
  min-width: 2.1rem; height: 2.1rem; padding: 0 0.45rem;
  font: 400 1.15rem/1 var(--serif); color: var(--gold-text);
  background: var(--ink-raised); border: 1px solid var(--gold-dim); border-radius: 2px; cursor: pointer;
}
.chip:hover { border-color: var(--gold); color: var(--gold-bright); }
.chip[aria-current="true"] {
  color: var(--gold-bright); border-color: var(--oxblood-light);
  background: linear-gradient(180deg, var(--oxblood-deep), var(--oxblood) 40%, var(--oxblood-light));
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.ahead { margin-left: 0.35rem; font-family: var(--serif); font-style: italic; font-size: 1rem; color: var(--ivory-soft); }
.show { display: flex; border: 1px solid var(--gold-dim); border-radius: 2px; }
.show button {
  padding: 0.35rem 0.9rem; font: 700 0.9375rem/1.3 var(--sans); color: var(--ivory-soft);
  background: none; border: 0; cursor: pointer;
}
.show button + button { border-left: 1px solid var(--gold-dim); }
.show button[aria-pressed="true"] { color: var(--ink); background: var(--gold-bright); }
.show button:not([aria-pressed="true"]):hover { color: var(--gold-bright); }

/* A chapter: the Chronicle's ribbon hangs from the rule above, carrying its number */
.fl-chapter { margin-top: 2.2rem; }
.fl-head {
  display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; gap: 0.4rem 1.3rem;
  align-items: start; margin-bottom: 1.6rem;
}
.fl-ribbon {
  width: 3rem; height: 5.4rem; margin-top: -2.2rem;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 1.35rem;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.3), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.34)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--oxblood-deep), var(--oxblood) 30%, var(--oxblood-light) 75%, var(--oxblood));
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
  font-family: var(--serif); font-size: 1.6rem; line-height: 1; color: var(--gold-bright);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.fl-ribbon.is-word { font-size: 0.9rem; writing-mode: vertical-rl; transform: rotate(180deg); padding: 0.9rem 0 0; align-items: center; clip-path: polygon(0 16%, 50% 0, 100% 16%, 100% 100%, 0 100%); }
.fl-number { font-family: var(--serif); font-style: italic; font-size: 1.2rem; color: var(--gold-text); }
.fl-title { font-family: var(--serif); font-weight: 400; font-size: clamp(1.8rem, 3.6vw, 2.4rem); line-height: 1.08; color: var(--ivory); text-wrap: balance; }
.fl-title.is-untitled { color: var(--ivory-soft); }
.fl-when { margin-top: 0.3rem; color: var(--ivory-soft); }
.fl-when span { white-space: nowrap; }
.fl-link { align-self: end; font-weight: 700; font-size: 0.95rem; color: var(--gold-text); white-space: nowrap; }
.fl-link[hidden] { display: none; }
.fl-message { margin: 1rem 0 2rem; font-family: var(--serif); font-size: 1.3rem; color: var(--ivory-soft); }
.fl-message:empty { display: none; }

/* The plates: each boar's picture in an ink mount with a gold keyline */
.plates {
  margin: 0; padding: 0; list-style: none;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1.6rem 1.4rem;
}
.plate {
  position: relative;
  padding: 0.55rem 0.55rem 0.65rem;
  background-color: var(--ink-raised);
  background-image: var(--grain-light);
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.32);
}
.plate.is-named, .plate.is-ding { border-color: var(--gold); }
.plate.is-target { box-shadow: 0 0 0 2px var(--gold-bright), 0 12px 24px rgba(0, 0, 0, 0.32); }
.plate-open {
  display: block; position: relative; width: 100%; padding: 0; border: 0;
  font: inherit; color: inherit; background: var(--ink-deep); cursor: zoom-in;
}
.plate-frame {
  display: block; aspect-ratio: 1280 / 949; overflow: hidden;
  box-shadow: 0 0 0 1px var(--ink-deep), 0 0 0 2px var(--gold-dim);
}
.plate-pic { display: block; width: 100%; max-width: 100%; height: 100%; object-fit: cover; }
.plate-open:hover .plate-frame, .plate-open:focus-visible .plate-frame { box-shadow: 0 0 0 1px var(--ink-deep), 0 0 0 2px var(--gold-bright); }
.plate-cap { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 0.75rem; align-items: baseline; padding: 0.6rem 0.15rem 0; }
.plate-n { font-family: var(--serif-sc); font-size: 1.12rem; color: var(--gold-text); }
.plate-when { justify-self: end; font-size: 0.85rem; color: var(--ivory-soft); text-align: right; }
.plate.is-live .plate-when { font-style: italic; }
.plate-what { grid-column: 1 / -1; font-size: 0.95rem; color: var(--ivory); }
.plate-zone { color: var(--ivory-soft); }
.plate-zone::before { content: "\00a0\00b7\0020"; }
.plate-zone:empty { display: none; }

/* No picture (before pictures were on, or one that failed): an empty mount with the number pressed into it */
.plate-empty {
  display: grid; place-content: center; text-align: center; width: 100%; aspect-ratio: 1280 / 949;
  background:
    repeating-linear-gradient(135deg, rgba(95, 77, 44, 0.12) 0 1px, transparent 1px 9px),
    var(--ink-deep);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--ink-deep), 0 0 0 2px var(--gold-dim);
}
.plate-empty b { font: 400 2.6rem/1 var(--serif); color: var(--gold-dim); text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7), 0 1px 0 rgba(184, 146, 74, 0.25); }
.plate-empty i { margin-top: 0.3rem; font-family: var(--serif); font-size: 0.95rem; color: #8e8571; }

/* The boar that closed a chapter, and the milestones */
.plate-mark { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.55rem; margin-top: 0.3rem; font-family: var(--serif); font-style: italic; color: var(--gold-bright); }
.plate-mark .mark-stud { flex: none; width: 10px; height: 10px; }
.coin {
  position: absolute; left: 0.25rem; bottom: 0.25rem; min-width: 2.6rem; height: 2.6rem; padding: 0 0.3rem; border-radius: 1.3rem;
  display: grid; place-content: center; font: 400 0.95rem/1 var(--serif); color: #3b2808;
  background: radial-gradient(circle at 35% 30%, #fbe7a6, #e0b65e 38%, #a8802f 70%, #6d4e19);
  box-shadow: inset 0 0 0 2px rgba(80, 55, 14, 0.55), inset 0 0 0 4px rgba(250, 226, 150, 0.4), 0 3px 6px rgba(0, 0, 0, 0.55);
}

/* The tag, as on stream: aged paper, corners clipped like a luggage tag, tied with
   twine to a brass pin in the top of the mount, hanging askew over the picture. */
.tag {
  --w: 6.6rem;
  position: absolute; z-index: 2; top: -0.55rem; right: 1.1rem; width: var(--w);
  pointer-events: none; transform-origin: 50% 0;
}
.tag-pin {
  position: absolute; top: 0; left: calc(50% - 0.27rem); width: 0.54rem; height: 0.54rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f6dc93, #b48a3a 55%, #5a3f12);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.tag-cord {
  position: absolute; top: 0.3rem; left: calc(50% - 0.05rem); width: 0.1rem; height: 1.05rem;
  background: linear-gradient(90deg, #6b5230, #b39363 50%, #6b5230);
  box-shadow: 0 0.1rem 0.15rem rgba(0, 0, 0, 0.5);
}
.tag-card {
  position: relative; margin-top: 1.05rem; padding: 0.62rem 0.45rem 0.45rem; text-align: center; isolation: isolate;
  transform: rotate(var(--sway, -5deg)); transform-origin: 50% 0.35rem;
}
.tag-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-color: var(--tag-paper);
  background-image: radial-gradient(ellipse at 40% 40%, rgba(255, 250, 236, 0.45), rgba(255, 250, 236, 0) 70%), var(--paper, none);
  background-size: auto, 100% 100%;
  clip-path: polygon(0.85rem 0, calc(100% - 0.85rem) 0, 100% 0.85rem, 100% 100%, 0 100%, 0 0.85rem);
  box-shadow: inset 0 0 1rem rgba(104, 66, 18, 0.5);
  filter: url(#rough-edge-fine) drop-shadow(0 0.3rem 0.4rem rgba(0, 0, 0, 0.6));
}
.tag-hole {
  position: absolute; top: 0.16rem; left: calc(50% - 0.24rem); width: 0.48rem; height: 0.48rem; border-radius: 50%;
  background: radial-gradient(circle, #1b130a 0 38%, #f0cf86 42%, #8a6420 70%, #5a3f12 100%);
}
.tag p { margin: 0; }
.tag-head { margin-top: 0.12rem !important; font-family: var(--serif-sc); font-size: 0.72rem; letter-spacing: 0.06em; line-height: 1.1; color: var(--tag-red); }
.tag-name { margin-top: 0.1rem !important; font-family: var(--serif); font-style: italic; font-size: 1.12rem; line-height: 1.05; color: var(--tag-ink); overflow-wrap: break-word; filter: url(#ink); }
.tag-name.is-long { font-size: 0.94rem; }
.tag-by { margin-top: 0.18rem !important; font-family: var(--serif); font-style: italic; font-size: 0.72rem; line-height: 1.15; color: var(--tag-soft); overflow-wrap: anywhere; }

/* The viewer: one boar, large, with the one before and after a key away */
.viewer {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto;
  background: rgba(8, 14, 20, 0.97);
  backdrop-filter: blur(4px);
  padding-block: calc(env(safe-area-inset-top, 0px) + 3.4rem) calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.viewer[hidden] { display: none; }
.viewer-inner { max-width: 1060px; margin: 0 auto; }
/* The frame fits the picture, whatever its shape (it follows the crop), and the words below keep to its width. */
.viewer figure { display: table; margin: 0 auto; }
.viewer figcaption { display: table-caption; caption-side: bottom; }
.viewer-close {
  position: fixed; z-index: 21; top: calc(env(safe-area-inset-top, 0px) + 0.8rem); right: max(1rem, env(safe-area-inset-right, 0px));
  padding: 0.3rem 0.8rem; font: 700 0.95rem/1.3 var(--sans); color: var(--gold-text);
  background: var(--ink-raised); border: 1px solid var(--gold-dim); border-radius: 2px; cursor: pointer;
}
.viewer-close:hover { border-color: var(--gold); color: var(--gold-bright); }
.viewer-frame {
  position: relative; padding: 0.7rem;
  background-color: var(--ink-raised); background-image: var(--grain-light);
  border: 1px solid var(--gold); border-radius: 3px;
  box-shadow: inset 0 0 0 5px var(--ink-raised), inset 0 0 0 6px var(--gold-dim), 0 20px 50px rgba(0, 0, 0, 0.6);
}
.viewer-pic { display: block; width: auto; height: auto; max-width: 100%; max-height: 70vh; background: var(--ink-deep); }
.viewer .plate-empty { width: min(1040px, calc(100vw - 4rem), calc(70vh * 1280 / 949)); }
.viewer .plate-empty b { font-size: 6rem; }
.viewer .tag { --w: 9.6rem; top: -0.4rem; right: 2.2rem; }
.viewer .tag-head { font-size: 0.85rem; }
.viewer .tag-name { font-size: 1.45rem; }
.viewer .tag-name.is-long { font-size: 1.15rem; }
.viewer .tag-by { font-size: 0.85rem; }
.viewer .tag-card { margin-top: 1.3rem; padding: 0.8rem 0.6rem 0.55rem; }
.viewer .tag-cord { height: 1.3rem; }
.viewer .coin { left: 1rem; bottom: 1rem; min-width: 3.6rem; height: 3.6rem; border-radius: 1.8rem; font-size: 1.3rem; }
.viewer-cap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem 2rem; align-items: start; margin-top: 1.2rem; }
.viewer-n { font-family: var(--serif); font-style: italic; font-size: 1.25rem; color: var(--gold-text); }
.viewer-title { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.05; color: var(--ivory); overflow-wrap: break-word; }
.viewer-text { margin-top: 0.45rem; max-width: 40rem; color: var(--ivory-soft); text-wrap: pretty; }
.viewer-text strong { color: var(--ivory); font-weight: 500; }
.viewer-text a { color: var(--gold-text); }
.viewer-steps { display: flex; gap: 0.6rem; }
.viewer-steps button {
  padding: 0.4rem 0.85rem; font: 700 0.95rem/1.3 var(--sans); color: var(--ivory);
  background: var(--ink-raised); border: 1px solid var(--gold); border-radius: 2px; cursor: pointer; white-space: nowrap;
}
.viewer-steps button:hover:not(:disabled) { color: var(--ink); background: var(--gold-bright); }
.viewer-steps button:disabled { opacity: 0.35; cursor: default; }
.viewer-steps small { display: block; font-weight: 400; font-family: var(--serif); font-style: italic; font-size: 0.9rem; color: inherit; opacity: 0.85; }
.viewer-steps small:empty { display: none; }
body.is-viewing { overflow: hidden; }

@media (max-width: 700px) {
  .fallen-head { grid-template-columns: minmax(0, 1fr); margin-top: 1.8rem; }
  .fl-head { grid-template-columns: 2.6rem minmax(0, 1fr); }
  .fl-ribbon { width: 2.6rem; height: 4.8rem; font-size: 1.35rem; }
  .fl-link { grid-column: 2; justify-self: start; white-space: normal; }
  .viewer-cap { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .plates { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 0.75rem; }
  .plate { padding: 0.4rem 0.4rem 0.5rem; }
  .plate-cap { grid-template-columns: minmax(0, 1fr); }
  .plate-when { justify-self: start; text-align: left; font-size: 0.8rem; }
  .plate-n { font-size: 1rem; }
  .plate-what { font-size: 0.88rem; }
  .plate-zone { display: block; }
  .plate-zone::before { content: none; }
  .plate-mark { font-size: 0.9rem; gap: 0.4rem; }
  .tag { --w: 5.1rem; right: 0.5rem; }
  .tag-name { font-size: 0.95rem; }
  .tag-name.is-long { font-size: 0.8rem; }
  .tag-head, .tag-by { font-size: 0.64rem; }
  .plate-empty b { font-size: 2rem; }
  .coin { min-width: 2.1rem; height: 2.1rem; font-size: 0.8rem; }
  .viewer .tag { --w: 6.4rem; right: 1.2rem; }
  .viewer .tag-name { font-size: 1.1rem; }
  .viewer .tag-name.is-long { font-size: 0.92rem; }
  .viewer .tag-head, .viewer .tag-by { font-size: 0.7rem; }
  .viewer .tag-card { margin-top: 1.05rem; padding: 0.6rem 0.45rem 0.45rem; }
  .viewer .tag-cord { height: 1.05rem; }
  .chron-home img { width: 48px; }
  .tally dd { font-size: 2.1rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .plate .tag-card { transition: transform 0.6s cubic-bezier(0.3, 0.6, 0.4, 1); }
  .plate:hover .tag-card { transform: rotate(calc(var(--sway, -5deg) + 4deg)); }
}
