/* Unicode Presenter — graph-paper family aesthetic, dialed to tasteful */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #1e2430;
  --faint: #8a93a5;
  --line: #dfe3ea;
  --accent: #3b6ef6;
  --paper: #fdfdf8;
  --grid: rgba(59, 110, 246, 0.055);
  --panel: rgba(253, 253, 248, 0.92);
  --side-bg: rgba(255, 255, 255, 0.65);
  --card: #fff;
  --row-bg: rgba(255, 255, 255, 0.55);
  --hover: rgba(59, 110, 246, 0.08);
  --focus-ring: rgba(59, 110, 246, 0.15);
  --amber: #c98a00;
  --mono: "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* graph paper at night — set by the ◐ toggle (renderer.js) / OS preference */
:root[data-theme="dark"] {
  --ink: #e2e6ef;
  --faint: #7c86a0;
  --line: #262b36;
  --accent: #7aa0ff;
  --paper: #14161b;
  --grid: rgba(122, 160, 255, 0.05);
  --panel: rgba(20, 22, 27, 0.92);
  --side-bg: rgba(255, 255, 255, 0.03);
  --card: #1b1e25;
  --row-bg: rgba(255, 255, 255, 0.02);
  --hover: rgba(122, 160, 255, 0.10);
  --focus-ring: rgba(122, 160, 255, 0.20);
  --amber: #e5aa42;
  color-scheme: dark;
}

/* last-resort glyph coverage — used only on .fb cells, i.e. where the system
   already drew a blank box. Jigmo first so Han gets real outlines before pixel Unifont. */
@font-face { font-family: "Jigmo";         src: url("data/fonts/Jigmo.ttf"); }
@font-face { font-family: "Jigmo2";        src: url("data/fonts/Jigmo2.ttf"); }
@font-face { font-family: "Jigmo3";        src: url("data/fonts/Jigmo3.ttf"); }
@font-face { font-family: "Unifont";       src: url("data/fonts/unifont.otf"); }
@font-face { font-family: "Unifont Upper"; src: url("data/fonts/unifont_upper.otf"); }
.fb {
  font-family: "Jigmo", "Jigmo2", "Jigmo3", "Unifont", "Unifont Upper",
    -apple-system, sans-serif !important;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  display: flex; flex-direction: column;
}

/* top bar */
#topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-bottom: 2px solid var(--ink);
  background: var(--panel);
}
#brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
#mascot { font-family: var(--mono); font-size: 18px; }
#title { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
#subtitle { font-size: 11px; color: var(--faint); }
#tabs { display: flex; gap: 6px; }
.tab {
  font: inherit; font-size: 13px; padding: 5px 14px; cursor: pointer;
  border: 1.5px solid var(--ink); border-radius: 999px; background: transparent;
}
.tab.active { background: var(--ink); color: var(--paper); }
#search {
  flex: 1; font: inherit; font-size: 14px; padding: 7px 12px;
  border: 1.5px solid var(--ink); border-radius: 8px;
  background: var(--card); color: var(--ink);
  outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
#theme-toggle, #glyph-toggle {
  font: inherit; font-size: 14px; line-height: 1; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
}
#theme-toggle:hover, #glyph-toggle:hover { border-color: var(--accent); color: var(--accent); }
#stats { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; }

/* layout */
main { flex: 1; display: flex; min-height: 0; }
.hidden { display: none !important; }

/* sidebar */
#sidebar, #emoji-side {
  width: 265px; overflow-y: auto; border-right: 1.5px solid var(--line);
  background: var(--side-bg); padding: 8px 0;
}
.blk {
  padding: 5px 14px; font-size: 12.5px; opacity: .45; transition: opacity .25s;
  display: flex; justify-content: space-between; gap: 8px; color: var(--faint);
}
.blk.sel { opacity: 1; color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); }
.blk .cnt { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.blk.pua { font-style: italic; }
/* timeline gloss (chrono order sidebar) — marginalia, not controls.
   Everything faint; the era passing the viewport gets a hair more presence. */
.era { padding: 6px 14px; opacity: .45; transition: opacity .25s; }
.era.sel { opacity: 1; box-shadow: inset 2px 0 0 var(--accent); }
.era-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 500; color: var(--faint); }
.era.sel .era-head { color: var(--ink); }
.era-head .cnt { font-family: var(--mono); font-size: 10.5px; font-weight: 400; }
.era-gloss { font-size: 10.5px; color: var(--faint); margin-top: 2px; line-height: 1.35; }

