/* CSN — Carnes Selectas Nayarit: brand-accurate red + orange, clean light mode. */

:root {
  color-scheme: light dark;

  /* ===== Light — "CSN Clean" (white surfaces, brand red/orange accents) ===== */
  --bg: #F7F5F3;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --surface: #ffffff;
  --surface-soft: #FFF3EE;
  --surface-muted: #F0EAE3;
  --on-bg: #1A0A05;
  --on-bg-soft: #5A3020;
  --on-bg-muted: #8A6050;
  --hairline: rgba(100, 30, 15, 0.10);
  --hairline-strong: rgba(100, 30, 15, 0.22);
  --shadow-card: 0 12px 28px -14px rgba(100, 30, 15, 0.18), 0 2px 6px -3px rgba(100, 30, 15, 0.08);
  --shadow-hero: 0 26px 60px -28px rgba(180, 40, 20, 0.40);

  /* ===== CSN Brand Palette ===== */
  --brand-red: #CC2B18;
  --brand-red-deep: #A82210;
  --brand-orange: #E87020;
  --brand-orange-soft: #FFD4A8;
  --brand-orange-deep: #C05010;
  --brand-wood: #C48040;
  --brand-copper: #b97836;
  --brand-leather: #6b3e2a;
  --brand-cream: #FFF6EE;
  --brand-brown: #2E140A;

  --primary: #CC2B18;
  --primary-pressed: #A82210;
  --on-primary: #ffffff;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-2xl: 34px;

  --margin-main: 20px;
  --gutter: 12px;
  --stack-sm: 8px;
  --stack-md: 16px;
  --stack-lg: 24px;
  --stack-xl: 32px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font-display: 'Fraunces', 'Playfair Display', Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, sans-serif;

  --surface-container: #ffffff;
  --surface-container-low: #FFF6F0;
  --surface-container-high: #F0EAE3;
  --surface-container-highest: #E8DFD5;
  --surface-variant: #FFF3EE;
  --on-surface: #1A0A05;
  --on-surface-variant: #8A6050;
  --on-secondary-fixed-variant: #b3997b;
  --primary-fixed-dim: #E87020;
  --primary-container: #CC2B18;
  --on-primary-container: #ffffff;
  --background: #F7F5F3;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #120806;
  --bg-elevated: #1E100C;
  --bg-glass: rgba(30, 16, 12, 0.88);
  --surface: #1E100C;
  --surface-soft: #281610;
  --surface-muted: #321E16;
  --on-bg: #FFF6EE;
  --on-bg-soft: #E8D0BE;
  --on-bg-muted: #B39080;
  --hairline: rgba(255, 210, 180, 0.10);
  --hairline-strong: rgba(255, 210, 180, 0.20);
  --shadow-card: 0 20px 40px -18px rgba(0, 0, 0, 0.60);
  --shadow-hero: 0 30px 80px -28px rgba(200, 43, 24, 0.30);

  --primary: #E87020;
  --primary-pressed: #CC2B18;
  --on-primary: #ffffff;

  --surface-container: #1E100C;
  --surface-container-low: #281610;
  --surface-container-high: #321E16;
  --surface-container-highest: #3C2418;
  --surface-variant: #321E16;
  --on-surface: #FFF6EE;
  --on-surface-variant: #B39080;
  --on-secondary-fixed-variant: #8A6050;
  --background: #120806;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--on-bg);
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  transition: background-color 280ms ease, color 280ms ease;
}

body {
  position: relative;
  min-height: 100dvh;
  padding-bottom: calc(96px + var(--safe-bottom));
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
}
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ===== Top app bar — translucent like Apple TV ===== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  width: 100%; max-width: 28rem; margin: 0 auto;
  padding-top: var(--safe-top);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.app-header-inner {
  display: flex; justify-content: space-between; align-items: center;
  height: 56px; padding: 0 var(--margin-main);
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-muted);
  color: var(--on-bg);
  border: none;
  transition: background-color 160ms ease, transform 160ms ease;
}
.icon-btn:hover { background: color-mix(in srgb, var(--surface-muted) 70%, var(--brand-orange) 30%); }
.icon-btn:active { transform: scale(0.94); }

.toolbar-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--surface-muted);
  border: none;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--on-bg);
}
.toolbar-toggle .dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 999px; background: var(--brand-orange);
}

