/* ============================================================
   Yakthung · components.css
   Page components: script chart, king cards & timeline, chapter
   cards, image slots, district map, stories, feature cards,
   clan directory.
   ============================================================ */

/* ---------- Sirijunga script chart (language page) ---------- */
.glyph-label {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(236, 225, 205, .55);
  margin: 0 0 18px;
}
.glyph-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.glyph-card {
  width: 78px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 4px;
  border: 1px solid rgba(236, 225, 205, .14);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(236, 225, 205, .03), transparent);
  transition: transform .3s cubic-bezier(.16, .85, .3, 1), border-color .3s, background .3s;
  cursor: default;
}
.glyph-card:hover {
  transform: translateY(-4px);
  border-color: rgba(200, 154, 62, .5);
  background: linear-gradient(180deg, rgba(200, 154, 62, .09), transparent);
}
.glyph-card .g { font-family: 'Noto Sans Limbu', serif; font-size: 30px; line-height: 1; color: #f1e3c8; }
.glyph-card .r { font-family: 'Space Mono', monospace; font-size: 11px; color: rgba(236, 225, 205, .82); }
.glyph-card .ipa { font-family: 'Space Mono', monospace; font-size: 9.5px; letter-spacing: .01em; color: rgba(200, 154, 62, .72); }
.glyph-card.is-archaic { opacity: .46; }
.glyph-card.is-archaic .r::after { content: ' †'; color: #c89a3e; }
.glyph-note {
  margin: 28px 0 0;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  line-height: 1.7;
  color: rgba(236, 225, 205, .5);
  max-width: 780px;
}
.glyph-note a { color: rgba(200, 154, 62, .85); text-underline-offset: 2px; }

@media (max-width: 520px) {
  .glyph-grid { gap: 9px; }
  .glyph-card { width: 64px; min-height: 88px; gap: 4px; padding: 8px 2px; }
  .glyph-card .g { font-size: 26px; }
  .glyph-card .ipa { font-size: 9px; }
}

/* ---------- Limbuwan kings — cards + timeline (cream sections) ---------- */
.lim-sublabel {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(36, 24, 17, .55);
  margin: 0 0 20px;
}
.lim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.lim-card {
  display: flex;
  flex-direction: column;
  min-height: 130px;
  padding: 16px 18px;
  border: 1px solid rgba(36, 24, 17, .14);
  border-radius: 13px;
  background: rgba(255, 250, 238, .45);
  transition: transform .3s cubic-bezier(.16, .85, .3, 1), border-color .3s, box-shadow .3s;
}
.lim-card:hover {
  transform: translateY(-4px);
  border-color: rgba(161, 66, 39, .5);
  box-shadow: 0 14px 30px rgba(60, 40, 22, .16);
}
.lim-card .idx { font-family: 'Space Mono', monospace; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: rgba(161, 66, 39, .6); margin-bottom: 10px; }
.lim-card .king-name { font-family: 'Marcellus', serif; font-size: 18px; line-height: 1.16; color: #241811; margin-bottom: 6px; }
.lim-card .realm { font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: .02em; color: #a14227; }
.lim-card .cap { font-family: 'Space Mono', monospace; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: rgba(36, 24, 17, .5); margin-top: auto; padding-top: 12px; }

.lim-time { position: relative; border-left: 2px solid rgba(161, 66, 39, .4); margin: 0; padding: 0 0 clamp(20px, 3vw, 28px); list-style: none; }
.lim-time li { position: relative; padding: 0 0 clamp(22px, 3vw, 32px) clamp(24px, 3vw, 36px); }
.lim-time li:last-child { padding-bottom: 0; }
/* Round event dots. Pseudo-elements aren't covered by the global border-box
   rule, so width:12 + 2px border renders a 16px box — left:-9 centres that on
   the 2px rule (left:-7 left it 2px to the right). */
.lim-time li::before {
  content: ''; position: absolute; left: -9px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #e7dcc4; border: 2px solid #a14227;
}
.lim-time li.is-fall::before { background: #a14227; }
.lim-time li.lim-era { padding-top: clamp(18px, 2.6vw, 30px); padding-bottom: clamp(14px, 2vw, 20px); }
.lim-time li.lim-era:first-child { padding-top: 0; }
/* Era headers and the closing cap share a 15px tilted square, centred on the
   rule (left:-8.5 → centre sits on the 2px line). */
.lim-time li.lim-era::before {
  left: -8.5px; top: 3px; width: 15px; height: 15px;
  border-radius: 2px; border: none; background: #a14227; transform: rotate(45deg);
}
/* Close the timeline with a tilted square that mirrors the opening era marker. */
.lim-time::after {
  content: ''; position: absolute; left: -8.5px; bottom: -7.5px;
  width: 15px; height: 15px; border-radius: 2px;
  background: #a14227; transform: rotate(45deg);
}
.lim-time .era { font-family: 'Space Mono', monospace; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; font-weight: 700; color: #a14227; }
.lim-time .yr { font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: rgba(161, 66, 39, .85); }
.lim-time .ev { font-family: 'Marcellus', serif; font-size: clamp(18px, 2.1vw, 24px); color: #241811; margin: 3px 0 5px; }
.lim-time .nt { font-size: clamp(14px, 1.5vw, 16px); line-height: 1.65; color: rgba(36, 24, 17, .76); max-width: 640px; text-wrap: pretty; }

@media (max-width: 520px) {
  .lim-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .lim-card { min-height: 116px; padding: 13px 14px; }
  .lim-card .king-name { font-size: 16px; }
}

/* kings detail card: stack the reign disc above the text on small phones */
@media (max-width: 520px) {
  #king-detail { flex-direction: column; align-items: flex-start; min-height: auto; }
  #king-detail > div:first-child { width: 84px !important; height: 84px !important; }
}

/* kings rail: allow horizontal scroll on narrow screens so 29 bars never
   overflow / squash into the page (was an overflow bug on mobile). */
@media (max-width: 720px) {
  /* wider tap targets, snap to taps, and a right-edge fade so the off-screen
     bars are discoverable as swipeable. */
  [data-kings-rail] {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    touch-action: pan-x;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent);
            mask-image: linear-gradient(90deg, #000 90%, transparent);
  }
  [data-king] { min-width: 36px !important; scroll-snap-align: center; }

  /* enlarge the inline glossary tap target without disturbing line flow */
  [data-term] { display: inline-block; padding: 6px 3px; margin: -6px 0; line-height: 1; }
}

/* ---------- Limbuwan district map ---------- */
/* the fetched-SVG slot keeps the map's aspect ratio so the cream panel
   doesn't collapse (or jump) while the file loads */
[data-map-slot] { position: relative; aspect-ratio: 1020 / 595; }
[data-map-slot] > svg { display: block; width: 100%; overflow: visible; }
.map-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 220px;
  padding: 30px;
  text-align: center;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  line-height: 1.8;
  color: rgba(36, 24, 17, .7);
}

/* tappable district selector for phones — the SVG cluster is too small to tap */
.district-chips { display: none; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.district-chip {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(36,24,17,.26);
  border-radius: 12px;
  background: rgba(255,252,244,.5);
  color: #2a1c12;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  letter-spacing: .03em;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.district-chip.is-active { background: #7a3b2e; color: #f3e8d2; border-color: #7a3b2e; }

@media (max-width: 720px) {
  .district-chips { display: flex; }
}

/* district detail card: stop overlapping the map, flow beneath it — across the
   whole small-tablet band, not just phones. */
@media (max-width: 900px) {
  #district-detail {
    position: static !important;
    width: auto !important;
    margin-top: 16px;
  }
}

/* tooltip becomes a bottom sheet on touch / small screens */
@media (max-width: 600px) {
  #glossary-tip {
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    max-width: none !important;
  }
}

/* ---------- image slots (figure placeholders that look intentional) ---------- */
.img-slot {
  position: relative;
  margin: 0;
  display: block;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(200,154,62,.16), transparent 60%),
    linear-gradient(135deg, #241811 0%, #1c140f 60%, #120c08 100%);
}
.img-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(125deg, rgba(236,225,205,.05) 0 2px, transparent 2px 22px);
  opacity: .5;
  pointer-events: none;
}
.img-slot__inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 22px;
}
.img-slot__glyph {
  font-family: 'Noto Sans Limbu', serif;
  font-size: clamp(34px, 6vw, 60px);
  color: rgba(232,192,105,.65);
  line-height: 1;
}
.img-slot__label {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(236,225,205,.5);
  max-width: 24ch;
  line-height: 1.7;
}
/* cream-section placeholders need darker ink */
.img-slot--cream {
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(161,66,39,.14), transparent 60%),
    linear-gradient(135deg, #d8c9a4 0%, #cabb92 60%, #bdac80 100%);
}
.img-slot--cream .img-slot__glyph { color: rgba(138,52,32,.7); }
.img-slot--cream .img-slot__label { color: rgba(36,24,17,.62); }
/* aspect-ratio fallback for engines without `aspect-ratio` (pre-2021): give the
   three ratio'd figures real height via a padding spacer so they don't collapse. */
@supports not (aspect-ratio: 1 / 1) {
  .img-slot[style*="aspect-ratio:4/5"]::before { content: ""; display: block; padding-top: 125%; }
  .img-slot[style*="aspect-ratio:5/4"]::before { content: ""; display: block; padding-top: 80%; }
}

/* When a real image is supplied (data-src wired by JS), it covers the slot */
.img-slot > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- chapter cards (home "explore") ---------- */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(248px, 1fr));
  gap: 16px;
}
.chapter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-height: 216px;
  padding: 26px 24px 22px;
  border: 1px solid rgba(236, 225, 205, .13);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(236, 225, 205, .035), transparent 70%);
  text-decoration: none;
  color: inherit;
  transition: transform .35s cubic-bezier(.16, .85, .3, 1), border-color .35s, box-shadow .35s;
}
.chapter-card:hover {
  transform: translateY(-5px);
  border-color: rgba(200, 154, 62, .55);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35), 0 0 0 1px rgba(200, 154, 62, .12);
}
.chapter-card__num {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: .24em;
  color: rgba(200, 154, 62, .75);
}
.chapter-card__glyph {
  font-family: 'Noto Sans Limbu', serif;
  font-size: 34px;
  line-height: 1;
  color: #e7c87f;
}
.chapter-card h3 {
  font-family: 'Marcellus', serif;
  font-weight: 400;
  font-size: 21px;
  margin: 0;
  color: #f1e3c8;
}
.chapter-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: rgba(236, 225, 205, .68);
}
.chapter-card__go {
  margin-top: auto;
  padding-top: 10px;
  font-family: 'Space Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(236, 225, 205, .55);
  transition: color .3s;
}
.chapter-card:hover .chapter-card__go { color: #e8c069; }

/* ---------- stories ---------- */
.story {
  position: relative;
  max-width: 840px;
  margin: 0 auto;
  padding: clamp(30px, 5vw, 48px) clamp(22px, 4vw, 46px);
  border: 1px solid rgba(236, 225, 205, .13);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(236, 225, 205, .03), transparent 60%);
}
.story + .story { margin-top: 24px; }
.story__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-family: 'Space Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #c89a3e;
  margin-bottom: 16px;
}
.story h2 {
  font-family: 'Marcellus', serif;
  font-weight: 400;
  font-size: clamp(24px, 3.4vw, 36px);
  line-height: 1.15;
  margin: 0 0 16px;
  color: #f1e3c8;
  text-wrap: balance;
}
.story p {
  margin: 0 0 14px;
  font-size: clamp(14.5px, 1.6vw, 17px);
  line-height: 1.78;
  color: rgba(236, 225, 205, .8);
  text-wrap: pretty;
}
.story p:last-child { margin-bottom: 0; }
.story .story__source {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(236, 225, 205, .1);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: .035em;
  color: rgba(236, 225, 205, .58);
}
.story__source a {
  color: #e8c069;
  text-decoration-color: rgba(232, 192, 105, .38);
  text-underline-offset: 3px;
}
.story__source a:hover { color: #f1d38a; }
.story--context {
  border-color: rgba(200, 154, 62, .35);
  background: radial-gradient(100% 140% at 0% 0%, rgba(200, 154, 62, .1), transparent 60%);
}
.story--soon {
  border-style: dashed;
  border-color: rgba(200, 154, 62, .35);
  text-align: center;
  background: none;
}

/* ---------- football feature cards ---------- */
.feature-duo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
}
.feature-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(26px, 3.4vw, 38px);
  border: 1px solid rgba(236, 225, 205, .14);
  border-radius: 18px;
  background:
    radial-gradient(120% 100% at 20% 0%, rgba(200, 154, 62, .08), transparent 55%),
    linear-gradient(180deg, rgba(236, 225, 205, .03), transparent 70%);
  transition: transform .35s cubic-bezier(.16, .85, .3, 1), border-color .35s;
}
.feature-card:hover { transform: translateY(-4px); border-color: rgba(200, 154, 62, .5); }
.feature-card__where {
  font-family: 'Space Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #c89a3e;
}
.feature-card h3 {
  font-family: 'Marcellus', serif;
  font-weight: 400;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.15;
  margin: 0;
  color: #f1e3c8;
}
.feature-card p {
  margin: 0;
  font-size: 15px;
  line-height: 1.72;
  color: rgba(236, 225, 205, .78);
  text-wrap: pretty;
}
.feature-card__fact {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(236, 225, 205, .1);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: .1em;
  color: rgba(232, 192, 105, .85);
}

