/* Chronicle of Gods — the website. Colours, type and the hand-made images are the game's own
   (THRESHOLD_THEME, RENDER_CONFIG.ui.material and the house fonts), baked out of its source. */

@font-face { font-family: 'EB Garamond'; src: url('../fonts/eb-garamond-latin-wght-normal.woff2') format('woff2');
  font-style: normal; font-weight: 400 800; font-display: swap; size-adjust: 115%; }
@font-face { font-family: 'EB Garamond'; src: url('../fonts/eb-garamond-latin-wght-italic.woff2') format('woff2');
  font-style: italic; font-weight: 400 800; font-display: swap; size-adjust: 115%; }
@font-face { font-family: 'IM Fell English'; src: url('../fonts/im-fell-english-latin-400-italic.woff2') format('woff2');
  font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: 'IM Fell English SC'; src: url('../fonts/im-fell-english-sc-latin-400-normal.woff2') format('woff2');
  font-style: normal; font-weight: 400; font-display: swap; }

:root {
  --leather: #2a1d0a;
  --leather-edge: #160f06;
  --leather-lit: #4a3313;
  --gold: #c9a227;
  --gold-bright: #e3c25a;
  --gold-tarnished: #a8862f;
  --parch: #f1e7cf;
  --parch-lore: #e3d3a8;
  --parch-lore-low: #dccb9a;
  --ink: #3a2e16;
  --ink-soft: #6b551f;
  --ink-title: #6a3f0f;
  --accent: #7e241a;
  --btn-flat: #ebdfbf;
  --btn-gilt: #dcb84e;

  --text: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --title: 'IM Fell English', 'EB Garamond', Georgia, serif;
  --head: 'IM Fell English SC', 'EB Garamond', Georgia, serif;

  --measure: 38rem;
  --book-w: 1260px;
  --void: #0c0803;
  --gutter: 16px;

  --leather-bg:
    url('../material/blind-stars.svg') 0 0 / 260px repeat,
    url('../material/tex-leather.webp') 0 0 / 260px repeat,
    radial-gradient(ellipse at 50% 18%, var(--leather-lit), var(--leather) 58%, var(--leather-edge));
  --paper-bg:
    radial-gradient(ellipse at 50% 40%, transparent 62%, rgba(90, 61, 14, 0.22) 100%),
    url('../material/tex-foxing.webp') 37px 91px / 300px repeat,
    url('../material/tex-mottle.webp') 0 0 / 320px repeat,
    url('../material/tex-fibre.webp') 0 0 / 240px repeat,
    linear-gradient(180deg, var(--parch-lore), var(--parch-lore-low));
}

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

html { background: var(--void); }

/* The page is the start menu's firmament; the book (cover, sheet, colophon) hangs in it. */
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(201, 162, 39, 0.10), transparent 62%),
    radial-gradient(ellipse at 50% 50%, transparent 42%, rgba(0, 0, 0, 0.55)),
    var(--void);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.125rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; }

:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }

/* ── The firmament: the start menu's own star table, split into a band each side of the book ── */

.sky {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 0;
  width: max(0px, calc((100vw - var(--book-w)) / 2 - 12px));
  pointer-events: none;
}
.sky-l { left: 0; }
.sky-r { right: 0; }
.sky i {
  position: absolute;
  border-radius: 50%;
  color: rgba(245, 234, 205, 0.92);
  background: currentColor;
  box-shadow: 0 0 2px currentColor;
  animation: star-cycle 30s ease-in-out infinite;
}
.sky i.dim { color: rgba(214, 196, 150, 0.5); }
/* Visible most of the cycle, briefly gone: the constellation shifts slowly, as on the start menu. */
@keyframes star-cycle { 0% { opacity: 0; } 8% { opacity: 1; } 76% { opacity: 1; } 90% { opacity: 0; } 100% { opacity: 0; } }

