/* Gilgamesh parallel-translation viewer — styles. Vanilla, no build. */

:root {
  --bg: #f7f4ee;
  --panel: #fffdf8;
  --ink: #2a2520;
  --ink-soft: #6b6358;
  --line: #e2d9c8;
  --line-strong: #cdbfa6;
  --accent: #8a5a2b;
  --shadow: 0 1px 3px rgba(60, 45, 20, 0.08);

  /* per-source accent colors (swatches + column tint) */
  --c-dyakonov: #a33b3b;
  --c-gumilyov: #c77d2e;
  --c-thompson: #2f6f5e;
  --c-kovacs: #3a5a99;
  --c-kovacs_ru: #6b3fa0;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", "PT Serif", serif;
  line-height: 1.55;
}

/* ---- Header ---- */
.site-header {
  background: linear-gradient(180deg, #3a2f22, #4a3c2a);
  color: #f4ead6;
  padding: 1.4rem 1rem 1.2rem;
  text-align: center;
}
.header-inner { max-width: none; margin: 0 auto; }
.site-header h1 { margin: 0; font-size: 1.5rem; letter-spacing: 0.01em; font-weight: 600; }
.tagline { margin: 0.35rem 0 0; color: #d8c7a8; font-size: 0.95rem; font-style: italic; }

/* ---- Toolbar (sticky controls) ---- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--panel);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}
.toolbar-inner {
  max-width: none;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
}
.control-group { display: flex; align-items: center; gap: 0.5rem; }
.control-group > label,
.control-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
}
#chapter-select {
  font-family: Georgia, serif;
  font-size: 0.95rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  max-width: 60vw;
}

/* Sources dropdown (hover/focus/click to open) */
.dropdown { position: relative; }
.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-family: system-ui, sans-serif;
}
.dropdown-trigger:hover { border-color: var(--accent); }
.dropdown-trigger .control-label { cursor: pointer; }
.dropdown-count { font-size: 0.78rem; color: var(--ink-soft); font-family: system-ui, sans-serif; }
.dropdown-trigger .caret { font-size: 0.7rem; color: var(--ink-soft); }

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  z-index: 40;
  min-width: 15rem;
  display: none;        /* shown on hover / focus-within / .open */
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(60, 45, 20, 0.18);
}
/* keep a hover bridge so moving cursor from trigger to menu doesn't close it */
.dropdown::after { content: ""; position: absolute; top: 100%; left: 0; right: 0; height: 6px; }
.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu,
.dropdown.open .dropdown-menu { display: flex; }

.source-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  font-family: system-ui, sans-serif;
  white-space: nowrap;
}
.source-toggle:hover { background: rgba(138, 90, 43, 0.09); }
.source-toggle input { accent-color: var(--accent); margin: 0; }
.toggle-text { display: inline-flex; align-items: baseline; gap: 0.4rem; }
.toggle-name { font-size: 0.9rem; }
.toggle-year { font-size: 0.72rem; color: var(--ink-soft); }

/* color swatches */
.swatch {
  width: 0.7rem; height: 0.7rem; border-radius: 50%;
  display: inline-block; flex: 0 0 auto;
}
.swatch-dyakonov { background: var(--c-dyakonov); }
.swatch-gumilyov { background: var(--c-gumilyov); }
.swatch-thompson { background: var(--c-thompson); }
.swatch-kovacs   { background: var(--c-kovacs); }
.swatch-kovacs_ru { background: var(--c-kovacs_ru); }

/* ---- Main ---- */
main {
  max-width: none;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}
.chapter-title {
  font-size: 1.35rem;
  margin: 1rem 0 0.2rem;
  color: var(--accent);
}
.chapter-sub { color: var(--ink-soft); font-style: italic; font-size: 1rem; font-weight: normal; }
.heading-note {
  margin: 0.1rem 0 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
}

/* ---- Parallel view (CSS grid) ---- */
/* No overflow here: it would make this a scroll container and break the
   sticky column headers. Columns use minmax(0,1fr) so they never overflow. */
.table-wrap {}

/* Resizable view: full width by default; width set in px via the toolbar
   slider. Centered in the page. */
