/* ==========================================================================
   El Faro — Red Chapala · shared design system
   "La red que no se apaga"
   Mobile-first. Bilingual-friendly (no hardcoded copy here).
   Palette derived from the live site; refined to a lake-blue aesthetic.
   ========================================================================== */

:root {
  /* Brand palette */
  --primary: #2196F3;      /* lake blue */
  --primary-600: #1976D2;
  --dark: #1a237e;         /* deep indigo — headings, hover */
  --accent: #FF8A65;       /* warm coral — the beacon */
  --accent-600: #F4623A;
  --light: #E3F2FD;        /* pale sky — tints */

  /* Surfaces & text */
  --bg-1: #eaf4fb;         /* gradient stop 1 */
  --bg-2: #cfe6f7;         /* gradient stop 2 */
  --bg-3: #b3d8f0;         /* gradient stop 3 */
  --card: rgba(255, 255, 255, 0.96);
  --card-solid: #ffffff;
  --text: #263238;
  --muted: #5f6b72;
  --line: rgba(26, 35, 126, 0.10);

  /* Status colors (badges / node health) */
  --ok: #2e7d32;
  --ok-bg: #e6f4ea;
  --warn: #b26a00;
  --warn-bg: #fff3e0;
  --bad: #c62828;
  --bad-bg: #fdeaea;
  --info: var(--primary);
  --info-bg: var(--light);

  /* Shape & depth */
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 10px 30px rgba(26, 35, 126, 0.12);
  --shadow-sm: 0 4px 14px rgba(26, 35, 126, 0.10);
  --shadow-hover: 0 14px 36px rgba(26, 35, 126, 0.18);

  --maxw: 1100px;
  --gap: 24px;
  --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 55%, var(--bg-3) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 48px; }
.stack > * + * { margin-top: var(--gap); }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- Typography ---------- */
h1, h2, h3 { color: var(--dark); line-height: 1.25; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); margin-bottom: .5em; }
h3 { font-size: 1.2rem; margin-bottom: .4em; }
p  { margin-bottom: .8em; color: #40484d; }
a  { color: var(--primary-600); text-decoration: none; }
a:hover { color: var(--dark); text-decoration: underline; }
.lead { font-size: 1.15rem; color: var(--muted); }
.muted { color: var(--muted); }
.center { text-align: center; }
code, .mono {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  background: var(--light);
  color: var(--dark);
  padding: .12em .45em;
  border-radius: 6px;
  font-size: .92em;
  word-break: break-all;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  margin-bottom: var(--gap);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--dark);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--dark); text-decoration: none; }
.brand .glyph { font-size: 1.5rem; line-height: 1; filter: drop-shadow(0 2px 4px rgba(244,98,58,.35)); }
.brand small { display: block; font-size: .62rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-600); }

