/* ==========================================================================
   Guayaquil Bajo Asedio — Design tokens
   Concept: a captain's siege-log kept aboard a ship on the Guayas river.
   Dominant surface = night/indigo siege sky. Parchment appears only as
   "log pages" (cards), never as the app background. Wax-seal stamps mark
   station status, echoing the editorial APPROVED/PUBLISHED workflow.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,600;0,700;1,500&family=Source+Sans+3:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ink-night: #0b1220;
  --ink-night-2: #101a2e;
  --ink-night-3: #16223a;
  --parchment: #ede1c8;
  --parchment-dim: #ddccA4;
  --parchment-ink: #2a2013;
  --ember: #c1521c;
  --ember-bright: #e06a2c;
  --river: #2f6e62;
  --river-bright: #3f9484;
  --brass: #b08d3e;
  --brass-bright: #d4ac54;
  --alarm: #7a2c22;

  --font-display: 'Spectral', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;

  --radius-page: 4px;
  --radius-pill: 999px;
  --shadow-lift: 0 18px 40px -18px rgba(0,0,0,0.55);
  --shadow-soft: 0 8px 24px -12px rgba(0,0,0,0.45);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(ellipse at 50% -10%, #16233d 0%, var(--ink-night) 55%, #060a13 100%);
  color: var(--parchment);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font-family: inherit; }
a { color: inherit; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

::selection { background: var(--ember); color: var(--parchment); }

/* Visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---------------------------------------------------------------------- */
/* App shell                                                               */
/* ---------------------------------------------------------------------- */

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  padding-bottom: 84px;
  background-image:
    radial-gradient(1px 1px at 15% 8%, rgba(237,225,200,0.35) 0, transparent 60%),
    radial-gradient(1px 1px at 78% 22%, rgba(237,225,200,0.28) 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 40% 4%, rgba(237,225,200,0.4) 0, transparent 60%),
    radial-gradient(1px 1px at 92% 12%, rgba(237,225,200,0.3) 0, transparent 60%),
    radial-gradient(1px 1px at 60% 30%, rgba(237,225,200,0.2) 0, transparent 60%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(11,18,32,0.96) 60%, rgba(11,18,32,0.65));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(176,141,62,0.22);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-display);
}
.brand .mark { color: var(--ember-bright); font-size: 20px; }
.brand .word { font-weight: 600; font-size: 15px; letter-spacing: 0.02em; color: var(--parchment); }
.brand .sub { font-family: var(--font-mono); font-size: 10px; color: var(--brass-bright); letter-spacing: 0.14em; text-transform: uppercase; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(176,141,62,0.35);
  background: rgba(255,255,255,0.03);
  color: var(--parchment);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }
.icon-btn:active { transform: scale(0.94); }

main[data-view] {
  padding: 18px 18px 8px;
}

/* ---------------------------------------------------------------------- */
/* Typography helpers                                                     */
/* ---------------------------------------------------------------------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass-bright);
  display: flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before { content: ''; width: 14px; height: 1px; background: var(--brass-bright); display: inline-block; }

h1, h2, h3 { font-family: var(--font-display); margin: 0; color: var(--parchment); }
h1 { font-size: 26px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
p { line-height: 1.6; color: rgba(237,225,200,0.82); }
.lede { font-size: 15px; color: rgba(237,225,200,0.7); }

/* ---------------------------------------------------------------------- */
/* Hero / home                                                            */
/* ---------------------------------------------------------------------- */

.hero {
  position: relative;
  padding: 8px 0 22px;
}
.hero h1 { font-style: italic; }
.hero .accent { color: var(--ember-bright); font-style: normal; }

.river-map-wrap {
  position: relative;
  margin-top: 18px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #0e1830 0%, #0a1120 100%);
  border: 1px solid rgba(176,141,62,0.25);
  box-shadow: var(--shadow-lift);
}

.river-svg { display: block; width: 100%; height: auto; }

.station-pin {
  cursor: pointer;
}
.station-pin .seal-outer { transition: transform 0.2s ease; }
.station-pin:hover .seal-outer { transform: scale(1.08); }
.station-pin:active .seal-outer { transform: scale(0.96); }

.station-pin-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  fill: var(--parchment);
  opacity: 0.85;
}