.book {
  position: relative;
  z-index: 1;
  width: min(var(--book-w), 100% - 16px);
  margin: clamp(8px, 2.2vw, 32px) auto;
  background: var(--leather-bg);
  background-color: var(--leather);
  background-blend-mode: normal, multiply, normal;  /* the grain multiplied over the lit radial, as the game's cover */
  border: 2px solid var(--leather-edge);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(138, 111, 42, 0.45), 0 24px 70px rgba(0, 0, 0, 0.7), 0 0 140px rgba(201, 162, 39, 0.07);
}

/* ── The cover: blind-tooled leather, the title in gilt ─────────────────────────────── */

.cover { padding: clamp(16px, 3vw, 36px) var(--gutter) 0; }

.cover-frame {
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 72px) clamp(8px, 4vw, 56px) clamp(120px, 14vw, 180px);
  border: clamp(28px, 6vw, 70px) solid transparent;
  border-image: url('../material/blind-frame.svg') 140 stretch;
  text-align: center;
}

.title {
  margin: 0;
  font-family: var(--title);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.75rem, 8vw, 6rem);
  line-height: 1;
  color: var(--gold-bright);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55), 0 0 28px rgba(201, 162, 39, 0.18);
}

.globes {
  display: block;
  margin: clamp(20px, 4vw, 44px) auto 0;
  max-width: 1180px;
}
.globes img {
  width: 100%;
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 72%, transparent 100%);
          mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 72%, transparent 100%);
}

.tagline {
  max-width: 31em;
  margin: clamp(20px, 3vw, 36px) auto 0;
  font-size: clamp(1.2rem, 2.1vw, 1.45rem);
  line-height: 1.5;
  color: var(--parch-lore);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px 28px;
  margin-top: 32px;
}

.status {
  margin: 18px 0 0;
  font-style: italic;
  color: var(--gold-tarnished);
}

.quiet-link { color: var(--parch-lore); text-underline-offset: 4px; text-decoration-thickness: 1px; }
.quiet-link:hover { color: var(--gold-bright); }

/* ── Buttons: the game's flat fills inside a hand-drawn frame ───────────────────────── */

.btn {
  display: inline-block;
  padding: 0.55em 1.5em 0.6em;
  font-family: var(--head);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: none;
  background: var(--btn-flat);
  border: 3px solid transparent;
  border-image: url('../material/hand-frame-btn.svg') 3 / 3px stretch;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.35), 0 5px 12px rgba(0, 0, 0, 0.28);
  transition: background-color 120ms ease;
}
.btn:hover { background-color: #f4ecd6; }
.btn-gilt { background: var(--btn-gilt); }
.btn-gilt:hover { background-color: var(--gold-bright); }
.btn:active { transform: translateY(1px); }

/* ── The sheet: a deckled leaf of parchment laid on the leather ─────────────────────── */

.sheet {
  position: relative;
  isolation: isolate;
  max-width: 1080px;
  margin: calc(-1 * clamp(80px, 10vw, 130px)) auto 0;
  padding: clamp(44px, 7vw, 88px) clamp(20px, 6vw, 72px) clamp(48px, 7vw, 88px);
  filter: drop-shadow(0 1px 1.4px rgba(0, 0, 0, 0.42)) drop-shadow(0 12px 22px rgba(0, 0, 0, 0.38));
}
.sheet::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper-bg);
  box-shadow: inset 0 1px 0 rgba(255, 248, 224, 0.5), inset 0 0 60px rgba(0, 0, 0, 0.13);
  -webkit-mask-box-image: url('../material/edge-img.svg') 8 round;
}
.sheet::after {
  content: '';
  position: absolute;
  inset: 10px;
  z-index: -1;
  pointer-events: none;
  border: 20px solid transparent;
  border-image: url('../material/hand-frame-plate.svg') 20 stretch;
}

/* Text keeps the measure; a plate takes the sheet's full width, as an illustration does in a book. */
.leaf > :not(.plate) { max-width: var(--measure); margin-left: auto; margin-right: auto; }
.leaf + .leaf { margin-top: clamp(40px, 6vw, 64px); }

