/* ============================================================
   ANCESTORS 2026 — Tournament Book & Player Directory
   Brand: ink #1F2732 · cream #FBF7F5 · brown #785336
          vision #235AAD / #95B7ED · legacy #3D7542 / #1D3E28
   ============================================================ */

:root {
  --ink: #1F2732;
  --ink-soft: #3a4552;
  --cream: #FBF7F5;
  --cream-dim: #f1eae4;
  --paper: #fffdfb;
  --brown: #785336;
  --tan: #c99e63;
  --vision: #235AAD;
  --vision-light: #95B7ED;
  --legacy: #3D7542;
  --legacy-dark: #1D3E28;
  --line: rgba(31, 39, 50, 0.14);

  --font-display: "Londrina Solid", "Trebuchet MS", sans-serif;
  --font-body: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.2rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 2.75rem;

  --shadow-card: 0 1px 2px rgba(31,39,50,.06), 0 8px 24px rgba(31,39,50,.09);
  --shadow-pop: 0 2px 6px rgba(31,39,50,.14), 0 18px 48px rgba(31,39,50,.22);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--cream);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--cream);
  text-decoration: none;
  flex-shrink: 0;
}

.brand svg { display: block; }
.lbl-short { display: none; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.35rem;
  letter-spacing: 0.12em;
  line-height: 1;
}

.brand-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  opacity: 0.72;
  margin-top: 2px;
}

.topnav {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.topnav a {
  color: var(--cream);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 999px;
  opacity: 0.75;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}

.topnav a:hover { opacity: 1; background: rgba(251,247,245,.1); }
.topnav a.active { opacity: 1; background: rgba(251,247,245,.16); }

/* ============================================================
   FLIPBOOK
   ============================================================ */

.book-shell {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 57px);
  overflow: hidden;
}

/* Immersive mode — book fills the window */
body.immersive .topbar { display: none; }
body.immersive .book-shell { height: 100dvh; }
body.immersive .book-stage { padding: 8px 48px; }
body.immersive .controls { padding-top: 4px; }

.book-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* we handle swipes ourselves */
  padding: 18px 64px;
}

#flipbook-holder {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.stf__wrapper { max-height: 100%; }

#flipbook { margin: 0 auto; }

.page {
  background: var(--paper);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(31,39,50,.08);
}

.page img.page-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.page .hotspot-layer {
  position: absolute;
  inset: 0;
}

.hotspot {
  position: absolute;
  display: block;
  border-radius: 10px;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
}

.hotspot:hover {
  background: rgba(149, 183, 237, 0.14);
  box-shadow: inset 0 0 0 2px rgba(35, 90, 173, 0.55);
}

.hotspot .chip {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: 999px;
  opacity: 0.92;
  pointer-events: none;
  white-space: nowrap;
}

/* gutter click zones for flipping */
.flip-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 56px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  opacity: 0.45;
  transition: opacity .15s, transform .15s;
}
.flip-zone:hover { opacity: 1; }
.flip-zone:active { transform: scale(.94); }
.flip-zone.prev { left: 4px; }
.flip-zone.next { right: 4px; }
.flip-zone svg { width: 34px; height: 34px; }
.flip-zone:disabled { opacity: 0.12; cursor: default; }

/* ---------- control bar ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px 14px;
  flex-wrap: wrap;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.ctrl-btn:hover { background: var(--cream-dim); border-color: rgba(31,39,50,.3); }
.ctrl-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.page-indicator {
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-soft);
  min-width: 84px;
  text-align: center;
}

/* ---------- thumbnail drawer ---------- */
.thumbs {
  display: none;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 16px 14px;
  scrollbar-width: thin;
}
.thumbs.open { display: flex; }

.thumb {
  flex: 0 0 auto;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0;
  background: none;
  cursor: pointer;
  position: relative;
  transition: transform .12s;
}
.thumb:hover { transform: translateY(-2px); }
.thumb img { display: block; width: 64px; border-radius: 4px; box-shadow: var(--shadow-card); }
.thumb.active { border-color: var(--brown); }
.thumb span {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 9px;
  font-weight: 700;
  background: rgba(31,39,50,.82);
  color: var(--cream);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---------- in-book directory CTA page ---------- */
@font-face {
  font-family: "Sensa Wild Fill";
  font-display: swap;
  src:
    url("../directory/assets/fonts/SensaWild-Fill.woff2") format("woff2"),
    url("../directory/assets/fonts/SensaWild-Fill.woff") format("woff");
}

.dir-page {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 18, 14, 0.72) 0%, rgba(7, 18, 14, 0.38) 48%, rgba(7, 18, 14, 0.16) 100%),
    url("../directory/assets/course/sand-valley-hero.jpg") center / cover no-repeat #16241c;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  text-align: left;
  padding: 8% 8% 6.5%;
  gap: 3%;
}

