/* Petron Baguio Watch — mobile-first PWA */
:root {
  --petron-red: #C8102E;
  --petron-red-dark: #9C0B22;
  --petron-blue: #003478;
  --petron-yellow: #FFC72C;
  --bg: #0E1116;
  --surface: #171B22;
  --surface-2: #1F242C;
  --surface-3: #2A2F38;
  --text: #F5F6F8;
  --text-dim: #A4ACB8;
  --text-faint: #6C7380;
  --success: #23D18B;
  --danger: #FF5B5B;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}

body {
  background:
    radial-gradient(1200px 600px at 100% -100px, rgba(200, 16, 46, 0.18), transparent 60%),
    radial-gradient(800px 500px at -10% 10%, rgba(0, 52, 120, 0.22), transparent 60%),
    var(--bg);
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 4px 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--petron-red), var(--petron-red-dark));
  display: grid;
  place-items: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.4);
}

.app-header h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: -0.2px;
  font-weight: 700;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: var(--surface-2);
}

.icon-btn.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Forecast banner */
.forecast-banner {
  display: flex;
  gap: 14px;
  background: linear-gradient(135deg, rgba(200, 16, 46, 0.12), rgba(0, 52, 120, 0.12));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  align-items: center;
}

.forecast-badge {
  min-width: 58px;
  padding: 10px 8px;
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.forecast-badge.hike { background: rgba(255, 91, 91, 0.15); color: var(--danger); }
.forecast-badge.rollback { background: rgba(35, 209, 139, 0.15); color: var(--success); }
.forecast-badge.mixed { background: rgba(255, 199, 44, 0.15); color: var(--petron-yellow); }

.forecast-title {
  margin: 0 0 2px;
  font-size: 13px;
  color: var(--text-dim);
}

.forecast-title span {
  color: var(--text);
  font-weight: 600;
}

.forecast-detail {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

/* Sections */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.section h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.1px;
  font-weight: 700;
}

.pill {
  background: var(--surface-2);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

/* Price grid */
.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.price-card {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 3px solid var(--petron-red);
}

.price-card.gas { border-top-color: var(--petron-red); }
.price-card.diesel { border-top-color: var(--petron-blue); }
.price-card.kero { border-top-color: var(--petron-yellow); }

.price-card .label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.price-card .price {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: baseline;
  gap: 1px;
}

.price-card .price small {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.price-card .delta {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
}

.delta.up { color: var(--danger); }
.delta.down { color: var(--success); }
.delta.flat { color: var(--text-dim); }

.compare-row {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.compare-row strong {
  color: var(--text);
}

/* Chart */
.chart-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
}

.tab {
  background: transparent;
  color: var(--text-dim);
  border: 0;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 7px;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: all 0.15s ease;
}

.tab.active {
  background: var(--petron-red);
  color: #fff;
}

.chart-wrap {
  height: 240px;
  position: relative;
}

.chart-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Why list */
.why-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Legacy plain-string items (fallback) */
.why-list > li:not(.why-item) {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
}

.why-list > li:not(.why-item)::before {
  content: "→";
  color: var(--petron-red);
  font-weight: 900;
  flex-shrink: 0;
}

/* Clickable / expandable reason cards */
.why-item {
  background: var(--surface-2);
  border-radius: 12px;
  overflow: hidden;
  transition: background 0.15s ease;
}

.why-item.open {
  background: var(--surface-3);
}

.why-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  transition: background 0.15s ease;
}

.why-head:hover {
  background: rgba(255, 255, 255, 0.02);
}

.why-head:active {
  background: rgba(255, 255, 255, 0.04);
}

.why-text {
  flex: 1;
  min-width: 0;
}

.why-title {
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.why-title::before {
  content: "→";
  color: var(--petron-red);
  font-weight: 900;
  flex-shrink: 0;
}

.why-summary {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  padding-left: 16px;
}

.why-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.impact-pill {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 7px;
  border-radius: 999px;
}

.impact-high {
  background: rgba(255, 91, 91, 0.15);
  color: var(--danger);
}

.impact-medium {
  background: rgba(255, 199, 44, 0.15);
  color: var(--petron-yellow);
}

.impact-low {
  background: rgba(35, 209, 139, 0.15);
  color: var(--success);
}

.why-chev {
  color: var(--text-dim);
  font-size: 13px;
  transition: transform 0.2s ease;
  display: inline-block;
}

.why-item.open .why-chev {
  transform: rotate(180deg);
}

.why-body {
  padding: 0 14px 14px 30px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.why-detail {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.why-src-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 6px;
}

.why-sources {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.why-sources li a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--petron-red);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 10px;
  background: rgba(200, 16, 46, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(200, 16, 46, 0.15);
  transition: background 0.12s ease;
}

.why-sources li a:hover,
.why-sources li a:active {
  background: rgba(200, 16, 46, 0.15);
}

.why-sources li a::before {
  content: "↗";
  font-weight: 800;
  flex-shrink: 0;
}

.why-updated {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 8px;
  letter-spacing: 0.3px;
}

/* Station list */
.station-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.station-list li {
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 13px;
}

.station-list .station-name {
  font-weight: 700;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.station-list .station-note {
  color: var(--petron-yellow);
  font-size: 11px;
  font-weight: 600;
  margin-top: 3px;
}

.station-list .station-addr {
  color: var(--text-dim);
  font-size: 12px;
}

/* Alerts */
.supply .section-header h2 {
  color: var(--petron-yellow);
}

.alert-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-list li {
  padding: 10px 12px;
  background: rgba(255, 199, 44, 0.08);
  border-left: 3px solid var(--petron-yellow);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.alert-list .alert-date {
  color: var(--petron-yellow);
  font-weight: 700;
  font-size: 11px;
  display: block;
  margin-bottom: 2px;
}

/* Install card */
.install-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--petron-red), var(--petron-blue));
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.install-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.install-card p {
  margin: 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}

.install-card.hidden {
  display: none;
}

.btn-primary {
  background: #fff;
  color: var(--petron-red);
  border: 0;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.btn-primary:active {
  transform: scale(0.95);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 20px 10px 10px;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.5;
}

.app-footer p {
  margin: 4px 0;
}

.app-footer .tiny {
  font-size: 10px;
  color: var(--text-faint);
  opacity: 0.7;
}

.credits {
  padding: 14px 12px 16px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.credits-line {
  font-size: 12.5px;
  margin: 0 0 10px !important;
  color: var(--text-dim);
}

.credits-line strong {
  color: var(--text);
  font-weight: 700;
}

.contact-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--petron-red), var(--petron-red-dark));
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.25);
}

.contact-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.35);
}

