/* ===================================================================
   style.css — Snow Day Predictor (Production Optimized)
   #10 Reserved space for result card / chart (prevents CLS)
   #14 Visible focus states for keyboard navigation
   #17 Confidence badge styles
   =================================================================== */

/* ===== CSS VARIABLES ===== */
:root {
  --ice:    #dff0f7;
  --frost:  #b8dff0;
  --sky:    #6ab8d9;
  --deep:   #1a4a6b;
  --ink:    #0d2535;
  --snow:   #f7fbfd;
  --mist:   #e8f4f9;
  --accent: #ff6b35;
  --gold:   #f0c040;
  --white:  #ffffff;
  --gray:   #8ba8b8;
  --shadow: rgba(26,74,107,0.12);
}

/* ===== RESET ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--snow);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== NAV ===== */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(247,251,253,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--frost);
  padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.logo {
  font-family: 'Fraunces', serif;
  font-weight: 700; font-size: 1.3rem;
  color: var(--deep);
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; text-decoration: none;
}
.logo span { color: var(--sky); }
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.875rem; font-weight: 500;
  color: var(--deep); text-decoration: none;
  transition: background 0.2s;
  cursor: pointer;
}
.nav-links a:hover  { background: var(--ice); }
.nav-links a.active { background: var(--ice); color: var(--sky); }

/* Hamburger — hidden on desktop */
.hamburger { display: none; }

/* ===== PAGES ===== */
.page { display: none; padding-top: 64px; min-height: 100vh; }
.page.active { display: block; }

/* ===== HERO ===== */
.hero {
  position: relative;
  background: linear-gradient(160deg, #0d2535 0%, #1a4a6b 50%, #2a7aaa 100%);
  padding: 5rem 2rem 4rem;
  overflow: hidden;
  text-align: center;
}
#snowCanvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
.hero-content { position: relative; z-index: 1; }
.hero::before {
  content: '';
  position: absolute; inset: 0; z-index: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 100px; padding: 0.3rem 0.9rem;
  font-size: 0.78rem; font-weight: 500; color: var(--frost);
  margin-bottom: 1.5rem; letter-spacing: 0.05em; text-transform: uppercase;
}
.hero h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 700; color: white;
  line-height: 1.1; margin-bottom: 1rem;
}
.hero h1 em { color: var(--gold); font-style: italic; }
.hero p {
  font-size: 1.1rem; color: var(--frost);
  max-width: 520px; margin: 0 auto 2.5rem; line-height: 1.6;
}

