/* Tulum Signature — Premium Apple-grade design system
 * Warm gold-aligned palette, layered depth, refined motion.
 */

:root, html.theme-dark {
  /* Deep warm backgrounds */
  --bg-0: #0a0805;
  --bg-1: #0f0d09;
  --bg-2: #181410;
  --bg-3: #221c16;
  --bg-4: #2c251d;

  /* Dividers / strokes */
  --line:        rgba(255, 244, 220, 0.05);
  --line-2:      rgba(255, 244, 220, 0.09);
  --line-strong: rgba(255, 244, 220, 0.15);

  /* Text */
  --t-1: #f7f3ea;
  --t-2: #b5ada0;
  --t-3: #756c60;
  --t-4: #45413a;
}

/* ── Light theme (warm cream palette) ───────────────────────── */
html.theme-light {
  --bg-0: #f5efe2;
  --bg-1: #faf6ec;
  --bg-2: #f2ead7;
  --bg-3: #e8dec4;
  --bg-4: #ddd1b1;

  --line:        rgba(26, 19, 8, 0.07);
  --line-2:      rgba(26, 19, 8, 0.11);
  --line-strong: rgba(26, 19, 8, 0.18);

  --t-1: #2a221a;
  --t-2: #635948;
  --t-3: #8a7e6a;
  --t-4: #b3a78e;

  --gold-0: #9a7a44;
  --gold-1: #a8895a;
  --gold-2: #b89669;
  --gold-3: #c8a87a;
  --gold-soft:    rgba(168, 137, 90, 0.15);
  --gold-softer:  rgba(168, 137, 90, 0.07);

  --sh-1: 0 1px 2px rgba(60, 40, 10, 0.08);
  --sh-2: 0 6px 18px rgba(60, 40, 10, 0.10);
  --sh-3: 0 18px 48px rgba(60, 40, 10, 0.12);
}

:root {

  /* Brand gold (logo derived) */
  --gold-0: #b89668;
  --gold-1: #c4a878;
  --gold-2: #d4b888;
  --gold-3: #e5cda3;
  --gold-soft:    rgba(196, 168, 120, 0.12);
  --gold-softer:  rgba(196, 168, 120, 0.06);

  /* Status */
  --emerald:      #34d399;
  --emerald-soft: rgba(52, 211, 153, 0.12);
  --red:          #f87171;
  --red-soft:     rgba(248, 113, 113, 0.12);
  --amber:        #fbbf24;
  --amber-soft:   rgba(251, 191, 36, 0.12);

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --spring:   cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Shadows */
  --sh-1: 0 1px 2px rgba(0,0,0,0.4);
  --sh-2: 0 6px 18px rgba(0,0,0,0.32);
  --sh-3: 0 18px 48px rgba(0,0,0,0.48);
}

/* ── Force dark mode against system preference ──────────────────── */
html { color-scheme: dark; background: var(--bg-1); }
body {
  background: var(--bg-1) !important;
  color: var(--t-1);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11", "cv09";
  letter-spacing: -0.005em;
}
* { box-sizing: border-box; }

@media (max-width: 767px) {
  html, body { overscroll-behavior-y: contain; }
}

/* ── Color utilities ──────────────────────────────────────────── */
.bg-app    { background-color: var(--bg-1) !important; }
.bg-surface{ background-color: var(--bg-2) !important; }
.bg-elev   { background-color: var(--bg-3) !important; }
.bg-elev-2 { background-color: var(--bg-4) !important; }

.text-pri  { color: var(--t-1) !important; }
.text-sec  { color: var(--t-2) !important; }
.text-ter  { color: var(--t-3) !important; }
.text-gold { color: var(--gold-1) !important; }

