/* ─────────────────────────────────────────────────────────────
   Should I Get Gas — Production Stylesheet
   Mobile-first, responsive to desktop at 900px.
   Design tokens are injected via --display-font CSS variable.
   ───────────────────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

button, a, [role="button"], input, select, textarea {
  touch-action: manipulation;
}

html, body {
  height: 100%;
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: none;
  background: #0a0b0e;
  color: #fff;
}

#root { height: 100%; }

.app-root {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.no-motion *, .no-motion *::before, .no-motion *::after {
  animation: none !important;
  transition: none !important;
}
.no-motion .reveal-item,
.no-motion .word-reveal { opacity: 1 !important; }
.no-motion .spark-draw { stroke-dashoffset: 0 !important; }
.no-motion .spark-area-in,
.no-motion .spark-dot-in { opacity: 1 !important; }

/* ─── Background wash ─── */
.wash-root { position: fixed; inset: 0; z-index: 0; }
.wash-layer { position: absolute; inset: 0; background-size: cover; }
@keyframes washIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Grain texture ─── */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* ─── Layout shell ─── */
.site-wrap {
  position: relative; z-index: 2;
  /* svh = the *small* viewport (iOS toolbar visible), so the footer is
     guaranteed above Safari's bottom toolbar on first paint; 100vh would size
     to the larger toolbar-collapsed viewport and hide the last line. The vh
     line is a fallback for browsers that don't understand svh. */
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0px) 0 0;
}

/* ─── Top bar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 20px 0;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.brand {
  font-family: var(--display-font, 'Bricolage Grotesque'), sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  display: none; /* hidden on mobile */
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; flex-shrink: 0;
}

.chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .15s ease;
  background: none; color: inherit;
  white-space: nowrap;
}
.chip:active { transform: scale(0.96); }

.pin {
  width: 8px; height: 8px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 1.5px solid;
  flex-shrink: 0;
}
.pin.filled { border: 0; }

.d-updated { font-size: 13px; font-weight: 500; display: none; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 999px; border: 1.5px solid;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .15s ease;
  background: none; color: inherit;
}
.icon-btn:active { transform: scale(0.92); }

/* ─── Location dropdown ─── */
.chip-wrap { position: relative; }
.loc-dropdown {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 40;
  width: 300px; border: 1.5px solid; border-radius: 16px; padding: 7px;
  backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; gap: 4px;
  animation: menuIn .2s ease;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

.loc-item {
  display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left;
  font-family: inherit; font-size: 14px; font-weight: 600; color: inherit;
  background: rgba(127,127,127,0.08); border: 1.5px solid transparent;
  border-radius: 10px; padding: 10px 12px; transition: background .12s ease;
}
.loc-item:hover { background: rgba(127,127,127,0.18); }
.loc-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.loc-name { flex: 1; }
.loc-price { font-variant-numeric: tabular-nums; opacity: 0.7; font-size: 13px; }
.loc-verdict { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; min-width: 52px; text-align: right; }
.loc-empty { opacity: 0.55; font-size: 13px; padding: 10px 4px; }

/* ─── Main layout ─── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 32px;
  gap: 20px;
}

/* ─── Hero ─── */
.hero {
  display: flex;
  flex-direction: column;
  padding-top: 8px;
}

.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; margin-bottom: 10px;
}

/* ─── Gas Price Display — glanceable price widget ─── */
.price-display {
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

/* price + delta on same baseline */
.price-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.price-number {
  font-family: var(--display-font, 'Bricolage Grotesque'), sans-serif;
  font-weight: 800;
  font-size: 68px;
  line-height: 1;
  letter-spacing: -0.048em;
  font-variant-numeric: tabular-nums;
}

/* direction + change — compact, badge-like, accent color */
.price-delta-badge {
  font-family: var(--display-font, 'Bricolage Grotesque'), sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  line-height: 1;
  /* sits slightly above baseline for optical balance */
  position: relative;
  top: -4px;
}

/* quiet attribution line */
.price-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 9px;
  opacity: 0.48;
}

.price-unit-inline {
  opacity: 0.6;
  letter-spacing: 0.04em;
}

.verdict-word {
  font-family: var(--display-font, 'Bricolage Grotesque'), sans-serif;
  font-weight: 800;
  font-size: 88px;
  line-height: 0.86;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  text-wrap: balance;
}

.tagline {
  font-size: 17px;
  font-weight: 600;
  margin-top: 13px;
}

.why {
  font-size: 15px;
  line-height: 1.5;
  margin-top: 10px;
  max-width: 440px;
  text-wrap: pretty;
}