/* ===== SEARCH BOX ===== */
.search-card {
  background: white; border-radius: 20px; padding: 1.5rem;
  max-width: 520px; margin: 0 auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  position: relative; z-index: 2;
}
.search-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.search-row input {
  flex: 1; padding: 0.75rem 1rem;
  border: 1.5px solid var(--frost); border-radius: 12px;
  font-size: 1rem; font-family: 'DM Sans', sans-serif;
  color: var(--ink); outline: none; transition: border-color 0.2s;
}
.search-row input:focus { border-color: var(--sky); }
.search-row input::placeholder { color: var(--gray); }
.btn-predict {
  padding: 0.75rem 1.5rem;
  background: var(--deep); color: white;
  border: none; border-radius: 12px;
  font-size: 0.95rem; font-weight: 600; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-predict:hover    { background: var(--sky); }
.btn-predict:active   { transform: scale(0.97); }
.btn-predict:disabled {
  background: var(--gray); cursor: not-allowed; transform: none;
}
.btn-geo {
  width: 100%; padding: 0.65rem;
  background: var(--ice); color: var(--deep);
  border: 1.5px solid var(--frost); border-radius: 12px;
  font-size: 0.875rem; font-weight: 500; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: background 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-geo:hover { background: var(--frost); }

/* ===== RESULT ===== */
.result-wrapper {
  max-width: 760px; margin: 3rem auto; padding: 0 1.5rem;
  /* #10: Reserve minimum height to prevent CLS on first load */
  min-height: 120px;
}
.result-card {
  background: white; border-radius: 24px; overflow: hidden;
  box-shadow: 0 4px 24px var(--shadow); margin-bottom: 1.5rem;
}
.result-header {
  padding: 2rem 2rem 1.5rem;
  background: linear-gradient(135deg, var(--deep) 0%, #2a7aaa 100%);
  text-align: center; color: white;
}
.result-location {
  font-size: 0.85rem; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--frost); margin-bottom: 0.5rem;
}
.prob-ring-wrap { display: flex; justify-content: center; margin: 1rem 0; }
.prob-ring      { width: 160px; height: 160px; position: relative; }
.prob-ring svg  { transform: rotate(-90deg); }
.prob-ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.prob-pct {
  font-family: 'Fraunces', serif;
  font-size: 2.8rem; font-weight: 700; color: white; line-height: 1;
}
.prob-label   { font-size: 0.75rem; color: var(--frost); margin-top: 2px; }
.result-verdict {
  font-family: 'Fraunces', serif;
  font-size: 1.4rem; font-weight: 700; margin-bottom: 0.25rem;
}
.result-verdict.high   { color: var(--gold); }
.result-verdict.medium { color: #ffd166; }
.result-verdict.low    { color: var(--frost); }
.result-subtext        { font-size: 0.9rem; color: var(--frost); }

.result-body { padding: 1.5rem 2rem; }
.explanation-box {
  background: var(--mist); border-left: 4px solid var(--sky);
  border-radius: 0 12px 12px 0; padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  font-size: 0.925rem; line-height: 1.65; color: var(--deep);
  /* #10: Reserve minimum height for explanation text to avoid CLS */
  min-height: 3rem;
}

/* ===== #17 CONFIDENCE BADGE ===== */
.confidence-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; font-weight: 600;
  padding: 0.25rem 0.7rem; border-radius: 100px;
  margin-bottom: 1.25rem; letter-spacing: 0.04em; text-transform: uppercase;
}
.confidence-badge.high   { background: #dcfce7; color: #166534; }
.confidence-badge.medium { background: #fef9c3; color: #854d0e; }
.confidence-badge.low    { background: var(--ice); color: var(--deep); }
.confidence-badge:empty  { display: none; }

.weather-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem; margin-bottom: 1.5rem;
  /* #10: Reserve grid height to prevent jump */
  min-height: 80px;
}
.weather-tile {
  background: var(--snow); border: 1px solid var(--ice);
  border-radius: 14px; padding: 1rem; text-align: center;
}
.weather-tile .icon { font-size: 1.6rem; margin-bottom: 0.3rem; }
.weather-tile .val  {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem; font-weight: 700; color: var(--deep);
}
.weather-tile .key  { font-size: 0.75rem; color: var(--gray); margin-top: 2px; }

.share-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn-share {
  padding: 0.55rem 1.1rem;
  border-radius: 10px; font-size: 0.85rem; font-weight: 500;
  cursor: pointer; border: 1.5px solid var(--frost);
  background: white; color: var(--deep);
  transition: all 0.2s; font-family: 'DM Sans', sans-serif;
  display: flex; align-items: center; gap: 0.4rem;
}
.btn-share:hover  { background: var(--deep); color: white; border-color: var(--deep); }
.btn-share.copied { background: #22c55e; color: white; border-color: #22c55e; }

/* Chart card */
.chart-card {
  background: white; border-radius: 20px; padding: 1.5rem;
  box-shadow: 0 4px 24px var(--shadow); margin-bottom: 1.5rem;
  /* #10: Reserve chart area height to prevent layout jump */
  min-height: 80px;
}
.chart-card h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem; color: var(--deep); margin-bottom: 1rem;
}
.btn-historical {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.3rem;
  background: var(--ice); color: var(--deep);
  border: 1.5px solid var(--frost); border-radius: 10px;
  font-size: 0.875rem; font-weight: 500; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: background 0.2s; margin-bottom: 1rem;
}
.btn-historical:hover    { background: var(--frost); }
.btn-historical:disabled { opacity: 0.55; cursor: not-allowed; }
#historicalChartWrap         { display: none; }
#historicalChartWrap.visible { display: block; }

/* Loading */
.loading { display: none; text-align: center; padding: 3rem 2rem; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--frost); border-top-color: var(--sky);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--gray); font-size: 0.9rem; }

/* ===== #14: VISIBLE FOCUS STATES ===== */
:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
  border-radius: 4px;
}
/* Remove default focus ring only when focus-visible is supported */
:focus:not(:focus-visible) { outline: none; }

/* ===== STATIC PAGES ===== */
.static-page { max-width: 720px; margin: 0 auto; padding: 3rem 1.5rem; }
.static-page h1 {
  font-family: 'Fraunces', serif;
  font-size: 2.5rem; font-weight: 700; color: var(--deep); margin-bottom: 0.5rem;
}
.static-page .subtitle  { color: var(--gray); margin-bottom: 2.5rem; font-size: 1rem; }
.static-page h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem; color: var(--deep); margin: 2rem 0 0.75rem;
}
.static-page p, .static-page li {
  line-height: 1.75; color: #3a5a70; font-size: 0.95rem;
}
.static-page ul { padding-left: 1.2rem; margin: 0.5rem 0; }
.static-page ul li { margin-bottom: 0.25rem; }
.info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin: 1.5rem 0;
}
.info-tile {
  background: var(--mist); border-radius: 14px;
  padding: 1.2rem; border: 1px solid var(--frost);
}
.info-tile .emoji { font-size: 1.5rem; margin-bottom: 0.5rem; }
.info-tile h2     { font-size: 0.95rem; font-weight: 600; color: var(--deep); margin-bottom: 0.3rem; margin-top: 0; }
.info-tile p      { font-size: 0.85rem; }