.bg-gold       { background-color: var(--gold-1) !important; color: #1a1310 !important; }
.bg-gold-soft  { background-color: var(--gold-soft) !important; color: var(--gold-2) !important; }
.bg-gold-softer{ background-color: var(--gold-softer) !important; }

.border-line   { border-color: var(--line)   !important; }
.border-line-2 { border-color: var(--line-2) !important; }

/* ── Tailwind dark-neutral overrides (cascade) ─────────────────── */
.bg-neutral-950, .bg-neutral-950\/30, .bg-neutral-950\/60, .bg-neutral-950\/95 {
  background-color: var(--bg-1) !important;
}
.bg-neutral-900, .bg-neutral-900\/95, .bg-neutral-900\/40 {
  background-color: var(--bg-2) !important;
}
.bg-neutral-800, .bg-neutral-800\/40, .bg-neutral-800\/50 {
  background-color: var(--bg-3) !important;
}
.bg-neutral-700 { background-color: var(--bg-4) !important; }

.border-neutral-800 { border-color: var(--line-2) !important; }
.border-neutral-700 { border-color: var(--line-strong) !important; }
.border-neutral-900 { border-color: var(--line) !important; }
.divide-neutral-800 > * + * { border-color: var(--line) !important; }

.text-neutral-200 { color: #e8e1d0 !important; }
.text-neutral-300 { color: #d8d0bc !important; }
.text-neutral-400 { color: var(--t-2) !important; }
.text-neutral-500 { color: var(--t-3) !important; }
.text-neutral-600 { color: var(--t-4) !important; }

/* Emerald → Gold mapping (brand consistency) */
.bg-emerald-500, .bg-emerald-600, .bg-emerald-700 {
  background-color: var(--gold-1) !important;
  color: #1a1310 !important;
}
.hover\:bg-emerald-500:hover, .hover\:bg-emerald-600:hover, .hover\:bg-emerald-700:hover {
  background-color: var(--gold-2) !important;
}
.text-emerald-300, .text-emerald-400, .text-emerald-500 { color: var(--gold-1) !important; }
.border-emerald-500, .border-emerald-600, .border-emerald-700 { border-color: var(--gold-1) !important; }
.bg-emerald-950\/40, .bg-emerald-900\/40 { background-color: var(--gold-soft) !important; }
.border-emerald-900, .border-emerald-800 { border-color: rgba(196, 168, 120, 0.30) !important; }

/* ── Typography ──────────────────────────────────────────────── */
h1, h2, h3 { letter-spacing: -0.022em; }
h1 { line-height: 1.05; }
h2, h3 { line-height: 1.15; }

.large-title {
  font-size: 2rem;           /* 32px on phones */
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.05;
  color: var(--t-1);
}
@media (min-width: 768px) {
  .large-title { font-size: 2.75rem; }   /* 44px on desktop */
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--t-3);
}

.section-h {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--t-3);
}

.num {
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ── Surfaces ────────────────────────────────────────────────── */
.card {
  background-color: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--sh-1);
  transition: border-color .2s var(--ease-out), transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.card-elev {
  background: linear-gradient(180deg, var(--bg-3) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  box-shadow: var(--sh-2);
}
.card-gold {
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(196,168,120,0.22) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-3) 0%, var(--bg-2) 100%);
  border: 1px solid rgba(196, 168, 120, 0.22);
  border-radius: 20px;
  box-shadow: var(--sh-2);
  position: relative;
  overflow: hidden;
}
.card-gold::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 40% at 100% 100%, rgba(196,168,120,0.10) 0%, transparent 70%);
}
.glass {
  background-color: rgba(15, 13, 9, 0.65);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid var(--line);
}
.glass-strong {
  background-color: rgba(10, 8, 5, 0.78);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid var(--line);
}

.lift { transition: transform .2s var(--ease-out), border-color .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.lift:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: var(--sh-2); }

.hairline { height: 1px; background: var(--line); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.25rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: .875rem;
  transition: all .15s var(--ease-out);
  min-height: 44px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-2) 0%, var(--gold-1) 100%);
  color: #1a1310;
  box-shadow: 0 4px 14px rgba(196,168,120,0.20), inset 0 1px 0 rgba(255,255,255,0.20);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--gold-3) 0%, var(--gold-2) 100%);
  box-shadow: 0 6px 20px rgba(196,168,120,0.28), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-ghost { background: var(--bg-3); color: var(--t-1); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--bg-4); border-color: var(--line-strong); }
.btn-quiet { background: transparent; color: var(--t-2); }
.btn-quiet:hover { color: var(--t-1); background: var(--bg-3); }

/* Pills / chips */
.pill {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .35rem .75rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--t-2);
  transition: all .15s var(--ease-out);
}
.pill-active {
  background: linear-gradient(180deg, var(--gold-2) 0%, var(--gold-1) 100%);
  color: #1a1310;
  border-color: var(--gold-0);
  box-shadow: 0 2px 8px rgba(196,168,120,0.18);
}