/* ─── Support cards (mobile) ─── */
.support-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.support-card {
  border: 1.5px solid;
  border-radius: 18px;
  padding: 13px 15px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sup-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.sup-label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.advice { font-size: 14px; font-weight: 700; }
.delta { font-size: 12px; font-weight: 600; }

/* ─── Day strip ─── */
.daystrip { display: flex; justify-content: space-between; }
.day-col { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.day-cell {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all .3s ease; font-weight: 500;
}
.day-tick { width: 4px; height: 4px; border-radius: 50%; }

/* ─── Sparkline ─── */
.spark { width: 100%; display: block; }
.sparkline-empty { width: 100%; height: 60px; display: block; }
.spark-draw {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: sparkDraw 1s ease .25s forwards;
}
.spark-area-in { opacity: 0; animation: fadeIn .8s ease .5s forwards; }
.spark-dot-in { opacity: 0; animation: fadeIn .4s ease 1.1s forwards; }
@keyframes sparkDraw { to { stroke-dashoffset: 0; } }

/* ─── Context link + GasBuddy button ─── */
.ctx-link {
  align-self: center; background: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 5px 10px; color: inherit; white-space: nowrap;
}

.gb-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  padding: 14px 20px; border-radius: 16px; border: 1.5px solid;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: transform .15s ease, background .2s ease;
  color: inherit; width: 100%; text-align: left;
}
.gb-btn:active { transform: scale(0.985); }
.gb-btn:hover { background: rgba(255,255,255,0.1); }
.gb-btn-arrow { font-weight: 700; }

/* ─── Context stats grid ─── */
.ctx-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px;
}
.ctx-stat { border-radius: 14px; padding: 12px 14px; }
.ctx-k { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.62; }
.ctx-v {
  font-family: var(--display-font, 'Bricolage Grotesque'), sans-serif;
  font-weight: 700; font-size: 24px; margin-top: 3px;
}
.src-link {
  display: inline-block; margin-top: 5px; font-size: 11px; font-weight: 700;
  text-decoration: none;
}
.src-link:hover { text-decoration: underline; }

/* ─── News carousel ─── */
.news-wrap { margin-bottom: 16px; }
.news-pills {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 9px; scrollbar-width: none;
}
.news-pills::-webkit-scrollbar { display: none; }
.news-pill {
  flex: 0 0 auto; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 5px 12px; border-radius: 999px; border: 1.5px solid;
  transition: all .15s ease; white-space: nowrap; background: none; color: inherit;
}
.news-pill:active { transform: scale(0.95); }
.news-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.news-track::-webkit-scrollbar { display: none; }
.news-card {
  flex: 0 0 100%; scroll-snap-align: start; border-radius: 14px; padding: 13px 15px;
  display: flex; flex-direction: column; gap: 8px; box-sizing: border-box;
}
.news-head { font-size: 14px; line-height: 1.42; }
.news-src { font-size: 12px; font-weight: 700; text-decoration: none; }
.news-src:hover { text-decoration: underline; }
.news-dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.news-dot { height: 6px; border-radius: 99px; cursor: pointer; transition: width .25s ease, background .25s ease; }

/* ─── Price breakdown ─── */
.breakdown-head {
  display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 12px;
}
.breakdown-head .ctx-k { white-space: nowrap; }
.breakdown-head .src-link { margin-top: 0; }
.meter-row { margin-bottom: 10px; }
.meter-row:last-child { margin-bottom: 0; }
.meter-top {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 600; margin-bottom: 5px;
}
.meter-track { height: 7px; border-radius: 99px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }
.ctx-foot { font-size: 12px; opacity: 0.45; margin-top: 14px; text-align: center; }

/* ─── Location search (mobile sheet) ─── */
.loc-search {
  width: 100%; border: 0; outline: none; border-radius: 12px;
  padding: 11px 14px; font-family: inherit; font-size: 16px; margin-bottom: 12px;
}
.loc-list { display: flex; flex-direction: column; gap: 6px; }

