/* RHCES Flip Books — app styles */
:root {
  --bg: #0f1115;
  --bg-soft: #151821;
  --panel: #1b1e26;
  --panel-2: #222633;
  --line: #2a2f3a;
  --text: #eef0f4;
  --muted: #9aa1ad;
  --accent: #e8b64c;
  --accent-deep: #c99732;
  --danger: #e2574b;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: radial-gradient(1400px 800px at 50% -10%, #1a1e28, var(--bg));
  color: var(--text);
  font: 15px/1.5 system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px clamp(16px, 4vw, 40px);
}
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.logo svg { width: 34px; height: 34px; }
.logo .word {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px; font-weight: 700; letter-spacing: .4px;
}
.logo .word em { color: var(--accent); font-style: normal; }
.logo .sub { display: block; font: 11px/1 system-ui, sans-serif; color: var(--muted); letter-spacing: 2.5px; text-transform: uppercase; margin-top: 3px; }
.site-header .spacer { flex: 1; }

/* ---------- hero + dropzone ---------- */
.hero { text-align: center; padding: clamp(16px, 4vh, 48px) 20px 8px; }
.hero h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 4.5vw, 44px);
  line-height: 1.15; font-weight: 700; letter-spacing: .3px;
}
.hero h1 em { color: var(--accent); font-style: italic; }
.hero p { color: var(--muted); margin-top: 10px; font-size: clamp(14px, 1.6vw, 17px); }

.dropzone {
  margin: 28px auto 0; width: min(680px, calc(100% - 40px));
  border: 2px dashed #3a4150; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .02), rgba(255, 255, 255, 0));
  padding: clamp(24px, 5vh, 48px) 24px;
  text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent); background: rgba(232, 182, 76, .05);
}
.dropzone.dragover { transform: scale(1.01); }
.dropzone .dz-icon { font-size: 40px; }
.dropzone h2 { font-size: 19px; margin-top: 10px; font-weight: 600; }
.dropzone p { color: var(--muted); margin-top: 6px; font-size: 14px; }
.dropzone .dz-actions { margin-top: 18px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 18px; cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #1a1405; font-weight: 600;
}
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #1a1405; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------- library ---------- */
.library { width: min(1100px, calc(100% - 40px)); margin: 40px auto 60px; flex: 1; }
.library h3 {
  font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 20px;
}
.book-grid {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.book-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s;
  display: flex; flex-direction: column;
}
.book-card:hover { transform: translateY(-3px); border-color: #3a4150; }
.book-card .cover {
  aspect-ratio: 3 / 4; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.book-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card .meta { padding: 12px 14px; }
.book-card .meta .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-card .meta .s { color: var(--muted); font-size: 12px; margin-top: 3px; }
.book-card .row { display: flex; gap: 8px; padding: 0 12px 12px; }
.empty-lib { color: var(--muted); text-align: center; padding: 30px 0; }

.site-footer { text-align: center; color: #566; color: var(--muted); font-size: 13px; padding: 24px; opacity: .7; }

/* ---------- progress overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 16, .82);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 60;
}
.dialog {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); width: min(440px, calc(100% - 40px)); padding: 26px;
}
.dialog h3 { font-size: 18px; margin-bottom: 6px; }
.dialog p { color: var(--muted); font-size: 14px; }
.progress-bar {
  height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 18px 0 8px;
}
.progress-bar i {
  display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  border-radius: 99px; transition: width .2s;
}
.dialog .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.dialog label.opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; margin-top: 10px;
}
.dialog label.opt:has(input:checked) { border-color: var(--accent); }
.dialog label.opt b { display: block; font-size: 14px; }
.dialog label.opt span { color: var(--muted); font-size: 13px; }
.dialog input[type="text"] {
  width: 100%; background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; margin-top: 12px; font: inherit;
}
.dialog input[type="text"]:focus { outline: none; border-color: var(--accent); }

/* ---------- viewer ---------- */
#viewer { position: fixed; inset: 0; background: radial-gradient(1200px 700px at 50% 20%, #1a1e28, var(--bg)); display: flex; flex-direction: column; z-index: 40; }
.v-top {
  display: flex; align-items: center; gap: 10px; padding: 10px clamp(10px, 2vw, 20px);
  flex: 0 0 auto; min-width: 0;
}
.v-top .v-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.v-top .spacer { flex: 1; }
.ctl {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; min-width: 38px; height: 38px; padding: 0 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px;
  flex: 0 0 auto;
}
.ctl:hover { border-color: var(--accent); color: var(--accent); }
.ctl:disabled { opacity: .4; cursor: default; }
.ctl:disabled:hover { border-color: var(--line); color: var(--text); }
.ctl.active { border-color: var(--accent); color: var(--accent); }
.v-zoom-label { color: var(--muted); font-size: 13px; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }

.v-body { flex: 1; display: flex; min-height: 0; position: relative; }
#stageHost { flex: 1; min-width: 0; position: relative; }

.v-bottom {
  display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(12px, 3vw, 24px) 16px; flex: 0 0 auto;
}
#pageSlider { flex: 1; accent-color: var(--accent); min-width: 0; }
#pageLabel { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }

/* thumbnails drawer */
.thumbs {
  width: 0; overflow: hidden; transition: width .25s ease; flex: 0 0 auto;
  background: var(--bg-soft); border-right: 1px solid var(--line);
}
.thumbs.open { width: 168px; }
.thumbs-inner { width: 168px; height: 100%; overflow-y: auto; padding: 12px; }
.thumb {
  border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer;
  margin-bottom: 10px; background: var(--panel-2); position: relative;
}
.thumb img { width: 100%; display: block; min-height: 40px; }
.thumb .n {
  position: absolute; right: 4px; bottom: 4px; background: rgba(0, 0, 0, .65);
  font-size: 11px; padding: 1px 7px; border-radius: 99px; color: #fff;
}
.thumb.current { border-color: var(--accent); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 12px 18px; font-size: 14px; opacity: 0;
  transition: opacity .25s, transform .25s; z-index: 100; pointer-events: none;
  max-width: min(480px, calc(100vw - 40px)); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .v-top .v-hide-sm { display: none; }
  .thumbs.open { width: 132px; }
  .thumbs-inner { width: 132px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
