/* ============================================================
   RE Cooking Calculator — BBQ theme
   Charcoal night, ember orange, smoke and flame.
   ============================================================ */

:root {
  --char-900: #120b08;
  --char-800: #1c120c;
  --char-700: #271811;
  --char-600: #332016;
  --ember: #ff6b1a;
  --ember-hot: #ffa040;
  --flame-red: #d43d17;
  --smoke: #c9b8ad;
  --smoke-dim: #8f7d71;
  --cream: #f7ede2;
  --panel-border: rgba(255, 107, 26, 0.22);
  --radius: 14px;
  --font-display: "Bebas Neue", "Arial Narrow", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

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

body {
  font-family: var(--font-body);
  color: var(--cream);
  -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255, 107, 26, 0.16), transparent 60%),
    radial-gradient(900px 500px at 85% 110%, rgba(212, 61, 23, 0.12), transparent 60%),
    linear-gradient(180deg, var(--char-900), var(--char-800) 45%, var(--char-900));
  min-height: 100vh;
}

button { touch-action: manipulation; }

/* ---------- atmosphere: vignette + film grain ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, transparent 55%, rgba(8, 4, 2, 0.45));
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 51;
  pointer-events: none;
  opacity: 0.055;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E") repeat;
}

/* ---------- view switching ---------- */
.view {
  display: none;
  min-height: 100vh;
  min-height: 100dvh; /* mobile browsers with collapsing toolbars */
  padding: 0 24px 48px;
  /* keep content clear of notches and home indicators */
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  padding-bottom: max(48px, env(safe-area-inset-bottom));
}
.view.active { display: block; animation: view-in 0.4s ease both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- hero ---------- */
/* breathing fire glow along the bottom of the welcome screen */
#welcome::before {
  content: "";
  position: fixed;
  left: 50%;
  bottom: -32vh;
  width: 130vw;
  height: 70vh;
  transform: translateX(-50%);
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255, 107, 26, 0.16), transparent 62%);
  animation: fire-breathe 5.5s ease-in-out infinite alternate;
}
@keyframes fire-breathe {
  from { opacity: 0.6; transform: translateX(-50%) scaleY(1); }
  to   { opacity: 1;   transform: translateX(-50%) scaleY(1.18); }
}

.hero {
  max-width: 860px;
  margin: 0 auto;
  padding-top: 72px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-block;
  padding: 8px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255, 107, 26, 0.08);
  color: var(--ember-hot);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(3.6rem, 10vw, 6.8rem);
  letter-spacing: 0.03em;
  line-height: 0.95;
  background: linear-gradient(180deg, var(--cream) 20%, var(--ember-hot) 65%, var(--flame-red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 24px 60px rgba(255, 107, 26, 0.25);
  margin-bottom: 22px;
  animation: title-glow 4s ease-in-out infinite alternate;
}
@keyframes title-glow {
  from { filter: drop-shadow(0 0 16px rgba(255, 107, 26, 0.15)); }
  to   { filter: drop-shadow(0 0 34px rgba(255, 160, 64, 0.4)); }
}

.hero-sub {
  color: var(--smoke);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  line-height: 1.65;
  max-width: 620px;
  margin: 0 auto;
}

.hero-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 38px auto 30px;
  max-width: 420px;
}
.hero-divider::before,
.hero-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ember));
}
.hero-divider::after { transform: scaleX(-1); }
.hero-divider span { font-size: 1.4rem; }

.pick-heading {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4.2vw, 2.4rem);
  color: var(--cream);
  letter-spacing: 0.06em;
  margin-bottom: 34px;
}