.dir-copy { display: flex; flex-direction: column; gap: 2.6%; }

.dir-page .kicker {
  font-size: clamp(9px, 1.7cqw, 14px);
  font-weight: 700;
  letter-spacing: .3em;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 2.4%;
}

.dir-page h2 {
  font-family: "Sensa Wild Fill", var(--font-display);
  font-weight: 400;
  font-size: clamp(21px, 5.4cqw, 56px);
  letter-spacing: .04em;
  margin: 0 0 2.4%;
  line-height: 0.98;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.38);
}

.dir-motto {
  font-size: clamp(10px, 2cqw, 17px);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.38);
  margin-bottom: 2.4%;
}

.dir-page p {
  max-width: 52ch;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(10.5px, 2cqw, 17.5px);
  line-height: 1.5;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.dir-map-link {
  position: relative;
  display: block;
  width: 80%;
  margin: 1% auto 3%;
  text-decoration: none;
}

.dir-page .map-teaser {
  display: block;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.dir-cta {
  position: absolute;
  left: 50%;
  bottom: -5.5%;
  transform: translateX(-50%);
  white-space: nowrap;
  display: inline-block;
  background: var(--cream);
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(10px, 1.9cqw, 16px);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0.8em 1.8em;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  transition: background .15s, color .15s;
}
.dir-map-link:hover .dir-cta { background: var(--tan); color: var(--ink); }

.dir-banners {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 4%;
}

.dir-banners img {
  width: 34%;
  max-width: 240px;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.4));
}

/* ---------- zoom overlay ---------- */
.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(24, 30, 39, 0.94);
  display: none;
  touch-action: none;
}
.zoom-overlay.open { display: block; }

.zoom-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}
.zoom-canvas.dragging { cursor: grabbing; }

.zoom-canvas img {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}

.zoom-ui {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}

.zoom-ui .ctrl-btn { box-shadow: var(--shadow-pop); }

.zoom-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
}

.zoom-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}
.zoom-nav.prev { left: 14px; }
.zoom-nav.next { right: 14px; }

.zoom-pageno {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--cream);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: .1em;
  z-index: 10;
  background: rgba(31,39,50,.6);
  padding: 5px 14px;
  border-radius: 999px;
}

/* ---------- loading ---------- */
.book-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  z-index: 60;
  transition: opacity .4s;
}
.book-loading.done { opacity: 0; pointer-events: none; }

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--brown);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.book-loading p {
  font-size: var(--text-sm);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ============================================================
   PLAYER DIRECTORY
   ============================================================ */

.dir-hero {
  padding: 44px 24px 10px;
  max-width: 1120px;
  margin: 0 auto;
}

.dir-hero .kicker {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--brown);
  margin: 0 0 8px;
}

.dir-hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: .04em;
  line-height: 1;
  margin: 0 0 10px;
}

.dir-hero .lede {
  max-width: 62ch;
  color: var(--ink-soft);
  font-size: var(--text-lg);
  margin: 0;
}

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-size: var(--text-sm);
  font-weight: 600;
}

.legend .dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: -1px;
}
.dot.vision { background: var(--vision); }
.dot.legacy { background: var(--legacy); }
.dot.host { background: var(--tan); }

.map-wrap {
  max-width: 1120px;
  margin: 22px auto 0;
  padding: 0 24px;
}

#map {
  height: 520px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  background: var(--cream-dim);
  z-index: 1;
}

.map-hint {
  text-align: center;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  margin: 10px 0 0;
}

/* leaflet marker styling */
.player-pin {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2.5px solid var(--cream);
  box-shadow: 0 1px 4px rgba(31,39,50,.4);
  cursor: pointer;
}
.player-pin.vision { background: var(--vision); }
.player-pin.legacy { background: var(--legacy); }

.host-pin svg { filter: drop-shadow(0 2px 3px rgba(31,39,50,.4)); }

.leaflet-popup-content-wrapper {
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  font-family: var(--font-body);
}
.leaflet-popup-content { margin: 12px 16px; }
.pop-name { font-weight: 700; font-size: 15px; }
.pop-town { color: var(--ink-soft); font-size: 13px; margin-top: 1px; }
.pop-team { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-top: 5px; }
.pop-team.vision { color: var(--vision); }
.pop-team.legacy { color: var(--legacy); }
.pop-link {
  display: inline-block;
  margin-top: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--brown);
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- founders ---------- */
.section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 46px 24px 0;
}