.leaf h2 {
  margin: 0 0 0.45em;
  font-family: var(--title);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.9rem, 3.6vw, 2.45rem);
  line-height: 1.12;
  color: var(--ink-title);
}

.leaf p { margin: 0 0 1em; }
.leaf p:last-child { margin-bottom: 0; }

.ornament {
  width: 120px;
  height: 8px;
  margin: clamp(40px, 6vw, 60px) auto;
  background: url('../material/swell.svg') center / 100% 100% no-repeat;
  opacity: 0.8;
}

.plate { margin: 1.8em 0; padding: 0; }
.plate-card { max-width: 760px; margin-left: auto; margin-right: auto; }
/* A plate is printed into the page: a fine ink line at the picture's edge, a margin of lighter paper,
   then the game's hand-drawn double rule with its gilt corner diamonds (the Folio cards' plate frame). */
.frame {
  position: relative;
  padding: 10px;
  border: 20px solid transparent;
  border-image: url('../material/hand-frame-plate.svg') 20 stretch;
  background: rgba(255, 248, 224, 0.32);
  background-clip: padding-box;
}
.pic {
  position: relative;
  box-shadow: 0 0 0 1px rgba(58, 46, 22, 0.6), 0 1px 4px rgba(58, 46, 22, 0.28);
}
.pic > img, .pic > video { width: 100%; background: var(--leather); }
.pic::after {     /* a soft shade at the picture's edge, as ink sinks into paper */
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 22px rgba(58, 46, 22, 0.3);
  pointer-events: none;
}

.plate figcaption {
  max-width: 36em;
  margin: 16px auto 0;
  font-style: italic;
  font-size: 1rem;
  line-height: 1.45;
  text-align: center;
  color: var(--ink-soft);
}

/* ── The town map: pins over a map still, each opening its town's card ──────────────── */

.map-frame > img { width: 100%; }
.map-frame::after { z-index: 1; }   /* the shade sits under the pins */

