/* Gabriel Landini's Voynich Eva Hand 1 fonts.
   EVA2.ttf — 2025 update, from https://voynich.nu/Fonts/EVA2.ttf
   EVA1.ttf — original 1998 release, from evah1_1.zip
   Non-commercial research use per voynich.nu/roadmap.html#fonts.
   Encoding: direct ASCII — 'a' at U+0061, 'c' at U+0063, 'h' at U+0068 etc.
   High-ASCII range U+0080-U+00FF is used for rare extended glyphs.
   Combined font stack — EVA2 primary + EVA1 fallback — gives us ~72 of the
   98 @NNN; rare extended glyph codes used in the STA alphabet. */
@font-face {
  font-family: "EvaHand1";
  src: url("EVA2.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "EvaHand1Fallback";
  src: url("EVA1.ttf") format("truetype");
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, ui-sans-serif, system-ui, sans-serif; background: #1a2333; color: #e2eaf4; height: 100%; }

/* Tab switcher at the very top of the page */
nav.tab-bar { display: flex; gap: 4px; padding: 6px 10px; background: #141e2c; border-bottom: 1px solid #2a3a50; position: sticky; top: 0; z-index: 20; }
nav.tab-bar .tab-btn { background: #1e2d40; color: #8fa8c0; border: 1px solid #2a3a50; padding: 6px 14px; border-radius: 3px 3px 0 0; cursor: pointer; font-size: 0.85em; }
nav.tab-bar .tab-btn:hover { background: #243347; color: #d0dcea; }
nav.tab-bar .tab-btn.active { background: #0f1a26; color: #90d4a0; border-color: #3a5a7a; border-bottom-color: #0f1a26; font-weight: 500; }

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Generic reader home */
#tab-0 {
  min-height: calc(100vh - 46px);
  padding: 24px 20px 28px;
  background:
    radial-gradient(circle at top right, rgba(60, 100, 160, 0.25), transparent 34%),
    radial-gradient(circle at left center, rgba(40, 110, 100, 0.18), transparent 30%),
    linear-gradient(180deg, #151f2e 0%, #1a2a3a 100%);
}
.reader-home {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.reader-home-hero {
  padding: 26px 24px;
  border: 1px solid #2e4060;
  border-radius: 14px;
  background: rgba(22, 32, 48, 0.92);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.20);
}
.reader-home-eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: #8fb7dd;
  font-size: 11px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}
.reader-home-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1.05;
}
.reader-home-hero p {
  margin: 0;
  max-width: 760px;
  color: #b8c4d4;
  line-height: 1.6;
}
.reader-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.reader-home-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px;
  border: 1px solid #2a3d55;
  border-radius: 12px;
  background: rgba(20, 30, 45, 0.94);
}
.reader-home-card h2 {
  margin: 0;
  font-size: 1rem;
}
.reader-home-card p {
  margin: 0;
  color: #b8c8da;
  line-height: 1.55;
  font-size: 0.92rem;
}
.reader-home-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.reader-home-actions label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #8fa0b6;
  font-size: 0.82rem;
}
.reader-home-actions input {
  min-width: 84px;
}
.reader-home-actions select {
  max-width: 160px;
  min-width: 80px;
}
.reader-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #35546d;
  color: #dfeaf3;
  background: #203244;
  text-decoration: none;
  font-size: 0.85rem;
}
.reader-home-link:hover {
  background: #29425a;
}
.reader-home-commands {
  padding: 18px 18px 16px;
  border: 1px solid #252c3d;
  border-radius: 12px;
  background: rgba(13, 15, 21, 0.94);
}
.reader-home-commands h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #d5deea;
}
.reader-home-commands ul {
  margin: 0;
  padding-left: 18px;
  color: #9dadbf;
  line-height: 1.65;
}

