/* ============================================================
   Reading Room — comic reader theme
   Palette
     ink        #14161c   page-dark background
     panel      #1d2029   raised surfaces (bars)
     line       #2c3040   hairlines / borders
     paper      #e8e6e0   primary text (warm off-white)
     muted      #8a8f9c   secondary text
     amber      #f0b429   accent (newsprint gold)
   ============================================================ */

:root {
  --ink: #14161c;
  --panel: #1d2029;
  --line: #2c3040;
  --paper: #e8e6e0;
  --muted: #8a8f9c;
  --amber: #f0b429;
  --amber-dim: #b6871f;

  --bar-h: 60px;
  --controls-h: 56px;
  --radius: 10px;

  --font-display: "Archivo", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Masthead ---------- */
.masthead {
  height: var(--bar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 3;
}

.masthead__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Halftone dot mark — the signature detail */
.masthead__mark {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  background-color: var(--amber);
  background-image: radial-gradient(var(--ink) 32%, transparent 33%);
  background-size: 7px 7px;
  background-position: center;
}

.masthead__title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.masthead__controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding-left: 2px;
}

.select {
  appearance: none;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 34px 8px 12px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  max-width: 240px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a8f9c' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s;
}

.select:hover { border-color: #3a4056; }
.select:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(240, 180, 41, 0.25);
}
.select:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Stage (reading area) ---------- */
.stage {
  flex: 1 1 auto;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 40px;
  background:
    radial-gradient(circle at 50% 0%, rgba(240, 180, 41, 0.04), transparent 60%),
    var(--ink);
}

.page-wrap {
  display: none;
  margin: 0 auto;
  line-height: 0;
}
.page-wrap--visible { display: block; }

.viewer {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

/* ---------- Placeholder / status ---------- */
.placeholder {
  margin: auto;
  text-align: center;
  max-width: 420px;
  padding: 20px;
}

.placeholder__dots {
  width: 84px;
  height: 84px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background-color: rgba(240, 180, 41, 0.9);
  background-image: radial-gradient(var(--ink) 30%, transparent 31%);
  background-size: 12px 12px;
  background-position: center;
  opacity: 0.9;
}

.placeholder__heading {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.placeholder__text {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

.status {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 20px;
}
.status--hidden { display: none; }

.status__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--paper);
  margin: 0 0 6px;
}
.status__detail {
  font-size: 13px;
  word-break: break-all;
  margin: 0;
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid var(--line);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Controls ---------- */
.controls {
  min-height: var(--controls-h);
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 9px 18px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  z-index: 3;
}
.controls--hidden { display: none; }

.controls__group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn--text { font-size: 13px; font-weight: 600; }

.btn:hover:not(:disabled) { border-color: var(--amber); }
.btn:active:not(:disabled) { background: #0f1116; }
.btn:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(240, 180, 41, 0.25);
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.pageinfo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pageinfo__input {
  width: 52px;
  height: 38px;
  text-align: center;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.pageinfo__input:focus-visible {
  outline: none;
  border-color: var(--amber);
}
/* hide number spinners */
.pageinfo__input::-webkit-inner-spin-button,
.pageinfo__input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pageinfo__input { -moz-appearance: textfield; }

.pageinfo__sep { color: var(--line); }

.zoomlevel {
  min-width: 44px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .masthead {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .masthead__controls { gap: 8px; }
  .field { flex: 1; }
  .select { max-width: none; width: 100%; }
  .fitbtn-hide-mobile { display: none; }
  .controls { gap: 8px; padding: 0 10px; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  * { transition: none !important; }
}