/* A pin: the game's hand-drawn double ring, gilded; its name on the ribbon the town cards carry. */
.town-pin {
  position: absolute;
  z-index: 2;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  background: url('../material/ring-gilt.svg') center / 100% no-repeat;
  border-radius: 50%;
  text-decoration: none;
  color: var(--ink);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
  transition: filter 140ms ease;
}
.pin-name {
  position: absolute;
  left: 50%;
  top: calc(100% - 2px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--head);
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--ink);
  border-style: solid;
  border-color: transparent;
  border-width: 6px 24px 10px;
  border-image: url('../material/banderole.svg') 6 26 10 fill / 6px 24px 10px stretch;
  padding: 1px 4px 3px;
}
.town-pin:hover, .town-pin:focus-visible, .town-pin[aria-current] {
  filter: drop-shadow(0 0 5px rgba(227, 194, 90, 0.9)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}
.town-pin:hover .pin-name, .town-pin:focus-visible .pin-name, .town-pin[aria-current] .pin-name {
  color: var(--ink-title);
}
.town-pin:focus-visible { outline-offset: 2px; }
/* A label that would crowd a neighbour sits to the ring's west instead (Namvang, over its coast). */
.pin-west .pin-name { left: auto; right: calc(100% - 6px); top: 50%; transform: translateY(-50%); }

.town-list { display: none; }
.town-chip, .pin-name { -webkit-tap-highlight-color: transparent; }
.town-chip {
  display: inline-block;
  font-family: var(--head);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
  border-style: solid;
  border-color: transparent;
  border-width: 6px 24px 10px;
  border-image: url('../material/banderole.svg') 6 26 10 fill / 6px 24px 10px stretch;
  padding: 2px 4px 4px;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}

/* The town opens as a spread of the Chronicle's book: the leather cover round two pages, the land on the
   left page under the town's name, the card on the right, the gutter's shade between them. */
.town-card {
  --spread-h: min(820px, calc(100vh - 48px));
  width: min(1180px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 14px;
  border: 0;
  border-radius: 8px;
  background: var(--leather-bg);
  background-color: var(--leather);
  background-blend-mode: normal, multiply, normal;
  box-shadow: inset 0 0 0 1px rgba(138, 111, 42, 0.55), inset 0 0 0 3px var(--leather-edge), 0 30px 80px rgba(0, 0, 0, 0.6);
  color: var(--ink);
  overflow: auto;
}
.town-card::backdrop { background: rgba(12, 8, 3, 0.74); }
.town-card[open] { animation: card-open 220ms ease-out; }
@keyframes card-open { from { opacity: 0; transform: translateY(8px) scale(0.985); } }

.town-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  height: var(--spread-h);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.page {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 26px clamp(18px, 2.6vw, 36px) 18px;
  background: var(--paper-bg);
}
/* The gutter: each page darkens towards the spine, as the game's own book does. */
.page-left { box-shadow: inset -26px 0 30px -18px rgba(60, 40, 10, 0.45); border-radius: 3px 0 0 3px; }
.page-right { box-shadow: inset 26px 0 30px -18px rgba(60, 40, 10, 0.45); border-radius: 0 3px 3px 0; align-items: center; }

.town-card-title { text-align: center; margin: 0 0 14px; }
.town-card-title h3 {
  margin: 0;
  font-family: var(--title);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.8rem, 3.2vw, 2.5rem);
  line-height: 1.05;
  color: var(--ink-title);
}
.town-card-kind { margin: 4px 0 0; font-family: var(--head); letter-spacing: 0.05em; color: var(--ink-soft); }
.town-card-title::after {      /* the swelled rule under a chapter's heading */
  content: '';
  display: block;
  width: 110px;
  height: 7px;
  margin: 10px auto 0;
  background: url('../material/swell.svg') center / 100% 100% no-repeat;
  opacity: 0.8;
}
.town-card-land {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(58, 46, 22, 0.6), 0 1px 4px rgba(58, 46, 22, 0.28);
}
.town-card-caption {
  margin: 14px auto 0;
  max-width: 30em;
  font-style: italic;
  text-align: center;
  color: var(--ink-soft);
}
.town-card-sheet {
  flex: 1 1 auto;
  min-height: 0;
  width: min(100%, 448px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 95, 34, 0.6) transparent;
  filter: drop-shadow(0 3px 6px rgba(58, 46, 22, 0.3));
}
.town-card-img { width: 100%; }

/* Page-turns at the foot of each page, named for the town they lead to. */
.page-turn {
  align-self: flex-start;
  margin-top: 12px;
  padding: 4px 2px;
  font-family: var(--title);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-title);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
}
.page-right .page-turn { align-self: flex-end; }
.page-turn:hover { border-bottom-color: rgba(106, 63, 15, 0.5); }

.town-card-closer { position: absolute; top: 4px; right: 4px; margin: 0; z-index: 2; }
.town-card-close, .lightbox-close {
  width: 34px;
  height: 34px;
  font: 1.1rem/1 var(--text);
  color: var(--gold-bright);
  background: var(--leather-edge);
  border: 1px solid rgba(201, 162, 39, 0.6);
  border-radius: 50%;
  cursor: pointer;
}
.town-card-close:hover, .lightbox-close:hover { color: var(--leather-edge); background: var(--gold-bright); }

/* ── The enlarged view: a picture opened full size over the dark of the firmament ───── */

.zoomable { cursor: zoom-in; }

.lightbox {
  --room: 140px;               /* the height kept free round the picture: the ✕ above, the caption below */
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 56px 24px 24px;
  border: 0;
  background: transparent;
  color: var(--parch-lore);
  overflow: auto;
  overscroll-behavior: contain;
  cursor: zoom-out;
}
.lightbox:not(.has-caption) { --room: 80px; }
.lightbox[open] { display: flex; animation: lightbox-open 180ms ease-out; }
.lightbox::backdrop { background: rgba(12, 8, 3, 0.92); }
@keyframes lightbox-open { from { opacity: 0; } }

