/* ==========================================================================
   Braai-o-Meter — charcoal & ember theme, mobile-first
   ========================================================================== */

:root {
  --charcoal: #16120e;
  --charcoal-soft: #221a13;
  --card: #2a2018;
  --card-edge: #3d2e1f;
  --ember: #ff7a1a;
  --ember-bright: #ffa04d;
  --flame-yellow: #ffd166;
  --smoke-text: #c9b8a5;
  --ash-text: #8a7a68;
  --cream: #fff3e4;
  --whatsapp: #25d366;
  --gain: #7ddc8e;
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 60% at 50% 0%, #2b1c0e 0%, var(--charcoal) 60%),
    var(--charcoal);
  color: var(--cream);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  text-align: center;
  overflow-x: hidden;
}

/* --- shared inline SVG icon sizing --- */
.icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.18em;
  display: inline-block;
}

/* --- subtle drifting smoke, pure CSS --- */
.smoke {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 25% at 20% 85%, rgba(255, 170, 90, 0.06), transparent 70%),
    radial-gradient(50% 30% at 80% 90%, rgba(255, 200, 120, 0.05), transparent 70%);
  animation: smoke-drift 14s ease-in-out infinite alternate;
  z-index: 0;
}
@keyframes smoke-drift {
  from { transform: translateY(0) scale(1);      opacity: 0.9; }
  to   { transform: translateY(-24px) scale(1.06); opacity: 0.6; }
}

/* --- rising embers, pure CSS --- */
.embers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.embers span {
  position: absolute;
  bottom: -8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 6px 2px rgba(255, 122, 26, 0.45);
  opacity: 0;
  animation: ember-rise 7s linear infinite;
}
.embers span:nth-child(1) { left: 12%; animation-delay: 0s;    animation-duration: 8s; }
.embers span:nth-child(2) { left: 28%; animation-delay: 2.4s;  animation-duration: 7s;  width: 4px; height: 4px; }
.embers span:nth-child(3) { left: 47%; animation-delay: 4.8s;  animation-duration: 9s; }
.embers span:nth-child(4) { left: 63%; animation-delay: 1.2s;  animation-duration: 7.5s; width: 3px; height: 3px; }
.embers span:nth-child(5) { left: 79%; animation-delay: 3.6s;  animation-duration: 8.5s; }
.embers span:nth-child(6) { left: 91%; animation-delay: 5.5s;  animation-duration: 6.5s; width: 4px; height: 4px; }
@keyframes ember-rise {
  0%   { transform: translateY(0) translateX(0);        opacity: 0; }
  8%   { opacity: 0.85; }
  50%  { transform: translateY(-45vh) translateX(-14px); opacity: 0.5; }
  100% { transform: translateY(-92vh) translateX(10px);  opacity: 0; }
}

/* --- header --- */
.site-header {
  position: relative;
  z-index: 1;
  padding: 1.1rem 1rem 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
.brand-flame {
  display: inline-flex;
  animation: flicker 1.6s ease-in-out infinite;
}
.brand-flame svg { width: 1.7rem; height: 1.7rem; }
@keyframes flicker {
  0%, 100% { transform: scale(1)    rotate(-2deg); }
  40%      { transform: scale(1.12) rotate(2deg); }
  70%      { transform: scale(0.96) rotate(-1deg); }
}
.brand-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--ember-bright), var(--flame-yellow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --- layout --- */
#app {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 0.5rem 1rem 1.5rem;
}
.screen[hidden] { display: none; }
.screen { animation: fade-in 0.4s ease both; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.screen-title { font-size: 1.35rem; margin: 2rem 0 0.4rem; }
.screen-subtitle { color: var(--smoke-text); margin-bottom: 1.2rem; font-size: 0.95rem; }

/* --- loading --- */
#screen-loading { padding-top: 4rem; }
.flame-loader {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  height: 64px;
  margin-bottom: 1.4rem;
}
.flame {
  width: 16px;
  border-radius: 50% 50% 40% 40%;
  background: linear-gradient(to top, var(--ember), var(--flame-yellow));
  animation: lick 0.9s ease-in-out infinite;
}
.f1 { height: 34px; animation-delay: 0s;    }
.f2 { height: 52px; animation-delay: 0.15s; }
.f3 { height: 38px; animation-delay: 0.3s;  }
@keyframes lick {
  0%, 100% { transform: scaleY(1);   filter: brightness(1); }
  50%      { transform: scaleY(1.25); filter: brightness(1.25); }
}
.loading-message {
  color: var(--smoke-text);
  font-size: 1.05rem;
  min-height: 1.6em;
}

/* --- town form --- */
.town-form { display: flex; flex-direction: column; gap: 0.7rem; }
#town-input {
  padding: 0.9rem 1rem;
  font-size: 1.05rem;
  border-radius: var(--radius);
  border: 2px solid var(--card-edge);
  background: var(--charcoal-soft);
  color: var(--cream);
  text-align: center;
  outline: none;
}
#town-input:focus { border-color: var(--ember); }
#town-input::placeholder { color: var(--ash-text); }