.section > h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-2xl);
  letter-spacing: .05em;
  margin: 0 0 4px;
}

.section > .section-sub {
  color: var(--ink-soft);
  margin: 0 0 22px;
  max-width: 70ch;
}

.founders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.founder-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.founder-card .avatar { flex-shrink: 0; }

.founder-card h3 { margin: 0; font-size: var(--text-xl); font-family: var(--font-display); font-weight: 400; letter-spacing: .04em; }
.founder-card .role { color: var(--brown); font-weight: 700; font-size: var(--text-sm); margin: 2px 0 0; }
.founder-card .town { color: var(--ink-soft); font-size: var(--text-sm); margin: 1px 0 10px; }
.founder-card .bio { font-size: var(--text-sm); color: var(--ink-soft); margin: 0; }
.founder-card .bio p { margin: 0 0 8px; }

/* ---------- filters + grid ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.search-box {
  flex: 1 1 220px;
  max-width: 340px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input:focus { border-color: var(--vision); box-shadow: 0 0 0 3px rgba(35,90,173,.14); }
.search-box svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink-soft);
  pointer-events: none;
}

.chipset { display: flex; gap: 8px; flex-wrap: wrap; }

.filter-chip {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}
.filter-chip:hover { border-color: rgba(31,39,50,.34); }
.filter-chip.active { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.filter-chip.active.vision { background: var(--vision); border-color: var(--vision); }
.filter-chip.active.legacy { background: var(--legacy); border-color: var(--legacy); }

.count-note { color: var(--ink-soft); font-size: var(--text-sm); margin-left: auto; }

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  padding-bottom: 20px;
}

.player-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: transform .14s, box-shadow .14s, border-color .14s;
  border-top: 3px solid transparent;
}
.player-card.vision { border-top-color: var(--vision); }
.player-card.legacy { border-top-color: var(--legacy); }
.player-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .02em;
  color: var(--cream);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar.big { width: 84px; height: 84px; font-size: 26px; }
.avatar.vision { background: var(--vision); }
.avatar.legacy { background: var(--legacy); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.player-card .pc-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.player-card .pc-town { color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; }

.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 5px;
}
.tag.vision { color: var(--vision); background: rgba(35,90,173,.1); }
.tag.legacy { color: var(--legacy); background: rgba(61,117,66,.12); }
.tag.captain { color: var(--brown); background: rgba(120,83,54,.12); margin-left: 4px; }

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 0 60px;
}

/* ---------- player modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(24,30,39,.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--paper);
  border-radius: 18px;
  box-shadow: var(--shadow-pop);
  max-width: 520px;
  width: 100%;
  max-height: 84dvh;
  overflow-y: auto;
  padding: 30px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 0;
  background: var(--cream-dim);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 17px;
  color: var(--ink);
  line-height: 1;
}
.modal-close:hover { background: var(--line); }

.modal-head { display: flex; gap: 18px; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: var(--text-xl); letter-spacing: .04em; }
.modal-head .role { color: var(--brown); font-weight: 700; font-size: var(--text-sm); margin-top: 2px; }
.modal-head .town { color: var(--ink-soft); font-size: var(--text-sm); margin-top: 1px; }
.modal-bio p { margin: 0 0 10px; color: var(--ink-soft); font-size: 15px; }
.modal-bio .soon { font-style: normal; color: var(--ink-soft); background: var(--cream-dim); border-radius: 8px; padding: 12px 14px; font-size: 14px; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 56px;
  background: var(--ink);
  color: rgba(251,247,245,.75);
  text-align: center;
  padding: 30px 20px 34px;
  font-size: var(--text-sm);
}
.site-footer .motto {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--cream);
  letter-spacing: .1em;
  font-size: var(--text-lg);
  margin-bottom: 4px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 1.1rem; }
  .topnav a { padding: 7px 10px; font-size: 12px; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .book-stage { padding: 8px 2px; }
  .flip-zone { width: 34px; }
  .flip-zone svg { width: 26px; height: 26px; }
  .controls { gap: 6px; padding: 8px 8px 12px; }
  .ctrl-btn { padding: 7px 11px; font-size: 12.5px; }
  .ctrl-btn .btn-label { display: none; }
  .page-indicator { min-width: 64px; font-size: 12.5px; }
  #map { height: 380px; }
  .dir-hero { padding-top: 30px; }
  .founder-card { flex-direction: column; }
  .modal { padding: 22px; }
}