/* FAQ */
.faq-item { border-bottom: 1px solid var(--ice); }
.faq-q {
  padding: 1.1rem 0; font-weight: 600; color: var(--deep);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  font-size: 0.95rem; user-select: none;
}
.faq-q:hover { color: var(--sky); }
.faq-q .arrow { transition: transform 0.25s; font-size: 0.8rem; color: var(--gray); }
.faq-q.open .arrow { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 0 1rem; color: #3a5a70; line-height: 1.7; font-size: 0.9rem; }
.faq-a.open { display: block; }

/* Contact */
.contact-form { max-width: 480px; }
.form-group { margin-bottom: 1.2rem; }
.form-group label {
  display: block; font-weight: 500; font-size: 0.875rem;
  color: var(--deep); margin-bottom: 0.4rem;
}
.form-group input, .form-group textarea {
  width: 100%; padding: 0.75rem 1rem;
  border: 1.5px solid var(--frost); border-radius: 12px;
  font-size: 0.95rem; font-family: 'DM Sans', sans-serif;
  color: var(--ink); outline: none; transition: border-color 0.2s;
  background: white;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--sky); }
.form-group textarea { resize: vertical; min-height: 120px; }
.btn-submit {
  padding: 0.8rem 2rem;
  background: var(--deep); color: white;
  border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 600;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}
.btn-submit:hover { background: var(--sky); }
.success-msg {
  display: none;
  background: #dcfce7; border: 1px solid #86efac;
  border-radius: 12px; padding: 1rem 1.2rem;
  color: #166534; font-size: 0.9rem; margin-top: 1rem;
}
.success-msg.show { display: block; }

/* Footer */
footer { background: var(--ink); padding: 2.5rem 2rem; margin-top: 4rem; }
.footer-inner {
  max-width: 960px; margin: 0 auto;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1.5rem;
}
.footer-logo { font-family: 'Fraunces', serif; font-size: 1.1rem; color: white; font-weight: 700; }
.footer-logo span { color: var(--sky); }
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a {
  font-size: 0.85rem; color: var(--gray);
  text-decoration: none; cursor: pointer; transition: color 0.2s;
}
.footer-links a:hover { color: var(--sky); }
.footer-copy { font-size: 0.8rem; color: var(--gray); }

/* Privacy tags */
.tag {
  display: inline-block; background: var(--ice); border-radius: 6px;
  padding: 0.2rem 0.6rem; font-size: 0.78rem; color: var(--sky);
  font-weight: 600; margin-right: 0.4rem; margin-bottom: 0.4rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1080px) {
  .ad-rail { display: none; }
  .page-with-ads { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  /* ── General layout ── */
  .hero { padding: 4rem 1.25rem 3rem; }
  .result-wrapper { padding: 0 1rem; }
  .result-body { padding: 1.25rem 1.25rem; }
  .static-page { padding: 2rem 1.25rem; }
  .ad-banner { display: none; }

  /* ── Fix: search card stacks vertically so button never overflows ── */
  .search-card { padding: 1.1rem; }
  .search-row {
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
  }
  .search-row input {
    width: 100%;
    font-size: 1rem;
  }
  .btn-predict {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    text-align: center;
    justify-content: center;
  }

  /* ── Hamburger nav ── */
  nav { padding: 0 1rem; }

  /* Hide desktop links on mobile */
  .nav-links {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 64px;
    left: 0; right: 0;
    background: rgba(247,251,253,0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--frost);
    padding: 0.75rem 1rem 1.25rem;
    gap: 0.2rem;
    z-index: 99;
    box-shadow: 0 8px 32px var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: 0.7rem 0.9rem;
    font-size: 0.95rem;
    border-radius: 10px;
    width: 100%;
  }

  /* Show hamburger button on mobile */
  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 38px; height: 38px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s;
    flex-shrink: 0;
  }
  .hamburger:hover { background: var(--ice); }
  .hamburger span {
    display: block;
    width: 20px; height: 2px;
    background: var(--deep);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
    transform-origin: center;
  }
  /* Animate to × when open */
  .hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  .hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}