/* ===== Hero — CSN brand red/orange gradient ===== */
.atv-hero {
  position: relative; overflow: hidden;
  margin: 12px var(--margin-main) 0;
  padding: 32px 28px 34px;
  border-radius: var(--radius-2xl);
  background:
    radial-gradient(120% 130% at 0% 0%, rgba(255,255,255,0.18) 0%, transparent 50%),
    radial-gradient(90% 90% at 100% 100%, rgba(0,0,0,0.22) 0%, transparent 55%),
    linear-gradient(140deg, #CC2B18 0%, #E87020 100%);
  color: #ffffff;
  box-shadow: var(--shadow-hero);
  border: 1px solid rgba(255,255,255,0.15);
}
[data-theme="dark"] .atv-hero {
  background:
    radial-gradient(120% 130% at 0% 0%, rgba(204, 43, 24, 0.45) 0%, transparent 55%),
    radial-gradient(120% 130% at 100% 100%, rgba(232, 112, 32, 0.22) 0%, transparent 60%),
    linear-gradient(140deg, #1E100C 0%, #281610 100%);
  color: var(--on-bg);
  border-color: rgba(255, 210, 180, 0.12);
}
.atv-hero::before {
  content: "";
  position: absolute; inset: -8% -10% auto auto;
  width: 88%; aspect-ratio: 1;
  background: url("/assets/logo-watermark.png") no-repeat center / contain;
  opacity: 0.5; pointer-events: none;
  filter: saturate(1.05);
}
[data-theme="dark"] .atv-hero::before { opacity: 0.35; mix-blend-mode: screen; }
.atv-hero > * { position: relative; z-index: 1; }
.atv-hero__hello {
  font-family: var(--font-display);
  font-size: 42px; line-height: 1.0; font-weight: 700;
  letter-spacing: -0.02em; margin: 6px 0 20px;
}
.atv-hero__points {
  font-family: var(--font-body);
  font-size: 13px; font-weight: 700; opacity: 0.7;
  text-transform: uppercase; letter-spacing: 0.1em; margin: 0 0 4px;
}
.atv-hero__points-value {
  font-family: var(--font-display);
  font-size: 64px; line-height: 1; font-weight: 700;
  letter-spacing: -0.04em; margin: 0 0 16px;
  color: #ffffff;
}
[data-theme="dark"] .atv-hero__points-value { color: var(--brand-orange); }
.atv-hero__tofor {
  font-size: 15px; line-height: 1.4; font-weight: 500; opacity: 0.88;
  margin: 0 0 14px; max-width: 320px;
}
.atv-hero__tofor strong { font-weight: 800; opacity: 1; }
.atv-hero__bar {
  width: 100%; height: 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}
[data-theme="dark"] .atv-hero__bar { background: rgba(255, 255, 255, 0.15); }
.atv-hero__bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0.85) 0%, #ffffff 100%);
  border-radius: 999px;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.45);
}
[data-theme="dark"] .atv-hero__bar > span {
  background: linear-gradient(90deg, var(--brand-orange) 0%, var(--brand-red) 100%);
  box-shadow: 0 0 14px rgba(232, 112, 32, 0.5);
}
.atv-hero__chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 18px; padding: 8px 14px;
  background: rgba(255,255,255,0.20); border: 1px solid rgba(255,255,255,0.30);
  border-radius: 999px;
  font-size: 13px; font-weight: 700; color: #ffffff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
[data-theme="dark"] .atv-hero__chip {
  background: var(--bg-elevated); border-color: var(--hairline); color: var(--on-bg);
}
.atv-hero__chip-label { opacity: 0.75; font-weight: 600; letter-spacing: 0.02em; }
.atv-hero__chip-value { color: #ffffff; font-weight: 800; }
[data-theme="dark"] .atv-hero__chip-value { color: var(--brand-orange); }

/* ===== Cards & lists ===== */
.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
}
.card-soft {
  background: var(--surface-soft);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
}
.glass {
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--hairline);
  color: var(--on-bg);
}
.glass-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  color: var(--on-bg);
}
.glass-dark {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  color: var(--on-bg);
}

/* Buttons / chips */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--primary);
  color: #ffffff; border: none;
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
  box-shadow: 0 8px 18px -8px rgba(200, 43, 24, 0.55);
  transition: transform 140ms ease, background-color 140ms ease;
}
.btn-primary:active { transform: scale(0.97); background: var(--primary-pressed); }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--surface-muted);
  color: var(--on-bg); border: none;
  font-weight: 700; font-size: 13px;
}
.chip-filter {
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface-muted); color: var(--on-bg-muted);
  border: 1px solid transparent;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  white-space: nowrap;
}
.chip-filter.is-active {
  background: var(--primary); color: #ffffff;
  box-shadow: 0 6px 14px -6px rgba(200, 43, 24, 0.50);
}

.section-title {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700; letter-spacing: -0.015em;
  color: var(--on-bg); margin: 0 0 12px;
}
.section-link {
  font-size: 13px; font-weight: 700; color: var(--primary);
}