/* ─── Bottom sheet (mobile context) ─── */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0); pointer-events: none; transition: background .3s ease;
  display: flex; align-items: flex-end;
}
.sheet-overlay.open { background: rgba(0,0,0,0.46); pointer-events: auto; }
.sheet {
  width: 100%; max-height: 88%; overflow-y: auto;
  border-radius: 26px 26px 0 0;
  padding: 12px 20px calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translateY(102%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
  backdrop-filter: blur(28px) saturate(160%); -webkit-backdrop-filter: blur(28px) saturate(160%);
  box-shadow: 0 -24px 60px rgba(0,0,0,0.32);
}
.sheet.open { transform: translateY(0); }
.sheet-grab {
  width: 38px; height: 4px; border-radius: 99px;
  margin: 2px auto 14px;
}
.sheet-title {
  font-family: var(--display-font, 'Bricolage Grotesque'), sans-serif;
  font-weight: 700; font-size: 20px; margin-bottom: 14px;
}

/* ─── Toast ─── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  z-index: 60; background: rgba(18,18,22,0.92); color: #fff;
  backdrop-filter: blur(12px); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: all .28s ease; white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ─── Loading / error states ─── */
.loading-screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: #0a0b0e;
}
.loading-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.4);
  animation: loadPulse 1.1s ease infinite;
}
.loading-dot:nth-child(2) { animation-delay: .15s; }
.loading-dot:nth-child(3) { animation-delay: .3s; }
@keyframes loadPulse { 0%,80%,100% { transform: scale(0.7); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }
.loading-dots { display: flex; gap: 10px; }

/* ─── Animations ─── */
@keyframes fadeIn { to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes wordIn { from { opacity: 0; transform: translateY(20px) scale(0.94); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.reveal-item { opacity: 0; animation: rise .55s cubic-bezier(.2,.7,.2,1) forwards; }
.word-reveal { animation: wordIn .6s cubic-bezier(.2,.7,.2,1) forwards; }
.spin { animation: spin .9s linear infinite; }
.chip-pulse { animation: pulse 1s ease infinite; }

/* ─── Mobile layout (max 899px): natural vertical scroll SPA ─── */
@media (max-width: 899px) {
  /* The page is a normal scrolling document; the viewport is NOT pinned to one
     screen, so the footer (EIA source / raw-data link) is always reachable.
     svh (not dvh/vh) sizes to the toolbar-visible viewport, so the footer clears
     Safari's bottom toolbar on first paint instead of hiding underneath it. */
  .site-wrap {
    min-height: 100vh;
    min-height: 100svh;
    overflow: visible;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .main-content {
    padding: 12px 20px 16px;
    gap: 12px;
  }

  .hero {
    padding-top: 0;
  }

  .eyebrow {
    margin-bottom: 5px;
  }

  .price-display {
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .price-number {
    font-size: clamp(48px, 13vw, 68px);
  }

  .verdict-word {
    font-size: clamp(64px, 18vw, 88px);
  }

  .tagline {
    margin-top: 6px;
  }

  .why {
    margin-top: 5px;
  }

  .support-cards {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
  }

  .support-cards .support-card {
    flex: 1;
    min-width: 0;
  }

  .support-cards .ctx-link,
  .support-cards .gb-btn,
  .support-cards .mobile-attribution {
    flex: 0 0 100%;
  }

  /* The buried mobile attribution is now redundant — the real footer renders. */
  .mobile-attribution { display: none; }

  .site-footer {
    display: block;
    /* Extra bottom breathing room: in a browser tab env(safe-area-inset-bottom)
       is 0, so the toolbar can still clip the last line — pad beyond it. */
    padding: 14px 20px calc(28px + env(safe-area-inset-bottom, 0px));
    text-align: center;
    font-size: 12px;
  }

  .day-cell {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }

  .sup-label { font-size: 10px; }
  .delta     { font-size: 10px; }
  .advice    { font-size: 12px; }
}

/* ─── Desktop layout (≥900px) ─── */
@media (min-width: 900px) {
  .app-root { overflow-x: hidden; }
  .site-wrap { min-height: 100vh; min-height: 100svh; }

  .topbar {
    padding: 24px 40px 0;
    position: relative;
  }

  .brand { display: flex; }
  .d-updated { display: block; }

  .main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 460px;
    gap: 48px;
    padding: 12px 40px 40px;
    align-items: center;
  }

  /* On desktop, hero takes the left column */
  .hero {
    padding-top: 0;
    justify-content: center;
  }

  .verdict-word {
    font-size: 128px;
    line-height: 0.84;
  }

  .price-number { font-size: 80px; }
  .price-delta-badge { font-size: 22px; padding: 5px 13px; }
  .price-label { font-size: 12px; margin-top: 10px; }

  .tagline { font-size: 21px; margin-top: 22px; }
  .why { font-size: 18px; line-height: 1.5; margin-top: 14px; max-width: 480px; }
  .price-display { margin-bottom: 28px; padding-bottom: 24px; }

  .hero-actions {
    margin-top: 32px;
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  }

  .gb-btn { width: auto; font-size: 16px; padding: 15px 24px; }
  .gb-hint { font-size: 13px; opacity: 0.55; }

  /* Context rail fills the right column */
  .context-rail {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 120px);
    max-height: calc(100svh - 120px);
    overflow-y: auto;
    padding-right: 2px;
  }
  .context-rail::-webkit-scrollbar { width: 5px; }
  .context-rail::-webkit-scrollbar-thumb { background: rgba(127,127,127,0.35); border-radius: 99px; }

  /* Cards in the desktop rail */
  .rail-card {
    border: 1.5px solid; border-radius: 18px; padding: 14px 16px;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  }

  /* Hide mobile-only support cards */
  .support-cards { display: none !important; }
}

/* Context rail is hidden on mobile (shown via sheet) */
.context-rail { display: none; }

/* hero-actions (GasBuddy + hint): desktop-only, hidden on mobile to avoid duplicate */
.hero-actions { display: none; }
.gb-hint { display: none; }

/* Legacy attribution line inside support-cards — superseded by .site-footer,
   which renders at every breakpoint. Kept hidden so the footer isn't duplicated
   on mobile (a previous rule re-showed it, causing a double footer). */
.mobile-attribution {
  display: none;
  font-size: 11px;
  opacity: 0.42;
  text-align: center;
  padding-top: 2px;
}

@media (min-width: 900px) {
  .hero-actions { display: flex; }
  .gb-hint { display: inline; }
}

/* ─── Footer ─── */
.site-footer {
  position: relative; z-index: 2;
  padding: 16px 20px;
  font-size: 12px;
  opacity: 0.42;
  text-align: center;
}
@media (min-width: 900px) {
  .site-footer { padding: 12px 40px; text-align: right; }
}