/* ---------------------------------------------------------------------- */
/* Log page card ("parchment")                                            */
/* ---------------------------------------------------------------------- */

.log-page {
  background:
    repeating-linear-gradient(180deg, rgba(0,0,0,0.02) 0 2px, transparent 2px 34px),
    linear-gradient(160deg, var(--parchment) 0%, var(--parchment-dim) 100%);
  color: var(--parchment-ink);
  border-radius: var(--radius-page);
  padding: 18px 18px 20px;
  position: relative;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(42,32,19,0.15);
}
.log-page::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: var(--radius-page);
  box-shadow: inset 0 0 40px rgba(122,44,34,0.06);
  pointer-events: none;
}
.log-page h2, .log-page h3 { color: var(--parchment-ink); }
.log-page p { color: rgba(42,32,19,0.82); }
.log-page .eyebrow { color: var(--alarm); }
.log-page .eyebrow::before { background: var(--alarm); }

.card-stack { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px 22px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.15s ease;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, var(--ember-bright), var(--ember)); color: #fff5ea; box-shadow: 0 10px 24px -10px rgba(193,82,28,0.6); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }

.btn-ghost { background: rgba(255,255,255,0.04); color: var(--parchment); border: 1px solid rgba(237,225,200,0.25); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }

.btn-river { background: linear-gradient(135deg, var(--river-bright), var(--river)); color: #f2fbf8; }

.btn-on-parchment { background: var(--parchment-ink); color: var(--parchment); }
.btn-on-parchment.outline { background: transparent; color: var(--parchment-ink); border: 1.5px solid var(--parchment-ink); }

.btn-sm { padding: 9px 16px; font-size: 13px; width: auto; }

/* ---------------------------------------------------------------------- */
/* Status chips + wax seal states                                        */
/* ---------------------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid currentColor;
}
.chip.locked { color: #7c8aa3; }
.chip.available { color: var(--brass-bright); }
.chip.downloaded { color: var(--river-bright); }
.chip.completed { color: var(--ember-bright); }

/* ---------------------------------------------------------------------- */
/* AR / camera view                                                       */
/* ---------------------------------------------------------------------- */

.ar-stage {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
}
.ar-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.ar-scrim-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 16px 16px 40px;
  background: linear-gradient(180deg, rgba(0,0,0,0.75), transparent);
  z-index: 2;
}
.ar-scrim-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,0.8), transparent);
  z-index: 2;
}
.ar-hotspot {
  position: absolute;
  width: 52px; height: 52px;
  margin-left: -26px; margin-top: -26px;
  border-radius: 50%;
  border: 2px solid var(--brass-bright);
  background: rgba(11,18,32,0.55);
  color: var(--brass-bright);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  animation: pulseRing 2.4s ease-in-out infinite;
  z-index: 3;
}
.ar-hotspot.found { border-color: var(--river-bright); color: var(--river-bright); animation: none; }
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,172,84,0.45); }
  50% { box-shadow: 0 0 0 10px rgba(212,172,84,0); }
}

.ar-progress-track {
  height: 6px; border-radius: 3px; background: rgba(255,255,255,0.15); overflow: hidden;
}
.ar-progress-fill { height: 100%; background: linear-gradient(90deg, var(--river-bright), var(--brass-bright)); transition: width 0.3s ease; }

.ar-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 32px;
  background: radial-gradient(ellipse at 50% 20%, #16233d, var(--ink-night));
}

/* ---------------------------------------------------------------------- */
/* Hotspot detail sheet                                                   */
/* ---------------------------------------------------------------------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(6,9,15,0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px;
  background: var(--parchment);
  color: var(--parchment-ink);
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: slideUp 0.28s cubic-bezier(.22,1,.36,1);
  max-height: 78vh;
  overflow-y: auto;
}
.sheet h1, .sheet h2, .sheet h3 { color: var(--parchment-ink); }
.sheet p { color: rgba(42,32,19,0.82); }
.sheet .eyebrow { color: var(--alarm); }
.sheet .eyebrow::before { background: var(--alarm); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---------------------------------------------------------------------- */
/* Quiz                                                                    */
/* ---------------------------------------------------------------------- */