/* ── Inputs ─────────────────────────────────────────────────── */
input, select, textarea {
  background-color: var(--bg-2) !important;
  border: 1px solid var(--line-2);
  color: var(--t-1);
  font-size: 16px;
  border-radius: 12px;
  transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out), background-color .15s var(--ease-out);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold-1) !important;
  background-color: var(--bg-3) !important;
  box-shadow: 0 0 0 3px var(--gold-soft);
  outline: none !important;
}
input::placeholder, textarea::placeholder { color: var(--t-3); }

/* ── Avatars ─────────────────────────────────────────────────── */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-3) 0%, var(--bg-4) 100%);
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.avatar-gold {
  background: linear-gradient(135deg, var(--gold-soft) 0%, transparent 100%);
  border-color: rgba(196,168,120,0.25);
  color: var(--gold-1);
}

/* ── Mini bar (sparkline-ish indicator) ─────────────────────── */
.bar {
  height: 4px; border-radius: 2px;
  background: var(--bg-3);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-0), var(--gold-2));
  border-radius: 2px;
  transition: width .4s var(--ease-out);
}

/* ── Touch & a11y ──────────────────────────────────────────── */
@media (pointer: coarse) {
  a, button, summary, select, input[type="text"], input[type="password"],
  input[type="number"], input[type="email"], input[type="search"], input[type="datetime-local"] {
    min-height: 44px;
  }
  nav a, nav button { min-height: 48px; }
}
a:active, button:active, summary:active {
  transition: transform .05s var(--ease-out);
  transform: scale(.98);
}
:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 2px; }

/* ── Motion ────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
main { animation: fadeInUp .35s var(--ease-out); }

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold-1);
  box-shadow: 0 0 8px var(--gold-1);
  animation: pulseGlow 2s ease-in-out infinite;
}

/* ── Line clamps ──────────────────────────────────────────── */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Mobile-specific polish ──────────────────────────────── */
@media (max-width: 767px) {
  /* Hero numbers feel right at ~72px on phone */
  .hero-num { font-size: 64px !important; }

  /* Cards get a touch more breathing room */
  .card { border-radius: 16px; }

  /* Eyebrow text more visible on mobile */
  .eyebrow { font-size: 0.66rem; letter-spacing: 0.12em; }

  /* Page top padding tighter (header gives space) */
  main > div:first-child { padding-top: 1.25rem !important; }

  /* Bottom nav glass blur improvement on iOS */
  nav.glass-strong {
    background-color: rgba(15, 13, 9, 0.88);
  }
  html.theme-light nav.glass-strong {
    background-color: rgba(250, 246, 236, 0.88);
  }
}

/* ── PWA standalone ───────────────────────────────────────── */
@media (display-mode: standalone) {
  body { user-select: none; -webkit-user-select: none; }
  input, textarea { user-select: text; -webkit-user-select: text; }
}

/* ── Mobile table → cards ─────────────────────────────────── */
@media (max-width: 767px) {
  table.mobile-cards thead { display: none; }
  table.mobile-cards tbody { display: block; }
  table.mobile-cards tbody tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }
  table.mobile-cards tbody tr td {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 2px 0; border: none !important; text-align: left !important;
  }
  table.mobile-cards tbody tr td:first-child { font-weight: 600; font-size: 0.95em; margin-bottom: 4px; }
  table.mobile-cards tbody tr td::before {
    content: attr(data-label);
    color: var(--t-3); font-size: 0.72em;
    text-transform: uppercase; letter-spacing: 0.06em; margin-right: 8px;
  }
  table.mobile-cards tbody tr td:first-child::before { display: none; }
}

/* ── Scrollbars ────────────────────────────────────────────── */
@media (pointer: fine) {
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; border: 2px solid var(--bg-1); }
  *::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }
}
@media (max-width: 767px) {
  *::-webkit-scrollbar { display: none; }
  * { scrollbar-width: none; }
}

/* ── Bottom sheet on mobile ───────────────────────────────── */
@media (max-width: 767px) {
  .modal-sheet { animation: slideUp 0.25s var(--ease-out); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.tap-zone { position: relative; }
.tap-zone::before { content: ''; position: absolute; inset: -8px; z-index: -1; }

/* Readable text selection on both themes (was an unreadable beige block) */
::selection      { background: var(--gold-soft); color: var(--t-1); }
::-moz-selection { background: var(--gold-soft); color: var(--t-1); }