/* ---------- clan directory ---------- */
.clan-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin: 0 0 30px;
}
.clan-toolbar input[type="search"] {
  flex: 1 1 260px;
  min-width: 0;
  max-width: 420px;
  font: 15px/1.4 'Hanken Grotesk', system-ui, sans-serif;
  color: #241811;
  background: rgba(255, 252, 244, .72);
  border: 1px solid rgba(36, 24, 17, .3);
  border-radius: 12px;
  padding: 13px 16px;
  transition: border-color .3s, background .3s;
}
.clan-toolbar input[type="search"]::placeholder { color: rgba(36, 24, 17, .45); }
.clan-toolbar input[type="search"]:focus {
  outline: none;
  border-color: #a14227;
  background: rgba(255, 252, 244, .95);
}
.clan-count {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(36, 24, 17, .6);
  white-space: nowrap;
}
.clan-none {
  display: none;
  padding: 34px 20px;
  border: 1px dashed rgba(161, 66, 39, .45);
  border-radius: 13px;
  text-align: center;
  font-size: 15px;
  color: rgba(36, 24, 17, .7);
}
.clan-none.is-visible { display: block; }
/* a clan card hidden by search */
.lim-card[data-clan][hidden] { display: none; }

/* compact clan cards — most entries are a bare recorded name */
.lim-card--clan { min-height: 0; padding: 15px 17px; }
.lim-card--clan .king-name { font-size: 17px; margin-bottom: 3px; }
.lim-card--clan .realm { font-size: 10.5px; }
.lim-card--clan .cap {
  margin-top: 8px;
  padding-top: 0;
  text-transform: none;
  letter-spacing: .02em;
  font-size: 11.5px;
  line-height: 1.6;
}