/* ---------- floating embers ---------- */
.embers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.embers i {
  position: absolute;
  bottom: -12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ember-hot), var(--flame-red));
  opacity: 0;
  animation: rise linear infinite;
  filter: blur(0.5px);
}
@keyframes rise {
  0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
  8%   { opacity: 0.85; }
  100% { transform: translateY(-105vh) translateX(var(--drift, 40px)) scale(0.2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .embers i { animation: none; display: none; }
}

/* ---------- theme cards ---------- */
.theme-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  max-width: 1100px;
  margin: 0 auto;
}

.theme-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 34px 20px 28px;
  background: linear-gradient(180deg, rgba(255, 107, 26, 0.07), rgba(28, 18, 12, 0.6));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  color: var(--cream);
  cursor: pointer;
  text-align: center;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  font-family: var(--font-body);
  animation: card-in 0.5s ease backwards;
}
.theme-card:nth-child(1) { animation-delay: 0.05s; }
.theme-card:nth-child(2) { animation-delay: 0.12s; }
.theme-card:nth-child(3) { animation-delay: 0.19s; }
.theme-card:nth-child(4) { animation-delay: 0.26s; }
.theme-card:nth-child(5) { animation-delay: 0.33s; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(20px); }
}

/* ember accent line across the top of each card */
.theme-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
  opacity: 0.4;
  transition: left 0.25s ease, right 0.25s ease, opacity 0.25s ease;
}
/* hover only on devices that actually hover — avoids sticky states on touch */
@media (hover: hover) {
  .theme-card:hover {
    transform: translateY(-6px);
    border-color: var(--ember);
    box-shadow: 0 18px 42px rgba(255, 107, 26, 0.22);
  }
  .theme-card:hover::before { left: 0; right: 0; opacity: 1; }
  .theme-card:hover .theme-icon { transform: scale(1.12) rotate(-6deg); }
}
.theme-card:focus-visible {
  transform: translateY(-6px);
  border-color: var(--ember);
  box-shadow: 0 18px 42px rgba(255, 107, 26, 0.22);
  outline: none;
}
.theme-card:active {
  transform: scale(0.97);
  border-color: var(--ember);
}
.theme-icon {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  font-size: 2.6rem;
  background: radial-gradient(circle at 50% 32%, rgba(255, 107, 26, 0.3), rgba(255, 107, 26, 0.05) 72%);
  border: 1px solid rgba(255, 107, 26, 0.28);
  filter: drop-shadow(0 6px 14px rgba(255, 107, 26, 0.35));
  transition: transform 0.2s ease;
}
.theme-name {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: 0.06em;
  color: var(--ember-hot);
}
.theme-desc {
  color: var(--smoke-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* phones: two tidy columns, last card full width */
@media (max-width: 560px) {
  .hero { padding-top: 44px; }
  .theme-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .theme-card { padding: 24px 12px 20px; }
  .theme-card:last-child { grid-column: 1 / -1; }
  .theme-icon { font-size: 2.1rem; width: 62px; height: 62px; }
  .panel { padding: 20px 16px; }
}

.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--smoke-dim);
  font-size: 0.8rem;
  margin-top: 56px;
  letter-spacing: 0.05em;
}

/* ---------- calculator views ---------- */
.calc-nav { max-width: 1000px; margin: 0 auto; padding-top: 28px; }

.back-btn {
  background: none;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--ember-hot);
  padding: 9px 20px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
@media (hover: hover) {
  .back-btn:hover { background: rgba(255, 107, 26, 0.12); border-color: var(--ember); }
}
.back-btn:active { background: rgba(255, 107, 26, 0.2); border-color: var(--ember); }

.calc-header {
  max-width: 1000px;
  margin: 0 auto;
  text-align: center;
  padding: 28px 0 34px;
}
.calc-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
  filter: drop-shadow(0 8px 20px rgba(255, 107, 26, 0.4));
}
.calc-header h2 {
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 6vw, 3.3rem);
  letter-spacing: 0.04em;
  color: var(--ember-hot);
  margin-bottom: 10px;
}
.calc-header p { color: var(--smoke); max-width: 560px; margin: 0 auto; line-height: 1.6; }

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  max-width: 1000px;
  margin: 0 auto;
}
@media (max-width: 760px) {
  .calc-grid { grid-template-columns: 1fr; }
}

.panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 107, 26, 0.06), rgba(28, 18, 12, 0.55));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.35);
}
.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 107, 26, 0.55), transparent);
}
.panel h3 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: 0.06em;
  color: var(--cream);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}

.panel label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--smoke);
  margin-bottom: 16px;
}
.panel label small {
  display: block;
  font-weight: 400;
  color: var(--smoke-dim);
  margin-top: 4px;
}

.panel input[type="number"],
.panel select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 14px;
  background: var(--char-700);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 1rem; /* 16px minimum — stops iOS zooming in on focus */
  min-height: 44px; /* comfortable touch target */
}

/* consistent dark select on iOS/Android instead of the native widget look */
.panel select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23ffa040' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.panel input:focus,
.panel select:focus {
  outline: none;
  border-color: var(--ember);
  box-shadow: 0 0 0 3px rgba(255, 107, 26, 0.18);
}

.check-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.check-label input { accent-color: var(--ember); width: 18px; height: 18px; }

/* ---------- info icons & popup ---------- */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-left: 7px;
  vertical-align: text-bottom;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  background: rgba(255, 107, 26, 0.1);
  color: var(--ember-hot);
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
@media (hover: hover) {
  .info-btn:hover {
    border-color: var(--ember);
    background: rgba(255, 107, 26, 0.22);
    transform: scale(1.15);
  }
}
.info-btn:focus-visible {
  border-color: var(--ember);
  background: rgba(255, 107, 26, 0.22);
  transform: scale(1.15);
  outline: none;
}
.info-btn:active { background: rgba(255, 107, 26, 0.3); }

/* bigger tap target on touch screens */
@media (pointer: coarse) {
  .info-btn {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
  }
}

.info-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 6, 4, 0.7);
  -webkit-backdrop-filter: blur(3px); /* iOS Safari */
  backdrop-filter: blur(3px);
}
.info-overlay[hidden] { display: none; }

.info-modal {
  position: relative;
  max-width: 440px;
  max-height: 80dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 20px;
  padding: 28px 30px;
  background: linear-gradient(180deg, var(--char-600), var(--char-700));
  border: 1px solid var(--ember);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 107, 26, 0.12);
  animation: info-pop 0.16s ease-out;
}
@keyframes info-pop {
  from { transform: translateY(10px) scale(0.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.info-modal h4 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  color: var(--ember-hot);
  margin-bottom: 12px;
  padding-right: 24px;
}
.info-modal p {
  color: var(--smoke);
  font-size: 0.92rem;
  line-height: 1.65;
}
.info-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--smoke-dim);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.info-close:hover { color: var(--ember-hot); }

/* respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- results ---------- */
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 8px;
  margin: 0 -8px;
  border-radius: 6px;
  border-bottom: 1px dashed rgba(255, 107, 26, 0.15);
  font-size: 0.95rem;
  transition: background 0.15s ease;
}
.result-row:last-child { border-bottom: none; }
@media (hover: hover) {
  .result-row:hover { background: rgba(255, 107, 26, 0.07); }
}
.result-row .r-label { color: var(--smoke); }
.result-row .r-value {
  font-weight: 700;
  color: var(--ember-hot);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.result-row.total {
  margin-top: 6px;
  padding: 12px;
  background: linear-gradient(90deg, rgba(255, 107, 26, 0.16), rgba(255, 107, 26, 0.04));
  border: 1px solid rgba(255, 107, 26, 0.28);
}
.result-row.total .r-label,
.result-row.total .r-value {
  color: var(--cream);
  font-weight: 700;
}
.result-note {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(255, 107, 26, 0.08);
  border-left: 3px solid var(--ember);
  border-radius: 0 8px 8px 0;
  color: var(--smoke);
  font-size: 0.85rem;
  line-height: 1.55;
}
.result-warn {
  border-left-color: var(--flame-red);
  background: rgba(212, 61, 23, 0.12);
}
.result-group-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  color: var(--cream);
  margin: 18px 0 4px;
}
.result-group-title:first-child { margin-top: 0; }