.side-label {
  display: block; padding: 10px 14px 4px; font-size: 10px;
  text-transform: uppercase; letter-spacing: 1px; color: var(--faint);
}
.filt {
  padding: 4px 14px; font-size: 12.5px; cursor: pointer;
  display: flex; justify-content: space-between;
}
.filt:hover { background: var(--hover); }
.filt.sel { background: var(--accent); color: #fff; }

/* virtualized list */
#listwrap, #emoji-listwrap { flex: 1; min-width: 0; position: relative; }
#scroller, #emoji-scroller { position: absolute; inset: 0; overflow-y: auto; }
#spacer, #emoji-spacer { width: 1px; }
#rows, #emoji-rows { position: absolute; top: 0; left: 0; right: 0; }

.row {
  height: 44px; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; border-bottom: 1px solid var(--line);
  cursor: pointer; background: var(--row-bg);
}
.row:hover { background: var(--hover); }
.row.mark { box-shadow: inset 3px 0 0 var(--accent); }
.glyph {
  width: 54px; min-width: 54px; text-align: center; font-size: 26px;
  line-height: 44px; overflow: hidden;
}
.cp { font-family: var(--mono); font-size: 11.5px; color: var(--accent); width: 84px; min-width: 84px; }
.nm { font-size: 13.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.age {
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  width: 96px; min-width: 96px; text-align: right; white-space: nowrap;
}
.badge {
  font-family: var(--mono); font-size: 9.5px; padding: 2px 7px;
  border: 1px solid var(--faint); border-radius: 999px; color: var(--faint);
  white-space: nowrap;
}
.badge.alias { border-color: var(--amber); color: var(--amber); }
.blkname { font-size: 10.5px; color: var(--faint); white-space: nowrap; }

/* emoji rows */
.erow .glyph { font-size: 24px; }
.erow .cp { width: auto; min-width: 84px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* installation config */
#install-view { justify-content: center; align-items: flex-start; overflow-y: auto; }
#install-config { max-width: 620px; margin: 48px auto; padding: 0 24px; }
#install-config h2 { font-size: 24px; margin-bottom: 10px; }
.install-blurb { font-size: 13.5px; color: var(--faint); margin-bottom: 26px; line-height: 1.5; }
.cfg-label {
  display: block; font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--faint); margin: 18px 0 7px;
}
.cfg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cfg-btn {
  font: inherit; font-size: 13px; padding: 6px 14px; cursor: pointer;
  border: 1.5px solid var(--ink); border-radius: 999px; background: transparent;
}
.cfg-btn.sel { background: var(--ink); color: var(--paper); }
.cfg-help { font-size: 12.5px; color: var(--faint); margin-top: 9px; font-style: italic; }
#cfg-speed { width: 260px; accent-color: var(--accent); }
#speed-readout { text-transform: none; letter-spacing: 0; }
#install-start {
  font: inherit; font-size: 15px; font-weight: 700; letter-spacing: 2px;
  margin-top: 28px; padding: 12px 44px; cursor: pointer;
  background: var(--ink); color: var(--paper);
  border: none; border-radius: 8px;
}
#install-start:hover { background: var(--accent); }

/* the stage */
#stage {
  position: fixed; inset: 0; z-index: 50; background: #000; color: #fff;
  overflow: hidden; cursor: none;
}
#stage-inner { position: absolute; inset: 0; }
#stage-caption {
  position: absolute; bottom: 22px; left: 0; right: 0; text-align: center;
  font-family: var(--mono); font-size: 12px; color: rgba(255,255,255,.35);
  letter-spacing: 1px;
}

/* crawl / temporal */
.mode-crawl #track {
  position: absolute; top: 50%; transform-origin: left center;
  white-space: nowrap; will-change: transform;
  display: flex; align-items: center; height: 0;
}
.mode-crawl .tick {
  font-size: 120px; line-height: 1; padding: 0 15px;
  display: inline-block; transform: translateY(-50%);
}
.mode-crawl .chapter {
  font-family: var(--mono); font-size: 30px; letter-spacing: 4px;
  color: #fff; border: 2px solid #fff; padding: 18px 28px; margin: 0 60px;
  display: inline-block; transform: translateY(-50%); white-space: nowrap;
}

/* museum */
.mode-museum { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; }
#mu-label {
  font-family: var(--mono); font-size: clamp(16px, 2.6vw, 34px);
  letter-spacing: 2px; color: #fff; text-align: center; padding: 0 40px;
  min-height: 1.4em;
}
#mu-glyph { font-size: clamp(160px, 38vh, 420px); line-height: 1.15; text-align: center; }
#mu-glyph.pop { animation: mu-pop .45s ease-out; }
@keyframes mu-pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }

/* apocalypse */
.mode-apoc {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr);
  height: 100%;
}
.tower {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.12);
}
.tower-glyph { font-size: clamp(80px, 16vh, 200px); line-height: 1.2; }
.tower-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 3px;
  color: rgba(255,255,255,.4); margin-top: 12px;
}

/* toast + status bar */
#toast {
  position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-family: var(--mono);
  font-size: 12.5px; padding: 8px 18px; border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0,0,0,.25); z-index: 10;
}
#statusbar {
  border-top: 1.5px solid var(--line); padding: 5px 16px;
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  background: var(--panel); white-space: nowrap; overflow: hidden;
}