#view {
  position: relative;
  width: var(--view-width, 100%);
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.parallel-grid {
  display: grid;
  align-items: stretch;        /* cells fill the row height (no gap below short cells) */
  /* 1px column gaps over the grid's background read as column separators */
  background: var(--line-strong);
  column-gap: 1px;
  row-gap: 0;
}

/* Sticky, draggable column headers */
.col-head {
  position: sticky;
  top: var(--toolbar-h, 56px);
  z-index: 10;
  background: #efe7d6;
  border-bottom: 2px solid var(--line-strong);
  padding: 0.55rem 0.85rem 0.6rem;
  cursor: grab;
  user-select: none;
}
.col-head:active { cursor: grabbing; }
.col-head.dragging { opacity: 0.45; }
.col-head.drag-over { box-shadow: inset 4px 0 0 var(--accent); background: #e7dcc4; }
.col-head .grip-dots { color: var(--line-strong); font-size: 0.8rem; margin-right: 0.35rem; }
/* one-line header: grip + author name + year, truncating in narrow columns */
.col-head {
  display: flex;
  align-items: baseline;
  gap: 0.1rem;
  white-space: nowrap;
}
.col-head .src-name {
  font-size: 0.95rem; font-weight: 600; font-family: system-ui, sans-serif;
  overflow: hidden; text-overflow: ellipsis;
}
.col-head .src-year {
  flex: 0 0 auto;
  font-size: 0.78rem; font-weight: normal;
  color: var(--ink-soft); font-family: system-ui, sans-serif;
}
.col-head.col-dyakonov { border-top: 3px solid var(--c-dyakonov); }
.col-head.col-gumilyov { border-top: 3px solid var(--c-gumilyov); }
.col-head.col-thompson { border-top: 3px solid var(--c-thompson); }
.col-head.col-kovacs   { border-top: 3px solid var(--c-kovacs); }
.col-head.col-kovacs_ru { border-top: 3px solid var(--c-kovacs_ru); }

/* Small section-title line, spanning all columns, before each section's cells */
.section-title {
  grid-column: 1 / -1;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: #efe7d6;
  border-top: 1px solid var(--line-strong);
  padding: 0.3rem 0.85rem;
  text-align: center;
}
.section-title .section-num {
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.5rem;
}
.section-title .section-ref { font-style: italic; }

.cell {
  background: var(--panel);
  padding: 0.55rem 0.85rem 0.7rem;
}
.cell p { margin: 0 0 0.5rem; }
.cell p:last-child { margin-bottom: 0; }
.cell[lang="ru"] { hyphens: none; }
.cell[lang="en"] { hyphens: auto; }
.cell-empty {
  color: #b6ab98;
  text-align: center;
  font-style: italic;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 6px,
      rgba(180, 168, 145, 0.16) 6px, rgba(180, 168, 145, 0.16) 12px),
    var(--panel);
}

/* Width slider (toolbar) */
#width-control input[type="range"] {
  width: 9rem;
  max-width: 40vw;
  accent-color: var(--accent);
  cursor: ew-resize;
}

/* ---- Footer / attribution ---- */
.site-footer {
  max-width: none;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  border-top: 1px solid var(--line-strong);
  color: var(--ink-soft);
}
.site-footer h3 { color: var(--ink); margin: 0 0 0.5rem; font-size: 1rem; }
.attr-list { list-style: none; padding: 0; margin: 0 0 1rem; font-size: 0.9rem; }
.attr-list li { margin: 0.35rem 0; }
.attr-list .swatch { margin-right: 0.3rem; vertical-align: middle; }
.attr-list a { color: var(--accent); }
.footer-meta { font-size: 0.82rem; font-style: italic; }
.empty-note { color: var(--ink-soft); font-style: italic; padding: 1.5rem 0; text-align: center; }

/* ---- Responsive ---- */
@media (max-width: 680px) {
  .site-header h1 { font-size: 1.15rem; }
  .toolbar-inner { gap: 0.6rem 1rem; }
  .cell { font-size: 0.95rem; }
  #chapter-select { max-width: 75vw; }
}