.lightbox-figure { margin: auto; }
/* As large as the screen allows, never past the file's own width. A card, far taller than wide, opens at
   full width and scrolls. */
.lightbox-item {
  width: min(calc(100vw - 48px), calc((100vh - var(--room)) * var(--ar)), var(--nw));
  width: min(calc(100vw - 48px), calc((100dvh - var(--room)) * var(--ar)), var(--nw));
  margin: 0 auto;
  box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.45), 0 20px 60px rgba(0, 0, 0, 0.6);
}
.lightbox.is-tall .lightbox-item { width: min(calc(100vw - 48px), var(--nw)); }
.lightbox-item .town-pin { cursor: pointer; }

.lightbox-caption {
  max-width: 40em;
  margin: 14px auto 0;
  font-style: italic;
  font-size: 1rem;
  line-height: 1.45;
  text-align: center;
}
.lightbox-caption:empty { display: none; }

.lightbox-closer { position: fixed; top: 12px; right: 12px; margin: 0; z-index: 2; }

/* ── The Impressum page ─────────────────────────────────────────────────────────────── */

.legal { margin-top: clamp(24px, 5vw, 56px); }
.legal .back { margin-bottom: 1.2em; }
.legal .note { font-style: italic; color: var(--ink-soft); }
.legal dl { margin: 0; }
.legal dt { margin-top: 0.9em; font-family: var(--head); letter-spacing: 0.03em; color: var(--ink-title); }
.legal dd { margin: 0.1em 0 0; }

.closing { text-align: center; }
.closing .actions { margin-top: 28px; }

/* ── Colophon ───────────────────────────────────────────────────────────────────────── */

.colophon {
  padding: 56px var(--gutter) 64px;
  text-align: center;
  color: var(--parch-lore);
}
.colophon a { text-underline-offset: 4px; text-decoration-thickness: 1px; }
.colophon a:hover { color: var(--gold-bright); }
.colophon p { margin: 12px 0 0; }
.colophon .small { font-size: 0.9rem; color: var(--gold-tarnished); }

.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 26px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--head);
  font-size: 1.15rem;
  letter-spacing: 0.03em;
}

/* ── Narrow screens ─────────────────────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .cover-frame { padding-bottom: 110px; }
  .globes { max-width: 420px; }
  .sheet { margin-left: 8px; margin-right: 8px; }
  .leaf p { hyphens: auto; }
  .sheet::after { inset: 6px; }
}

/* Too narrow for a spread: one page, the name, the card, then the land below it; the whole book scrolls. */
@media (max-width: 900px) {
  .page { display: contents; }
  .town-card-body {
    display: flex; flex-direction: column; align-items: center; height: auto;
    padding: 22px 16px 16px; background: var(--paper-bg); border-radius: 3px;
  }
  .town-card-title { order: 1; }
  .town-card-sheet { order: 2; overflow: visible; filter: none; }
  .town-card-land { order: 3; margin-top: 16px; flex: none; height: auto; }
  .town-card-caption { order: 4; }
  .page-turn { order: 5; align-self: stretch; text-align: center; }
  .page-right .page-turn { order: 6; align-self: stretch; }
}

@media (max-width: 700px) {
  .town-pin { width: 26px; height: 26px; }
  .map-frame .pin-name {      /* hidden from sight, kept as the ring's accessible name */
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
    border: 0; padding: 0; white-space: nowrap;
  }
  .town-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 6px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
  }
  .frame { padding: 6px; border-width: 14px; }
  .town-card { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .town-card[open], .lightbox[open] { animation: none; }
  .sky i { animation: none; opacity: 1; }
  .town-pin { transition: none; }
}

@media (forced-colors: active) {
  .sheet::before, .sheet::after { display: none; }
  .sheet { border: 1px solid CanvasText; filter: none; }
  .btn { border-image: none; border: 1px solid CanvasText; }
}