.quiz-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(42,32,19,0.2);
  background: rgba(255,255,255,0.35);
  color: var(--parchment-ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.quiz-option:hover { background: rgba(255,255,255,0.55); }
.quiz-option .letter {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--parchment-ink); color: var(--parchment);
  font-family: var(--font-mono); font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.quiz-option.correct { border-color: var(--river); background: rgba(47,110,98,0.18); }
.quiz-option.wrong { border-color: var(--alarm); background: rgba(122,44,34,0.14); }
.quiz-option:disabled { cursor: default; }

/* ---------------------------------------------------------------------- */
/* Bottom nav                                                             */
/* ---------------------------------------------------------------------- */

.bottom-nav {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 14px;
  width: calc(100% - 32px);
  max-width: 448px;
  display: flex;
  background: rgba(16,26,46,0.92);
  border: 1px solid rgba(176,141,62,0.3);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-pill);
  padding: 6px;
  z-index: 50;
  box-shadow: var(--shadow-lift);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px 7px;
  border-radius: var(--radius-pill);
  background: transparent; border: none; color: rgba(237,225,200,0.55);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nav-item.active { background: rgba(193,82,28,0.22); color: var(--ember-bright); }
.nav-item svg { width: 19px; height: 19px; }

/* ---------------------------------------------------------------------- */
/* Misc components                                                        */
/* ---------------------------------------------------------------------- */

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(176,141,62,0.22);
  border-radius: 14px;
  padding: 14px;
}
.stat-card .num { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--brass-bright); }
.stat-card .label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(237,225,200,0.55); margin-top: 2px; }

.timeline-entry { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(42,32,19,0.12); }
.timeline-entry:last-child { border-bottom: none; }
.timeline-entry .t { font-family: var(--font-mono); font-size: 11px; color: var(--alarm); white-space: nowrap; padding-top: 2px; }
.timeline-entry .d { font-size: 13.5px; color: rgba(42,32,19,0.82); }

.download-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(176,141,62,0.15);
}
.download-row:last-child { border-bottom: none; }
.progress-mini { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.12); overflow: hidden; margin-top: 6px; width: 140px; }
.progress-mini > div { height: 100%; background: var(--river-bright); }

.badge-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.workflow-track { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.workflow-step {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 6px 10px; border-radius: var(--radius-pill);
  background: rgba(176,141,62,0.14); color: var(--brass-bright);
  border: 1px solid rgba(176,141,62,0.35);
}
.workflow-arrow { color: rgba(237,225,200,0.35); align-self: center; font-size: 11px; }

.role-card { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(176,141,62,0.15); }
.role-card:last-child { border-bottom: none; }
.role-card .role-icon {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: rgba(47,110,98,0.18); border: 1px solid rgba(63,148,132,0.4);
  display: flex; align-items: center; justify-content: center; color: var(--river-bright);
}

.offline-banner {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px;
  padding: 8px 14px; border-radius: var(--radius-pill);
  background: rgba(122,44,34,0.25); color: #f3b9ab;
  border: 1px solid rgba(122,44,34,0.5);
  margin-bottom: 14px;
}
.offline-banner .dot { width: 6px; height: 6px; border-radius: 50%; background: #f3b9ab; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 96px; z-index: 300;
  background: var(--parchment-ink); color: var(--parchment);
  padding: 11px 18px; border-radius: var(--radius-pill);
  font-size: 13px; box-shadow: var(--shadow-lift);
  animation: toastIn 0.22s ease;
  max-width: 88%;
  text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.scene-header-art {
  height: 132px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid rgba(176,141,62,0.25);
}
.scene-header-art svg { width: 100%; height: 100%; display: block; }

.empty-state {
  text-align: center;
  padding: 40px 18px;
  color: rgba(237,225,200,0.55);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.6; }

.divider-label {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 12px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(237,225,200,0.45);
}
.divider-label::before, .divider-label::after { content: ''; flex: 1; height: 1px; background: rgba(176,141,62,0.25); }

.source-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.source-list li { font-size: 12.5px; color: rgba(42,32,19,0.65); padding-left: 14px; position: relative; }
.source-list li::before { content: '—'; position: absolute; left: 0; color: var(--alarm); }

@media (max-width: 360px) {
  h1 { font-size: 22px; }
  main[data-view] { padding: 14px 14px 8px; }
}