header { padding: 10px 14px; border-bottom: 1px solid #333; background: #101014; position: sticky; top: 34px; z-index: 10; }
header h1 { margin: 0 0 6px 0; font-size: 1.05em; }
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: 0.85em; }
.controls.small { font-size: 0.78em; color: #aaa; }
button { background: #262630; color: #e8e8ea; border: 1px solid #444; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 0.82em; }
button:hover { background: #33333f; }
button.active { background: #3a6; border-color: #5c8; color: #fff; }
input[type="text"], input:not([type]) { background: #101014; color: #e8e8ea; border: 1px solid #444; padding: 4px 6px; border-radius: 3px; font-family: ui-monospace, monospace; }
.legend { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78em; color: #bbb; }
.sw { display: inline-block; width: 12px; height: 12px; border: 1px solid #000; }
.sw.raw    { background: rgba(255,100,100,0.35); border-color: #e55; }
.sw.fit    { background: rgba(100,220,120,0.35); border-color: #4c6; }
.sw.anchor-v { background: #ff4; }
.sw.anchor-b { background: #4cf; }
.hint { color: #fc6; }
.hint-inline { color: #9c9; font-size: 0.82em; font-style: italic; }
#line-list li.selected { background: #253; color: #cfe; border-left: 3px solid #3a6; }
#line-list li.ok { color: #8d8; }
#line-list li.partial { color: #cc7; }
#line-list li.excluded { color: #666; }
#line-list li .count { color: #888; font-size: 0.9em; }

#active-line-display { font-family: ui-monospace, monospace; font-size: 0.9em; }
#active-line-display .tok { padding: 2px 5px; margin: 0 1px; border-radius: 3px; }
#active-line-display .tok.current { background: #fc6; color: #111; font-weight: bold; }
#active-line-display .tok.done { color: #6c6; text-decoration: line-through; }
#active-line-display .tok.pending { color: #aaa; }

#zoom { vertical-align: middle; }
#zoom-display { color: #9c9; font-family: ui-monospace, monospace; font-size: 0.85em; min-width: 3em; }

main { display: grid; grid-template-columns: 1fr 320px; height: calc(100vh - 120px); }
#canvas-wrap { overflow: auto; background: #0a0a0c; padding: 4px; }
#canvas { display: block; background: #222; cursor: crosshair; }
#sidebar { border-left: 1px solid #333; padding: 10px 12px; overflow-y: auto; background: #141418; }
#sidebar h2 { font-size: 0.85em; text-transform: uppercase; letter-spacing: 1px; color: #8c8; border-bottom: 1px solid #333; padding-bottom: 4px; margin-top: 16px; }
#sidebar h2:first-child { margin-top: 0; }
#line-list, #anchor-list { list-style: none; padding: 0; margin: 0; font-family: ui-monospace, monospace; font-size: 0.75em; }
#line-list li, #anchor-list li { padding: 3px 6px; border-bottom: 1px solid #222; cursor: pointer; }
#line-list li:hover { background: #22222a; }
#line-list li.flagged { color: #fc6; }
#line-list li.excluded { color: #666; }
#line-list li.ok { color: #9d9; }
pre { background: #0a0a0c; border: 1px solid #333; padding: 6px 8px; font-size: 0.75em; color: #9c9; white-space: pre-wrap; word-break: break-all; }
#line-count-badge { font-size: 0.8em; color: #888; font-weight: normal; }

/* =============================================================== */
/* Tab 2 — Glyph Cross-Reference                                  */
/* =============================================================== */
#tab-2 main { display: grid; grid-template-columns: 1fr 420px; height: calc(100vh - 220px); }
#tab-2 #g-canvas-wrap { overflow: auto; background: #0a0a0c; padding: 4px; }
#tab-2 #g-canvas { display: block; background: #222; cursor: crosshair; }
#tab-2 #g-sidebar { border-left: 1px solid #333; padding: 10px 12px; overflow-y: auto; background: #141418; }
#tab-2 #g-sidebar h2 { font-size: 0.85em; text-transform: uppercase; letter-spacing: 1px; color: #8c8; border-bottom: 1px solid #333; padding-bottom: 4px; margin-top: 16px; }
#tab-2 #g-sidebar h2:first-child { margin-top: 0; }

#g-active-display { font-family: ui-monospace, monospace; font-size: 0.92em; }
#g-active-display .eva-current { background: #fc6; color: #111; padding: 3px 8px; border-radius: 3px; font-weight: bold; }
#g-active-display .eva-current-sta { background: #223; color: #9cf; padding: 3px 8px; border-radius: 3px; margin-left: 6px; font-size: 0.85em; }
#g-active-display .eva-current-shape { color: #aaa; font-style: italic; margin-left: 8px; }
#g-progress .sta-tag { color: #789; font-size: 0.85em; margin-left: 4px; }

/* Unlabeled-line mode button at top of the sidebar */
.line-mode-wrap { padding: 4px 0 8px 0; border-bottom: 1px dashed #333; margin-bottom: 6px; }
.line-mode-btn { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #1a2e2a; color: #bfe; border: 1px solid #2dd4bf; border-radius: 4px; cursor: pointer; font-family: ui-monospace, monospace; font-size: 0.9em; }
.line-mode-btn:hover { background: #224a42; }
.line-mode-btn.active { background: #2dd4bf; color: #042; font-weight: bold; border-color: #6fe; }
.line-mode-btn .line-mode-icon { font-size: 1.2em; }
.line-mode-btn .line-mode-label { flex: 1; text-align: left; }
.line-mode-btn .line-mode-count { background: rgba(0,0,0,0.3); padding: 2px 8px; border-radius: 10px; font-size: 0.8em; }
.line-mode-btn.active .line-mode-count { background: rgba(0,0,0,0.2); color: #042; }

/* Unlabeled-line rows in the progress panel */
#g-progress .line-section-header { margin-top: 10px; padding: 6px 4px; border-top: 1px solid #333; display: flex; justify-content: space-between; align-items: center; }
#g-progress .line-row { background: #121d1a; border: 1px solid #1e322c; border-radius: 3px; padding: 6px 8px; margin: 4px 0; cursor: pointer; }
#g-progress .line-row.selected { border-color: #ff4; background: #1c2a24; }
#g-progress .line-row:hover { background: #162420; }
#g-progress .line-row-head { display: flex; justify-content: space-between; font-family: ui-monospace, monospace; font-size: 0.72em; color: #789; margin-bottom: 4px; }
#g-progress .line-row-head .seq { font-weight: bold; }
#g-progress .line-row-head .bbox { color: #556; }
#g-progress .line-row .line-note { width: 100%; background: #08100e; color: #e8e8ea; border: 1px solid #2a3a34; padding: 3px 5px; border-radius: 2px; font-size: 0.75em; font-family: ui-monospace, monospace; }
#g-progress .line-row .line-note:focus { outline: none; border-color: #2dd4bf; }

#g-eva-list { display: flex; flex-direction: column; gap: 8px; }

.eva-filter-wrap { position: sticky; top: 0; background: #141418; padding: 6px 0 8px 0; z-index: 5; border-bottom: 1px solid #222; margin-bottom: 4px; }
.eva-filter { width: 100%; background: #08080a; color: #e8e8ea; border: 1px solid #444; padding: 5px 8px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.85em; }
.eva-filter:focus { outline: none; border-color: #6c6; }
.eva-filter-hint { font-size: 0.7em; color: #666; margin-top: 4px; font-style: italic; }

#g-eva-list .eva-group { border-top: 1px solid #1e1e24; padding-top: 6px; }
#g-eva-list .eva-group.collapsed .eva-buttons { display: none; }
#g-eva-list .eva-group-title { font-size: 0.72em; text-transform: none; letter-spacing: 0; color: #9ba; margin-bottom: 6px; cursor: pointer; padding: 2px 4px; user-select: none; border-radius: 3px; display: flex; align-items: center; gap: 6px; }
#g-eva-list .eva-group-title:hover { background: #22222e; color: #cdc; }
#g-eva-list .eva-group-title b { font-size: 1.1em; color: #cfc; margin-right: 2px; }
#g-eva-list .eva-fam-count { color: #666; margin-left: auto; font-size: 0.85em; }
#g-eva-list .eva-fam-toggle { color: #888; margin-left: 6px; font-size: 0.85em; }
#g-eva-list .family-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.4); flex-shrink: 0; }

#g-eva-list .eva-buttons { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 2px 4px 16px; }
#g-eva-list .eva-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-start; min-width: 56px; min-height: 56px; padding: 4px 8px 2px 8px; background: #f6f6ee; color: #111; border: 1px solid #2a2a34; border-radius: 4px; cursor: pointer; position: relative; line-height: 1; overflow: visible; }
#g-eva-list .eva-btn:hover { background: #fff; border-color: #888; }
#g-eva-list .eva-btn.active { background: #fc6; border-color: #fe8; }
#g-eva-list .eva-btn.has-boxes { border-color: #4a6; box-shadow: 0 0 0 1px #4a6 inset; }
#g-eva-list .eva-btn .eva-glyph {
  font-family: "EvaHand1", "EvaHand1Fallback", ui-monospace, monospace;
  font-size: 1.6em;
  line-height: 1.7;           /* give the font room for its full ascender/descender extent */
  color: #111;
  max-width: 120px;
  overflow: visible;           /* don't clip the glyph if it overflows its box */
  text-align: center;
  white-space: nowrap;
  display: block;
  margin-top: -2px;            /* nudge the glyph up within the button */
  flex: 0 0 auto;
}
#g-eva-list .eva-btn .eva-sta { font-size: 0.5em; color: #789; margin-top: 0; font-family: ui-monospace, monospace; flex: 0 0 auto; }
#g-eva-list .eva-btn.active .eva-sta { color: #553; font-weight: bold; }
#g-eva-list .eva-btn .eva-count { position: absolute; top: -7px; right: -7px; min-width: 18px; padding: 1px 5px; background: #4a6; color: #fff; border-radius: 9px; font-size: 0.65em; font-family: ui-monospace, monospace; display: none; border: 1px solid #141418; }
#g-eva-list .eva-btn.has-boxes .eva-count { display: block; }
#g-eva-list .eva-btn.active .eva-count { background: #111; color: #fc6; }
/* Fallback text shown when the glyph is a STA code (no eva rep available) */
#g-eva-list .eva-btn .eva-glyph.fallback { font-family: ui-monospace, monospace; font-size: 0.82em; color: #633; }
#g-eva-list .empty { color: #666; font-style: italic; padding: 8px; text-align: center; }
/* Use the Eva font on the active target display too */
#g-active-display .eva-current { font-family: "EvaHand1", "EvaHand1Fallback", ui-monospace, monospace; font-size: 1.4em; line-height: 1; }

#g-progress { font-family: ui-monospace, monospace; font-size: 0.78em; color: #9c9; max-height: 220px; overflow-y: auto; }
#g-progress .row { display: flex; justify-content: space-between; padding: 2px 4px; border-bottom: 1px solid #222; }
#g-progress .row .eva { color: #cfc; font-weight: bold; }
#g-progress .row .count { color: #ffa; }
#g-progress .empty { color: #666; font-style: italic; padding: 4px; }

@media (max-width: 700px) {
  nav.tab-bar {
    overflow-x: auto;
    padding-bottom: 4px;
  }
  nav.tab-bar .tab-btn {
    white-space: nowrap;
  }
  #tab-0 {
    padding: 18px 14px 22px;
  }
  .reader-home-hero,
  .reader-home-card,
  .reader-home-commands {
    padding-left: 14px;
    padding-right: 14px;
  }
}
