/* ============================================================
   West Bragg Creek Ride Conditions — styles
   Mobile-first, dark, card-based, touch-friendly.
   ============================================================ */

:root {
  --bg:            #0f1411;
  --bg-card:       #1a211c;
  --bg-card-hi:    #222b25;
  --text:          #e8efe9;
  --text-dim:      #9bb0a2;
  --text-faint:    #6f8478;
  --border:        #2c3730;
  --accent:        #4ade80;

  --green:         #34d399;
  --yellow:        #fbbf24;
  --red:           #f87171;
  --grey:          #6b7c72;

  --radius:        16px;
  --gap:           14px;
  --maxw:          720px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 18px 14px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  z-index: 10;
}
.app-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.app-subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.refresh-btn {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s, transform .15s;
}
.refresh-btn:active { transform: scale(0.92); background: var(--bg-card-hi); }
.refresh-btn.is-spinning .refresh-btn__icon { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dashboard grid ---------- */
.dashboard {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 4px 14px 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
}
.card__title {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.card__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card__title-row .card__title { margin-bottom: 12px; }
.card__note {
  margin: 12px 0 0;
  font-size: 0.74rem;
  color: var(--text-faint);
  line-height: 1.4;
}
.card__source {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.card__source:active { opacity: .6; }

/* ---------- Verdict card ---------- */
.card--verdict {
  background: linear-gradient(160deg, var(--bg-card-hi), var(--bg-card));
  border-color: #34433a;
}
.verdict__headline {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.verdict__detail {
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--text-dim);
}
.verdict--good .verdict__headline { color: var(--green); }
.verdict--caution .verdict__headline { color: var(--yellow); }
.verdict--wet .verdict__headline { color: var(--red); }

/* ---------- Stoplight ---------- */
.stoplight {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stoplight__dot {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--grey);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.04);
}
.stoplight__dot--green  { background: var(--green);  box-shadow: 0 0 14px -2px var(--green); }
.stoplight__dot--yellow { background: var(--yellow); box-shadow: 0 0 14px -2px var(--yellow); }
.stoplight__dot--red    { background: var(--red);    box-shadow: 0 0 14px -2px var(--red); }
.stoplight__dot--loading { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.stoplight__label {
  font-size: 1.05rem;
  font-weight: 600;
}
.stoplight__commentary {
  margin-top: 2px;
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* ---------- Webcams ---------- */
.webcams {
  display: grid;
  gap: 10px;
}
.webcam {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #0a0d0b;
  aspect-ratio: 16 / 9;
}
.webcam img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.webcam__caption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 0.72rem;
  background: rgba(0,0,0,0.6);
  padding: 3px 8px;
  border-radius: 6px;
  color: #fff;
}
.webcam__fail {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 0.85rem;
  color: var(--text-faint);
  text-align: center;
  padding: 12px;
}
.mini-btn {
  border: 1px solid var(--border);
  background: var(--bg-card-hi);
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 32px;
}
.mini-btn:active { background: var(--border); }

/* ---------- Weather stats ---------- */
.weather-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  background: var(--bg-card-hi);
  border-radius: 12px;
  padding: 12px 14px;
}
.stat__value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.stat__label {
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ---------- Sun ---------- */
.card--sun .sun-row {
  display: flex;
  gap: 12px;
}
.sun-item {
  flex: 1;
  background: var(--bg-card-hi);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.sun-item__icon { font-size: 1.1rem; display: block; color: var(--yellow); }
.sun-item__time { font-size: 1.25rem; font-weight: 700; display: block; margin-top: 4px; }
.sun-item__label { font-size: 0.72rem; color: var(--text-dim); }

/* ---------- Social links ---------- */
.links { display: grid; gap: 10px; }
.link-btn {
  display: flex;
  flex-direction: column;
  background: var(--bg-card-hi);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
  text-decoration: none;
  color: var(--text);
  min-height: 56px;
  justify-content: center;
  transition: background .15s;
}
.link-btn:active { background: var(--border); }
.link-btn__name { font-weight: 600; font-size: 0.95rem; }
.link-btn__sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* ---------- Footer ---------- */
.app-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 18px 28px;
  font-size: 0.72rem;
  color: var(--text-faint);
  text-align: center;
}
.app-footer__sep { margin: 0 6px; }

/* ---------- Error / stale states ---------- */
.is-error .stat__value,
.is-error .verdict__headline { color: var(--text-faint); }

/* ---------- Desktop ---------- */
@media (min-width: 680px) {
  .dashboard {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .card--verdict { grid-column: 1 / -1; }
  .verdict__headline { font-size: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