/* --- buttons --- */
.btn {
  display: block;
  width: 100%;
  padding: 0.95rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--charcoal);
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary   { background: linear-gradient(135deg, var(--ember), var(--flame-yellow)); }
.btn-whatsapp  { background: var(--whatsapp); color: #06240f; }
.btn-secondary {
  background: transparent;
  color: var(--ember-bright);
  border: 2px solid var(--card-edge);
}
.btn-link {
  background: none;
  border: none;
  color: var(--ash-text);
  text-decoration: underline;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.9rem;
  padding: 0.4rem;
}

/* --- score card (the hero) --- */
.score-card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.3rem;
  margin-top: 0.4rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.score-town {
  color: var(--ember-bright);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* golden braai hour badge */
.golden-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #3a2a00;
  background: linear-gradient(120deg, var(--flame-yellow), #ffe9a8, var(--flame-yellow));
  background-size: 200% 100%;
  animation: golden-shimmer 3s linear infinite;
}
.golden-badge[hidden] { display: none; }
@keyframes golden-shimmer {
  from { background-position: 0% 0; }
  to   { background-position: 200% 0; }
}

.gauge-wrap { position: relative; margin: 0.3rem auto 0; max-width: 280px; }
.gauge { width: 100%; display: block; }
.gauge-track { stroke: var(--card-edge); }
.gauge-fill {
  stroke: var(--ember); /* recoloured from script.js based on the score */
  filter: drop-shadow(0 0 6px rgba(255, 122, 26, 0.55));
  transition: stroke-dashoffset 1s cubic-bezier(0.25, 1, 0.4, 1), stroke 0.5s ease;
}
.score-number {
  position: absolute;
  left: 0; right: 0;
  bottom: 6%;
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  color: var(--cream);
  text-shadow: 0 2px 18px rgba(255, 122, 26, 0.35);
}
/* fixed-width, digit-stable box so the count-up never nudges the layout */
#result-score {
  display: inline-block;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.score-outof { font-size: 1.5rem; font-weight: 700; color: var(--ash-text); }

.score-verdict {
  font-size: 1.25rem;
  font-weight: 800;
  margin-top: 0.7rem;
  color: var(--flame-yellow);
}
.score-commentary {
  color: var(--smoke-text);
  margin-top: 0.5rem;
  font-size: 1rem;
  line-height: 1.45;
}
.score-weather {
  color: var(--ash-text);
  margin-top: 0.7rem;
  font-size: 0.85rem;
}

/* --- "How we scored it" breakdown --- */
.breakdown {
  margin-top: 0.9rem;
  text-align: left;
  border-top: 1px solid var(--card-edge);
  padding-top: 0.7rem;
}
.breakdown summary {
  cursor: pointer;
  color: var(--ember-bright);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  list-style: none;
}
.breakdown summary::-webkit-details-marker { display: none; }
.breakdown summary::after { content: " ▾"; color: var(--ash-text); }
.breakdown[open] summary::after { content: " ▴"; }
.breakdown-list { list-style: none; margin-top: 0.7rem; }
.breakdown-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0.2rem;
  font-size: 0.92rem;
  border-bottom: 1px dashed rgba(61, 46, 31, 0.6);
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-icon { color: var(--ash-text); display: inline-flex; }
.breakdown-icon .icon { width: 1.15rem; height: 1.15rem; }
.breakdown-label { flex: 1; color: var(--smoke-text); }
.breakdown-points { font-weight: 800; font-variant-numeric: tabular-nums; }
.breakdown-points.pos  { color: var(--gain); }
.breakdown-points.neg  { color: var(--ember-bright); }
.breakdown-points.zero { color: var(--ash-text); }

/* --- drink card --- */
.drink-card {
  background: linear-gradient(160deg, #2c1f2e, #241a26);
  border: 1px solid #4a3350;
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem;
  margin-top: 0.9rem;
  position: relative;
  overflow: hidden;
}
.drink-title {
  font-size: 1.15rem;
  color: #e8c8ff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
.drink-plane {
  display: inline-flex;
  margin-top: 0.45rem;
  color: #c9a6e0;
  animation: fly 6s ease-in-out infinite;
}
.drink-plane svg {
  width: 1.5rem;
  height: 1.5rem;
  transform: rotate(90deg); /* nose pointing the way it flies */
}
@keyframes fly {
  0%   { transform: translateX(-34px) translateY(4px);  opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateX(34px) translateY(-6px); opacity: 0; }
}
.drink-message { margin-top: 0.35rem; line-height: 1.45; color: var(--cream); }
.drink-bonus {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  font-style: italic;
  color: #c9a6e0;
}

/* --- actions & errors --- */
.actions { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.65rem; }
.error-icon {
  display: inline-flex;
  margin-top: 3rem;
  color: var(--ash-text);
}
.error-icon svg { width: 3.4rem; height: 3.4rem; }
.error-message {
  color: var(--smoke-text);
  font-size: 1.1rem;
  line-height: 1.5;
  margin: 1rem 0 1.4rem;
}

/* --- footer --- */
.site-footer {
  position: relative;
  z-index: 1;
  padding: 0.9rem 1rem 1.1rem;
  font-size: 0.85rem;
}
.site-footer a { color: var(--ash-text); text-decoration: none; }
.site-footer strong { color: var(--ember-bright); }
.site-footer a:hover strong { text-decoration: underline; }
.footer-flame { width: 0.95em; height: 0.95em; }

/* --- larger screens: keep it phone-shaped and centred --- */
@media (min-width: 700px) {
  .brand-name { font-size: 1.8rem; }
  .score-number { font-size: 4.6rem; }
}

/* --- respect reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .smoke, .embers span, .brand-flame, .flame, .drink-plane, .golden-badge { animation: none; }
  .gauge-fill { transition: none; }
}
