/* ============================================================
   Phone Deals — site styles
   Colors and fonts are tokens on :root. Dark theme follows the
   OS setting, or the header toggle (data-theme on <html>).
   ============================================================ */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #d8dde7;
  --text: #141a26;
  --muted: #5b6478;
  --accent: #1a5fd6;
  --accent-hover: #164fb3;
  --on-accent: #ffffff;
  --accent-soft: #e6eefc;
  --save: #c8410a;
  --save-soft: #fdeee5;
  --good: #1f8a4c;
  --good-soft: #e3f4ea;
  --warn: #9a6a12;
  --warn-soft: #fbf1dc;
  --shadow: 0 1px 2px rgba(20, 26, 38, .05), 0 6px 20px rgba(20, 26, 38, .05);
  --radius: 12px;
  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1218; --surface: #151b25; --surface-2: #1b2331; --border: #2a3444;
    --text: #e7ebf2; --muted: #9aa4b8; --accent: #5b9dff; --accent-hover: #82b3ff;
    --on-accent: #0b1322; --accent-soft: #172741; --save: #ff8b52; --save-soft: #3a2113;
    --good: #49c97f; --good-soft: #143222; --warn: #e0ad4a; --warn-soft: #3a2d12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1218; --surface: #151b25; --surface-2: #1b2331; --border: #2a3444;
  --text: #e7ebf2; --muted: #9aa4b8; --accent: #5b9dff; --accent-hover: #82b3ff;
  --on-accent: #0b1322; --accent-soft: #172741; --save: #ff8b52; --save-soft: #3a2113;
  --good: #49c97f; --good-soft: #143222; --warn: #e0ad4a; --warn-soft: #3a2d12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
code { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); }
.skip-link:focus { left: 8px; }
.wrap { max-width: 1120px; margin-inline: auto; padding-inline: 16px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; gap: 12px; min-height: 62px; position: relative; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); margin-right: auto; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: 14px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--surface); border-radius: 9px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
#theme-toggle svg { display: none; }
#theme-toggle[data-theme="light"] .ic-sun, #theme-toggle[data-theme="dark"] .ic-moon, #theme-toggle[data-theme="system"] .ic-auto { display: block; }
.nav-toggle { display: none; }
@media (max-width: 800px) {
  .nav-toggle { display: inline-grid; }
  .nav { display: none; position: absolute; right: 0; top: calc(100% + 6px); flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); min-width: 200px; }
  .nav.open { display: flex; }
}

/* ---------- hero ---------- */
.hero { padding-block: 28px 8px; }
.hero-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 0 0 8px; text-wrap: balance; }
.hero p { margin: 0; color: var(--muted); max-width: 62ch; }
.region-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.region-field select { min-width: 200px; }