.site-nav { margin-left: auto; }
.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.site-nav a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  color: var(--dark);
  font-weight: 600;
  font-size: .95rem;
  transition: background .2s, color .2s;
}
.site-nav a:hover { background: var(--light); text-decoration: none; }
.site-nav a[aria-current="page"] { background: var(--primary); color: #fff; }

/* Language toggle */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: #fff;
}
.lang-switch button {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: .82rem;
  padding: 7px 12px;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.lang-switch button[aria-pressed="true"] { background: var(--primary); color: #fff; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card--tint { background: linear-gradient(135deg, #fff 0%, var(--light) 100%); }
.card--hover { transition: transform .25s, box-shadow .25s; }
.card--hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.card .icon { font-size: 2.2rem; margin-bottom: 10px; display: block; }

/* Hero */
.hero { text-align: center; padding: clamp(32px, 6vw, 56px) 28px; }
.hero .beacon { font-size: clamp(3rem, 12vw, 5rem); line-height: 1; margin-bottom: 12px; filter: drop-shadow(0 6px 14px rgba(244,98,58,.4)); }
.hero .tagline { font-size: 1.25rem; color: var(--accent-600); font-weight: 600; margin-top: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, background .2s;
}
.btn:hover { background: var(--dark); color: #fff; text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn--secondary { background: #fff; color: var(--dark); border: 1px solid var(--line); }
.btn--secondary:hover { background: var(--light); color: var(--dark); }
.btn--accent { background: var(--accent); }
.btn--accent:hover { background: var(--accent-600); }
.btn--emergency { background: var(--bad); font-weight: 700; }
.btn--emergency:hover { background: #9a1f1f; }
.btn--lg { padding: 15px 32px; font-size: 1.1rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-row.center { justify-content: center; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: var(--radius-pill);
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.5;
  background: var(--info-bg);
  color: var(--primary-600);
}
.badge--ok   { background: var(--ok-bg);   color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--bad  { background: var(--bad-bg);  color: var(--bad); }
.badge--muted{ background: #eceff1;        color: var(--muted); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Status (Estado page + landing strip) ---------- */
#status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 16px 20px;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-size: .95rem;
}
#status-strip .strip-head { font-weight: 700; color: var(--dark); }
#status-strip .strip-nodes { display: flex; flex-wrap: wrap; gap: 6px; }
#status-strip .updated { margin-left: auto; color: var(--muted); font-size: .85rem; }

.status-summary { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.status-summary .metric { flex: 1 1 140px; background: var(--light); border-radius: var(--radius-sm); padding: 14px 18px; }
.status-summary .metric b { display: block; font-size: 1.6rem; color: var(--dark); }
.status-summary .metric span { color: var(--muted); font-size: .85rem; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.status-table { width: 100%; border-collapse: collapse; min-width: 480px; }
table.status-table th, table.status-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
table.status-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
table.status-table td { font-size: .95rem; }
table.status-table tr:last-child td { border-bottom: 0; }

.node-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: #fff;
  border: 1px solid var(--line);
  font-size: .82rem;
  font-weight: 600;
}
.node-chip .short { color: var(--dark); }

.batt { display: inline-flex; align-items: center; gap: 6px; }
.batt .bar { width: 42px; height: 8px; border-radius: 4px; background: #dfe6ea; overflow: hidden; }
.batt .bar > i { display: block; height: 100%; background: var(--ok); }

/* QR placeholder box (Meshtastic channel) */
.qr-placeholder {
  border: 2px dashed var(--primary);
  border-radius: var(--radius-sm);
  background: var(--light);
  color: var(--primary-600);
  padding: 40px 24px;
  text-align: center;
  font-weight: 600;
  max-width: 320px;
  margin: 0 auto;
}
.qr-placeholder .glyph { font-size: 2.4rem; display: block; margin-bottom: 8px; }

/* Callout / notice */
.notice {
  border-left: 4px solid var(--accent);
  background: var(--warn-bg);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}
.notice--info { border-left-color: var(--primary); background: var(--info-bg); }

/* Offline / error state for status */
.status-offline { text-align: center; color: var(--muted); padding: 24px; }
.status-offline .glyph { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 26px 24px;
  margin-top: var(--gap);
  text-align: center;
  color: var(--muted);
}
.site-footer .f-tagline { color: var(--accent-600); font-weight: 600; margin-bottom: 6px; }
.site-footer .f-brand { color: var(--dark); font-weight: 700; }
.site-footer a { font-weight: 600; }
.site-footer .f-meta { font-size: .85rem; margin-top: 8px; }

/* ---------- Language visibility (driven by app.js on <html data-lang>) ---------- */
[data-lang="es"] .lang-en { display: none !important; }
[data-lang="en"] .lang-es { display: none !important; }
/* Before JS runs, default to Spanish */
.lang-en { display: none; }
[data-lang="en"] .lang-en { display: initial; }
[data-lang="en"] .lang-es { display: none; }

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #0e1622; --bg-2: #101d2c; --bg-3: #0b1420;
    --card: rgba(23, 34, 48, 0.94);
    --card-solid: #172230;
    --text: #dce6ef;
    --muted: #93a4b3;
    --line: rgba(255, 255, 255, 0.10);
    --light: #16283a;
    --dark: #cfe0ff;
    --primary-600: #64b5f6;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 14px 36px rgba(0, 0, 0, 0.55);
    --ok-bg: #12331c; --warn-bg: #3a2a10; --bad-bg: #3a1616; --info-bg: #16283a;
  }
  p { color: var(--text); }
  .btn--secondary { background: #1d2b3a; color: var(--dark); }
  .node-chip, #status-strip .updated { background: transparent; }
  .node-chip { background: #1d2b3a; }
  .lang-switch { background: #1d2b3a; }
  .batt .bar { background: #2a3947; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: stretch; text-align: center; }
  .brand { justify-content: center; }
  .site-nav { margin-left: 0; }
  .site-nav ul { justify-content: center; }
  #status-strip .updated { margin-left: 0; width: 100%; }
}

/* ---------- Print (for /emergencia — one clean page) ---------- */
@media print {
  body { background: #fff !important; color: #000; }
  .site-header .site-nav, .lang-switch, .btn, .card--hover:hover { display: revert; }
  .site-nav, .lang-switch, .no-print { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .card, .site-header, .site-footer { box-shadow: none; border: 1px solid #ccc; border-radius: 8px; page-break-inside: avoid; }
  .lang-en { display: none !important; }   /* print Spanish only */
  a { color: #000; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
  h1, h2, h3 { color: #000; }
}
