/* ============================================================
   NOSSA VIAGEM — CSS Principal
   Paleta editorial: cream/ink/papal/gold · Fraunces + Geist
   ============================================================ */

/* ----------------------------------------------------------
   VARIÁVEIS
   ---------------------------------------------------------- */
:root {
  /* Paleta principal */
  --c-primary:    #8b1e1e;   /* papal */
  --c-gold:       #a8842c;
  --c-gold-light: #d4ab4f;
  --c-cream:      #fdfaf3;
  --c-ink:        #1a1410;
  --c-ink-soft:   #3d322a;
  --c-ink-muted:  #6b5c4f;

  /* UI surfaces */
  --bg:       #fdfaf3;
  --bg2:      #f8f1e0;
  --surface:  #ffffff;
  --border:   rgba(26,20,16,0.10);

  /* Texto */
  --text:     #1a1410;
  --text2:    #3d322a;
  --text3:    #6b5c4f;

  /* Sombras */
  --shadow:    rgba(26,20,16,0.08);
  --shadow-md: rgba(26,20,16,0.15);

  /* Tipografia */
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans:  'Geist', system-ui, sans-serif;
  --font-mono:  'Geist Mono', monospace;

  /* Layout */
  --nav-h:    64px;
  --header-h: auto;
  --safe-b:   env(safe-area-inset-bottom, 0px);

  /* Raios */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 999px;

  /* Espaçamentos */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;

  /* Transições */
  --t-fast: 150ms ease;
  --t-med:  280ms ease;
  --t-slow: 400ms cubic-bezier(.4,0,.2,1);
}

/* ----------------------------------------------------------
   RESET
   ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Textura sutil de papel */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at top, rgba(168,132,44,0.03), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(139,30,30,0.02), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.15;
  font-feature-settings: 'ss01' on, 'cv11' on;
  letter-spacing: -0.02em;
}

/* ----------------------------------------------------------
   LAYOUT DO APP
   ---------------------------------------------------------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ----------------------------------------------------------
   HEADER EDITORIAL
   ---------------------------------------------------------- */
.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) var(--s5) 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
  position: relative;
}

.header-editorial {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.header-mono-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-mono-label::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c-primary);
  flex-shrink: 0;
}

.header-display-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 300;
  color: var(--text);
  line-height: 1;
  margin-top: 2px;
}

.header-display-title em {
  font-style: italic;
  color: var(--c-primary);
  font-weight: 400;
}

.header-mono-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text3);
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding-top: 2px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text3);
  transition: var(--t-fast);
}
.btn-icon:hover { background: var(--border); color: var(--text); }
.btn-icon svg { flex-shrink: 0; }

.icon-sun, .icon-moon { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"]  .icon-sun  { display: block; }
[data-theme="auto"]  .icon-moon { display: block; }

/* ----------------------------------------------------------
   QUICK STATS GRID
   ---------------------------------------------------------- */
.header-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stat-cell {
  background: var(--bg);
  padding: 8px 12px;
  border-right: 1px solid var(--border);
}
.stat-cell:last-child { border-right: none; }

.stat-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-sub {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------------------------
   MAIN
   ---------------------------------------------------------- */
.app-main {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.app-section {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + var(--s5));
}

.app-section.active {
  display: block;
  animation: fadeInSection var(--t-med);
}

@keyframes fadeInSection {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------------------------
   LOADING
   ---------------------------------------------------------- */
.section-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  height: 60vh;
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------
   BOTTOM NAV
   ---------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: stretch;
  background: rgba(253,250,243,0.96);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color var(--t-fast);
  padding: var(--s2) var(--s1);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.nav-item:hover { color: var(--c-primary); }
.nav-item.active { color: var(--c-primary); }

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--c-primary);
  border-radius: 0 0 2px 2px;
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.nav-item.active .nav-icon {
  stroke-width: 2;
}

.nav-label { line-height: 1; }

/* ----------------------------------------------------------
   SECTION HEADER INTERNO
   ---------------------------------------------------------- */
.section-header {
  padding: var(--s5) var(--s5) var(--s4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.section-mono-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--c-primary);
  margin-bottom: var(--s2);
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--text);
  font-style: italic;
}

.section-subtitle {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text3);
  margin-top: 4px;
}

.section-body {
  padding: var(--s4) var(--s5);
}

/* ----------------------------------------------------------
   UPDATE BANNER
   ---------------------------------------------------------- */
.update-banner {
  position: fixed;
  top: 12px;
  left: var(--s4);
  right: var(--s4);
  background: var(--text);
  color: var(--bg);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  z-index: 200;
  box-shadow: 0 4px 16px var(--shadow-md);
  animation: slideDown var(--t-med);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.update-banner.hidden { display: none; }

/* ----------------------------------------------------------
   INSTALL PROMPT
   ---------------------------------------------------------- */
.install-prompt {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--s4));
  left: var(--s4);
  right: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: 0 8px 32px var(--shadow-md);
  z-index: 200;
  animation: slideUp var(--t-med);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.install-prompt.hidden { display: none; }

.install-prompt-content {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
}
.install-prompt-icon { color: var(--c-primary); flex-shrink: 0; }
.install-prompt-content div { flex: 1; min-width: 120px; }
.install-prompt-content strong { font-size: 0.88rem; font-family: var(--font-serif); }
.install-prompt-content p { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text3); margin-top: 2px; letter-spacing: 0.05em; }
.install-prompt-actions { display: flex; gap: var(--s2); }

/* ----------------------------------------------------------
   TIPOGRAFIA AUXILIAR
   ---------------------------------------------------------- */
.mono-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text3);
}
.mono-label.papal { color: var(--c-primary); }
.mono-label.gold  { color: var(--c-gold); }

.serif { font-family: var(--font-serif); }
.text-muted { color: var(--text3); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }

/* ----------------------------------------------------------
   SCROLL OCULTO
   ---------------------------------------------------------- */
.scroll-x {
  overflow-x: auto;
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }

/* ----------------------------------------------------------
   CITY PILLS (filtros) — versão editorial
   ---------------------------------------------------------- */
.city-pills {
  display: flex;
  gap: var(--s2);
  padding: var(--s3) var(--s5);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.city-pills::-webkit-scrollbar { display: none; }

.city-pill {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 5px var(--s3);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text3);
  background: var(--bg);
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.city-pill:hover { border-color: var(--c-primary); color: var(--c-primary); }
.city-pill.active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: var(--bg);
}

/* ----------------------------------------------------------
   RESPONSIVE
   ---------------------------------------------------------- */
@media (min-width: 480px) {
  .section-body { padding: var(--s5) var(--s6); }
}

@media (min-width: 768px) {
  :root { --nav-h: 0px; }
  .bottom-nav { display: none; }
  .app-section { padding-bottom: var(--s8); }

  #app {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "header header"
      "stats stats"
      "sidenav main";
  }
  .app-header         { grid-area: header; }
  .header-stats-grid  { grid-area: stats; }
  .app-main           { grid-area: main; }

  .bottom-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    grid-area: sidenav;
    height: auto;
    position: static;
    border-top: none;
    border-right: 1px solid var(--border);
    background: var(--bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: var(--s5) 0;
  }
  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    padding: var(--s3) var(--s5);
    gap: var(--s3);
    font-size: 9px;
    border-radius: 0;
  }
  .nav-item.active::before {
    top: 25%; bottom: 25%;
    left: 0; right: auto;
    width: 2px; height: auto;
    border-radius: 0 2px 2px 0;
  }
  .header-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