.orange-glow { box-shadow: 0 8px 22px -10px rgba(200, 43, 24, 0.45); }
.inner-glow { box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5); }
.active-glow { filter: drop-shadow(0 0 8px rgba(200, 43, 24, 0.50)); }
.qr-gradient {
  background: linear-gradient(135deg, #ffffff 0%, #f5f5f7 100%);
  border: 1px solid var(--hairline);
}
[data-theme="dark"] .qr-gradient {
  background: linear-gradient(135deg, #1c1c1e 0%, #0e0e10 100%);
  border-color: var(--hairline-strong);
}

/* ===== Bottom nav (Apple-style segmented) ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 28rem; margin: 0 auto;
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 12px calc(14px + var(--safe-bottom));
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--hairline);
  z-index: 50;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 10px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--on-bg-muted);
  transition: color 180ms ease, transform 180ms ease;
}
.bottom-nav a:hover { color: var(--on-bg); }
.bottom-nav a[aria-current="page"] {
  color: var(--primary);
  font-weight: 700;
}
[data-theme="dark"] .bottom-nav a[aria-current="page"] {
  color: var(--brand-orange);
}
.bottom-nav a[aria-current="page"] .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 600;
}

/* ===== Install banner ===== */
.install-banner {
  position: fixed; left: 50%;
  bottom: calc(110px + var(--safe-bottom));
  transform: translateX(-50%) translateY(120%);
  width: calc(100% - 32px); max-width: 26rem;
  padding: 12px 14px; border-radius: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  color: var(--on-bg);
  display: flex; align-items: center; gap: 12px;
  z-index: 80; opacity: 0; pointer-events: none;
  transition: transform 320ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 320ms;
}
.install-banner.is-open {
  transform: translateX(-50%) translateY(0);
  opacity: 1; pointer-events: auto;
}
.install-banner__icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(204, 43, 24, 0.12);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.install-banner__body { flex: 1; line-height: 1.2; }
.install-banner__body strong { display: block; font-size: 14px; font-weight: 700; }
.install-banner__body span { font-size: 12px; color: var(--on-bg-muted); }
.install-banner__cta {
  background: var(--primary); color: #ffffff; border: none;
  border-radius: 999px; padding: 8px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
}
.install-banner__close {
  background: transparent; border: none; color: var(--on-bg-muted);
  padding: 4px; display: flex;
}

/* ===== Network toast ===== */
.net-toast {
  position: fixed; top: calc(12px + var(--safe-top)); left: 50%;
  transform: translate(-50%, -140%);
  background: var(--bg-elevated); color: var(--on-bg);
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px; z-index: 100;
  transition: transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.net-toast.is-visible { transform: translate(-50%, 0); }
.net-toast .dot { width: 8px; height: 8px; border-radius: 999px; background: #e3543d; }
.net-toast.is-online .dot { background: #34c759; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}


/* ===== DESKTOP LAYOUT (≥ 768px) — sidebar + expanded content ===== */

.sidebar-nav { display: none; }

@media (min-width: 768px) {
  body {
    padding-left: 260px;
    padding-bottom: 0;
  }
  .bottom-nav { display: none !important; }
  .app-header {
    max-width: 100%;
    border-radius: 0;
  }
  .app-header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 40px;
  }
  body > main {
    max-width: 900px !important;
    width: 100%;
    margin: 0 auto !important;
    padding: 0 40px 48px;
  }
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    height: 100dvh;
    z-index: 60;
    background: var(--bg-elevated);
    border-right: 1px solid var(--hairline);
    padding: 0 12px 24px;
    overflow-y: auto;
    gap: 2px;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 12px 24px;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 12px;
  }
  .sidebar-brand img { width: 32px; height: 28px; }
  .sidebar-brand-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--on-bg);
  }
  .sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--on-bg-muted);
    text-decoration: none;
    transition: background-color 140ms ease, color 140ms ease;
  }
  .sidebar-nav a:hover { background: var(--surface-muted); color: var(--on-bg); }
  .sidebar-nav a[aria-current="page"] {
    background: var(--surface-soft);
    color: var(--primary);
    font-weight: 700;
  }
  [data-theme="dark"] .sidebar-nav a[aria-current="page"] {
    color: var(--brand-orange);
    background: var(--surface-muted);
  }
  .sidebar-nav a[aria-current="page"] .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 600;
  }
  .sidebar-nav .material-symbols-outlined { font-size: 22px; }
  .sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .sidebar-footer button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--on-bg-muted);
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
  }
  .sidebar-footer button:hover { background: var(--surface-muted); color: var(--on-bg); }
  .install-banner {
    left: calc(260px + 16px);
    transform: translateX(0) translateY(120%);
    bottom: 24px;
    max-width: 380px;
  }
  .install-banner.is-open { transform: translateX(0) translateY(0); }
}

/* ===== View Transitions ===== */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 200ms ease both vt-out; }
::view-transition-new(root) { animation: 260ms ease 50ms both vt-in; }
@keyframes vt-out { from { opacity:1; transform:translateY(0); } to { opacity:0; transform:translateY(-6px); } }
@keyframes vt-in  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ===== Standalone PWA polish ===== */
@media (display-mode: standalone) {
  .app-header { padding-top: max(var(--safe-top), 8px); }
}
