/* Origami Text Web Reader — chrome styles.
   The document itself renders inside an iframe with the EPUB's own CSS. */

:root {
  --paper: #faf8f4;
  --ink: #201f1c;
  --ink-2: #6c6862;
  --hairline: #ded9d0;
  --surface: #ffffff;
  --accent: #35569e;
  --accent-soft: rgba(53, 86, 158, 0.14);
  --lift-shadow: 0 6px 14px rgba(32, 31, 28, 0.22);
  font-size: 16px;
}
html.dark {
  --paper: #161616;
  --ink: #e7e4de;
  --ink-2: #9b978f;
  --hairline: #3a3a3a;
  --surface: #2b2b2b;      /* a shade above black, never pure black on black */
  --accent: #8aa4e3;
  --accent-soft: rgba(138, 164, 227, 0.18);
  --lift-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Seravek, "Avenir Next", -apple-system, "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
.view[hidden] { display: none; }

/* ---------- shared small controls ---------- */
.quiet-btn, .quiet-select {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  color: var(--ink-2);
}
.quiet-btn:hover { color: var(--ink); border-color: var(--ink-2); }
.quiet-btn:focus-visible, .quiet-select:focus-visible,
.foot-find:focus-visible, .foot-back:focus-visible, .aside-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.file-btn { display: inline-block; }

/* ---------- Articles: a contents page, not a card grid ---------- */
#view-articles {
  max-width: 44rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}
.articles-head h1 {
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.2rem;
}
.venue-sub { margin: 0 0 1rem; color: var(--ink-2); }
.articles-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 2rem; }

.drop-hint {
  border: 1px dashed var(--hairline);
  border-radius: 10px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--ink-2);
}
body.dragging .drop-hint, body.dragging #view-articles { outline: 2px dashed var(--accent); outline-offset: -6px; }

.articles-list { list-style: none; margin: 0; padding: 0; }
.articles-list li {
  border-top: 1px solid var(--hairline);
  padding: 0.9rem 0.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.75rem;
  cursor: pointer;
}
.articles-list li:last-child { border-bottom: 1px solid var(--hairline); }
.articles-list li:hover .a-title { color: var(--accent); }
.a-title { font-weight: 600; grid-column: 1; }
.a-meta { grid-column: 1; color: var(--ink-2); font-size: 0.9rem; }
.a-flags { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--accent); font-size: 0.85rem; white-space: nowrap; }
li.pinned .a-title::before { content: "\2022\00a0"; color: var(--accent); }

.articles-foot { margin-top: 2rem; text-align: center; }
.aside-pill {
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  padding: 0.35rem 1.1rem;
  cursor: pointer;
  color: var(--ink-2);
}
.aside-list { margin-top: 1rem; opacity: 0.6; text-align: left; }

/* ---------- Map ---------- */
.view-map { position: fixed; inset: 0; display: flex; flex-direction: column; }
.map-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  touch-action: none;
  background: var(--paper);
}
.map-canvas {
  position: absolute;
  left: 0; top: 0;
  width: 4600px; height: 3400px;
  transform-origin: 0 0;
}

.map-card {
  position: absolute;
  width: 168px;
  background: var(--surface);
  border: 1px solid var(--ink-2);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: box-shadow 150ms ease, translate 150ms ease, opacity 200ms ease;
}
.map-card .c-title {
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.map-card .c-authors {
  font-size: 0.72rem;
  color: var(--ink-2);
  margin-top: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.map-card.pinned { border: 1.5px solid var(--accent); }
.map-card.pinned::after {
  content: "\1F4CC";
  position: absolute; top: 4px; right: 6px;
  font-size: 0.62rem;
  filter: grayscale(1) opacity(0.85);
}
.map-card.aside { opacity: 0.45; }
.map-card.lifted {
  box-shadow: var(--lift-shadow);   /* the card's frame only — never per-glyph */
  translate: -2px -2px;
  cursor: grabbing;
  z-index: 30;
}
.map-card.match {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--lift-shadow);
  z-index: 20;
}
.map-card.recede { opacity: 0.25; }
.map-card.aside.recede { opacity: 0.18; }

/* ---------- foot bar (map) and read bar ---------- */
.foot-bar, .read-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.75rem;
  padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hairline);
  background: var(--paper);
}
.read-bar { border-top: none; border-bottom: 1px solid var(--hairline); padding-bottom: 0.4rem; }
.foot-back {
  border: none;
  background: none;
  font-size: 1.6rem;
  line-height: 1;
  padding: 0 0.5rem;
  cursor: pointer;
  color: var(--ink-2);
}
.foot-back:hover { color: var(--ink); }
.foot-find {
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  padding: 0.3rem 0.9rem;
  min-width: 0;
  width: min(22rem, 50vw);
  margin: 0 auto;
}
.foot-spacer { width: 2.6rem; }
.read-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
  font-size: 0.9rem;
}
.read-find { margin: 0; width: min(16rem, 34vw); }
.find-count { color: var(--ink-2); font-size: 0.8rem; min-width: 3.2rem; }

.view-reader { position: fixed; inset: 0; display: flex; flex-direction: column; }
.read-foot { flex-wrap: wrap; gap: 0.5rem; }
.read-foot .read-title { flex: 0 1 auto; max-width: 22ch; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; opacity: 0.6; font-size: 0.85rem; }
.read-foot .read-find { flex: 1 1 8rem; min-width: 6rem; }
.read-frame { flex: 1; border: none; width: 100%; background: var(--paper); }

/* ---------- context menu ---------- */
.ctx-menu {
  position: fixed;
  list-style: none;
  margin: 0; padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: var(--lift-shadow);
  z-index: 60;
  min-width: 10rem;
}
.ctx-menu li {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}
.ctx-menu li:hover { background: var(--accent-soft); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 4.2rem;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  box-shadow: var(--lift-shadow);
  z-index: 80;
}

@media (prefers-reduced-motion: reduce) {
  .map-card { transition: none; }
}
@media (max-width: 640px) {
  .read-find { width: 8rem; }
  .quiet-select { display: none; }
}