/* ---------- form controls ---------- */
select, input[type="search"], input[type="number"], input[type="text"], input[type="email"] {
  width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); padding: 0 10px; font: inherit; font-size: 14px;
}
select { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

/* ---------- filters ---------- */
.filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-block: 16px 12px; box-shadow: var(--shadow);
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.field.search { grid-column: span 2; }
@media (max-width: 520px) { .field.search { grid-column: 1 / -1; } }
.filters-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 2px; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.toggle input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip small { opacity: .7; font-size: 12px; margin-left: 3px; }

/* ---------- deal list ---------- */
.results-bar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 14px 0 10px; color: var(--muted); font-size: 14px; }
.results-bar strong { color: var(--text); }
.deals { display: grid; gap: 14px; }
.deal {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.deal.is-target { outline: 2px solid var(--accent); outline-offset: 2px; }
.deal.is-expired .deal-main, .deal.is-expired .deal-price { opacity: .65; }
.deal-main { padding: 18px 20px; min-width: 0; }
.deal-head { display: flex; gap: 12px; align-items: flex-start; }
.brand-avatar { width: 44px; height: 44px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--muted); flex: none; overflow: hidden; }
.brand-avatar img { width: 100%; height: 100%; object-fit: contain; }
.deal-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.deal-variant { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.tags { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag-low { background: var(--save-soft); color: var(--save); }
.tag-new { background: var(--accent-soft); color: var(--accent); }
.tag-expired { background: var(--warn-soft); color: var(--warn); }
.specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px 24px; margin: 14px 0 0; padding: 0; }
.specs > div { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 8px; font-size: 14px; }
.specs dt { color: var(--muted); margin: 0; }
.specs dd { margin: 0; overflow-wrap: anywhere; }
.deal-note { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.deal-meta { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

.deal-price { padding: 18px 20px; background: var(--surface-2); border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.badge { align-self: flex-start; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 4px 9px; border-radius: 6px; }
.badge-great { background: var(--good-soft); color: var(--good); }
.badge-good { background: var(--accent-soft); color: var(--accent); }
.badge-ok { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.price { font-family: var(--font-display); font-size: 32px; font-weight: 800; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; margin-top: 4px; overflow-wrap: anywhere; }
.retailer { font-size: 14px; color: var(--muted); }
.save { color: var(--save); font-weight: 600; font-size: 14px; }
.was { color: var(--muted); font-size: 13px; }
.coupon { display: flex; align-items: center; gap: 8px; border: 1px dashed var(--border); background: var(--surface); border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 13px; text-align: left; margin-top: 4px; }
.coupon:hover { border-color: var(--accent); }
.coupon code { font-weight: 500; letter-spacing: .06em; }
.coupon .copy-state { margin-left: auto; font-size: 12px; color: var(--accent); font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; font-weight: 600; text-decoration: none; cursor: pointer; font-size: 15px; background: transparent; }
.btn-primary { background: var(--accent); color: var(--on-accent); margin-top: 6px; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--border); color: var(--text); height: 36px; font-size: 13px; padding: 0 10px; flex: 1; background: var(--surface); }
.btn-ghost:hover { border-color: var(--accent); }
.ic { display: inline-flex; }
.ic svg { width: 15px; height: 15px; }
.deal-actions { display: flex; gap: 6px; margin-top: 2px; }
.history { grid-column: 1 / -1; border-top: 1px solid var(--border); padding: 14px 20px 16px; background: var(--surface); }
.history-title { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.history-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0 0 12px; }
.history-stats > div { font-size: 12px; color: var(--muted); }
.history-stats strong { display: block; color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; font-family: var(--font-display); }
.history-stats .is-good { color: var(--good); }
.history-stats .is-bad { color: var(--save); }
.history-table { overflow-x: auto; }
.history table { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 320px; }
.history th, .history td { padding: 5px 16px 5px 0; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.history th { color: var(--muted); font-weight: 600; font-size: 12px; }
.history tr.is-current td { font-weight: 600; }
@media (max-width: 820px) {
  .deal { grid-template-columns: 1fr; }
  .deal-price { border-left: 0; border-top: 1px solid var(--border); }
}
.empty { padding: 40px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- content sections ---------- */
.section { padding-block: 28px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
h2 { font-family: var(--font-display); font-size: 24px; letter-spacing: -.01em; margin: 0 0 10px; line-height: 1.2; text-wrap: balance; }
.prose { max-width: 70ch; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose h2 { margin-top: 28px; }
.prose h3 { font-size: 17px; margin: 22px 0 6px; font-family: var(--font-display); }
.prose li { margin-bottom: 4px; }
.page-title { font-family: var(--font-display); font-size: clamp(28px, 4vw, 36px); font-weight: 800; letter-spacing: -.02em; margin: 28px 0 6px; line-height: 1.1; }
.page-lede { color: var(--muted); margin: 0 0 20px; max-width: 65ch; }
.faq details { border-top: 1px solid var(--border); padding: 12px 0; }
.faq details:last-child { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; font-weight: 600; font-family: var(--font-display); font-size: 16px; }
.faq details p { margin: 8px 0 0; color: var(--muted); }
.cta-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; background: var(--accent-soft); border-color: transparent; }
.cta-card h2 { margin: 0 0 4px; }
.cta-card p { margin: 0; color: var(--muted); }
.steps { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 0; padding: 0; list-style: none; }
.steps li { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; font-size: 14px; color: var(--muted); }
.steps strong { display: block; font-family: var(--font-display); font-size: 16px; margin-bottom: 4px; color: var(--text); }
.placeholder { background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 0 4px; }

/* ---------- footer ---------- */
.site-footer { margin-top: 40px; border-top: 1px solid var(--border); background: var(--surface); padding-block: 30px; font-size: 14px; color: var(--muted); }
.footer-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.footer-h { font-family: var(--font-display); font-size: 15px; color: var(--text); margin: 0 0 6px; }
.site-footer p { margin: 0 0 8px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.footer-links a { color: var(--text); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
.disclosure { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }
.copyright { font-size: 13px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 14px; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