.contact-btn:active {
  transform: translateY(0);
}

.contact-btn svg {
  flex-shrink: 0;
}

/* Light mode (if user prefers) */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #F5F6F8;
    --surface: #FFFFFF;
    --surface-2: #F0F2F5;
    --surface-3: #E5E8EC;
    --text: #0E1116;
    --text-dim: #5A6372;
    --text-faint: #8B93A1;
    --border: rgba(0, 0, 0, 0.08);
    --shadow: 0 4px 16px rgba(14, 17, 22, 0.08);
  }
}

/* =========================================================
   Responsive layout — tablet & desktop (placed at end so
   these rules correctly override the mobile defaults above).
   ========================================================= */
@media (min-width: 900px) {
  body {
    padding: 24px 0;
  }
  .container {
    max-width: 1180px;
    padding: 0 28px 48px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "header    header"
      "forecast  forecast"
      "prices    prices"
      "chart     why"
      "stations  supply"
      "install   install"
      "footer    footer";
    gap: 16px 20px;
  }
  .app-header { grid-area: header; margin-bottom: 0; }
  .forecast-banner { grid-area: forecast; margin-bottom: 0; }
  .section.prices-section { grid-area: prices; margin-bottom: 0; }
  .section.chart-section { grid-area: chart; margin-bottom: 0; }
  .section.why-section { grid-area: why; margin-bottom: 0; }
  .section.stations-section { grid-area: stations; margin-bottom: 0; }
  .section.supply { grid-area: supply; margin-bottom: 0; }
  .install-card { grid-area: install; margin-bottom: 0; }
  .app-footer { grid-area: footer; margin-top: 8px; }

  .app-header h1 { font-size: 22px; }
  .subtitle { font-size: 13px; }
  .logo { width: 52px; height: 52px; font-size: 28px; }
  .section { padding: 20px; }
  .section h2 { font-size: 17px; }

  .price-card .price { font-size: 28px; }
  .price-card .label { font-size: 12px; }
  .chart-wrap { height: 360px; }

  /* Why-list scrollable on desktop so the chart column + why column align */
  .why-section .why-list {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
  }

  /* Hover affordances on desktop */
  .station-list li,
  .alert-list li {
    transition: transform 0.12s ease;
  }
  .station-list li:hover {
    transform: translateX(3px);
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1320px;
  }
  .chart-wrap { height: 420px; }
  .why-section .why-list { max-height: 420px; }
}
