:root {
  --brand-teal: #0f766e;
  --brand-teal-600: #0d675f;
  --brand-teal-100: #e8f7f5;
  --brand-ink: #3E2F1F;   /* primary body text – soil brown */
  --brand-ink-2: #5A4A3B; /* secondary text */
  --brand-muted: #7A6A5A; /* muted/labels */
  --brand-border: #e6e6e6;
  --card-bg: #fafafa;
  --focus: #0f766e;
  --chip-bg: #111;
  --chip-fg: #fff;

  --hero-start: #0f766e;
  --hero-end: #0b4c57;

  --link: #0f766e;
  --link-dark: #7aeadd;
}

/* Base / reset */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.45;
  color: var(--brand-ink);
  background: #fff;
}
.container { max-width: 1040px; margin: 0 auto; padding: 1.25rem; }

/* Utilities */
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute !important; height: 1px; width: 1px; overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* Skip link */
.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  left: 1rem; top: 1rem; width: auto; height: auto;
  padding: .5rem .75rem; background: #fff; color: #000;
  border: 2px solid var(--focus); border-radius: 8px; z-index: 9999;
}

/* Brand hero (gradient only; no image) */
.brand-hero {
  background:
    radial-gradient(1200px 400px at 20% 0%, rgba(255,255,255,0.08), transparent 60%),
    linear-gradient(135deg, var(--hero-start), var(--hero-end));
  color: #fff;
  position: relative; overflow: hidden;
}
.hero-inner { position: relative; z-index: 1; padding-top: .75rem; padding-bottom: 1rem; }

/* Disable watermark block since we're not using a background image */
.page-watermark { display: none; }

/* Brand lockup */
.brand-lockup { display: grid; grid-template-columns: auto 1fr; gap: .85rem; align-items: center; }
.brand-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--chip-bg); color: var(--chip-fg);
  text-decoration: none; font-weight: 700; letter-spacing: .5px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25), inset 0 0 0 2px rgba(255,255,255,.1);
}
.brand-initials { font-size: .95rem; }
.app-title { margin: 0; font-size: clamp(1.25rem, 1.6rem, 2rem); color: #fff; }
.title-emojis { font-size: .9em; margin-left: .35rem; }
.app-subtitle { margin: .25rem 0 0 0; color: #e8fffb; }
.hero-links a { color: #e8fffb; }

/* Layout */
main { display: grid; grid-template-columns: 1fr; gap: 1rem; position: relative; z-index: 1; }
.grid-two { position: relative; display: grid; gap: 1.25rem; }
@media (min-width: 960px) { .grid-two { grid-template-columns: 1fr 1fr; align-items: start; } }

/* Cards & text */
.card { border: 1px solid var(--brand-border); border-radius: 12px; background: var(--card-bg); padding: 1rem; }
.section-title { margin: 0 0 .5rem 0; font-size: 1.1rem; font-weight: 700; }
.prewrap { white-space: pre-wrap; margin: 0; }
a.muted-link { text-decoration: none; color: var(--link); font-size: .95rem; }
.muted { color: var(--brand-muted); font-size: .95rem; }
.small { font-size: .9rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Presets */
#presets { display: flex; flex-wrap: wrap; gap: .5rem; }
.preset-btn {
  border: 1px solid #cbe6e2;
  background: var(--brand-teal-100);
  color: var(--brand-teal);
  font-size: .9rem;
  padding: .35rem .6rem;
  border-radius: 999px;
  cursor: pointer;
}
.preset-btn:hover, .preset-btn:focus { outline: none; border-color: #9fd1ca; background: #dff2f0; }

/* Form */
.form-card { position: relative; }
.form-grid { display: grid; gap: .9rem; }
.form-row { display: grid; gap: .75rem; }
@media (min-width: 720px) { .form-row--two { grid-template-columns: 1fr 1fr; } }

label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type="text"], textarea, select {
  width: 100%; padding: .6rem; border: 1px solid #ccc; border-radius: 8px;
  background: #fff; color: inherit;
}
input::placeholder, textarea::placeholder { color: #6a7582; }
textarea { resize: vertical; min-height: 120px; }

/* Buttons */
.actions { display: flex; align-items: center; gap: .75rem; }
button.primary {
  padding: .7rem 1rem; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--brand-teal); color: #fff;
}
button.primary:disabled { opacity: 0.7; cursor: default; }
button.secondary {
  padding: .7rem 1rem;
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  cursor: pointer;
  background: #ffffff;
  color: #0b1212;
}

/* Combined loading overlay */
.combined-loading-overlay {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(1px);
  border-radius: 12px; z-index: 2;
}
.grid-two.is-submitting .combined-loading-overlay { display: flex; }
.grid-two.is-submitting .card { pointer-events: none; opacity: 0.95; }
.grid-two.is-submitting .form-grid input,
.grid-two.is-submitting .form-grid select,
.grid-two.is-submitting .form-grid textarea,
.grid-two.is-submitting .form-grid button { pointer-events: none; }

.answer-card:focus { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Spinner */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid #c7ece7; border-top-color: var(--brand-teal);
  border-radius: 50%; animation: spin 0.9s linear infinite;
  margin-right: .5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Weather header & units toggle */
.weather-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .9rem; /* extra space before hourly */
}
.units-toggle { margin: 0; }
.units-toggle fieldset { display: inline-flex; gap: .25rem; border: 0; margin: 0; padding: 0; }
.toggle-seg {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--brand-border); border-radius: 999px; padding: .25rem .55rem;
  background: #fff; color: var(--brand-ink); cursor: pointer; user-select: none;
}
.toggle-seg input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-seg:has(input:checked) {
  background: var(--brand-teal);
  color: #fff;
  border-color: var(--brand-teal);
}

/* Unit display toggling */
#weather-section .only-f { display: inline; }
#weather-section .only-c { display: none; }
#weather-section[data-units="c"] .only-f { display: none; }
#weather-section[data-units="c"] .only-c { display: inline; }

/* Hourly forecast (capped width chips) */
.hourly-wrap { margin-bottom: 1rem; }
.hourly-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(72px, 120px);
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: .25rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  outline: none;
  justify-content: start;
}
.hourly-scroll:focus-visible { outline: 2px solid #17a29a; outline-offset: 2px; }
.hourly-chip {
  display: grid; place-items: center;
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  padding: .55rem .35rem;
  background: #fff;
  transition: border-color .2s ease, background-color .2s ease;
  max-width: 120px;
}
.hourly-time { font-size: .85rem; color: var(--brand-muted); }
.hourly-emoji { font-size: 1.25rem; line-height: 1.25rem; margin: .15rem 0; }
.hourly-temp { font-weight: 600; }

/* Weather alerts */
.weather-alerts { margin-top: .6rem; display: grid; gap: .5rem; }
.alert-item {
  background: #fff3cd;
  color: #5c3c00;
  border: 1px solid #ffe39a;
  border-radius: 8px;
  padding: .55rem .7rem;
}
.alert-title { margin-right: .4rem; }

/* Forecast grid — single row at wide screens (today + 5 days) */
.forecast-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: 1fr;
  margin-top: .6rem;
}
@media (min-width: 560px) {
  .forecast-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 880px) {
  .forecast-grid { grid-template-columns: repeat(6, 1fr); }
}

/* Daily forecast cards */
.forecast-card {
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  background: #fff;
  padding: .75rem;
  display: grid; gap: .35rem; align-content: start;
}
.forecast-card.today {
  background: var(--brand-teal-100);
  border-color: #9fd1ca;
  order: -1;
  box-shadow: 0 0 0 2px #0f766e22;
  transition: box-shadow 0.2s ease-in-out;
}
.forecast-card.today .forecast-day { color: var(--brand-teal); }
.forecast-card.today:hover, .forecast-card.today:focus-within { box-shadow: 0 0 0 3px #0f766e44; }

.forecast-top { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.forecast-day { font-weight: 700; }
.forecast-daywrap { display: inline-flex; align-items: baseline; gap: .35rem; }
.forecast-date { color: #6b7280; font-size: .9rem; }
.forecast-emoji { font-size: 1.6rem; line-height: 1; }
.forecast-desc { color: var(--brand-ink-2); font-size: .95rem; }
.forecast-temps { display: flex; gap: .5rem; align-items: baseline; margin-top: .25rem; flex-wrap: wrap; }
.forecast-temps .tlabel { font-weight: 600; margin-right: .15rem; }
.forecast-temps .tmax { font-weight: 700; }
.forecast-temps .tmin { color: #6b7280; opacity: 0.95; }
.forecast-extras { margin-top: .25rem; }

.badge {
  display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.4rem;
  border-radius: 999px; background: var(--brand-teal); color: #fff;
  margin-left: 0.35rem; vertical-align: middle;
}

/* History */
.history-header { display: flex; justify-content: space-between; align-items: baseline; }
ul.history { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
ul.history li { border: 1px solid var(--brand-border); border-radius: 10px; padding: .75rem; background: #fff; }
.history-q { margin-top: .35rem; }
.history-details { margin-top: .35rem; }
.history-answer { margin-top: .4rem; }

/* Footer */
.site-footer {
  margin-top: 2rem; padding: 1rem 0; font-size: 0.9rem; color: var(--brand-muted);
  border-top: 1px solid rgba(0,0,0,.08); text-align: center;
}
.site-footer a { color: inherit; text-decoration: underline; }
.site-footer a:hover { text-decoration: none; }

/* Loading shimmer */
#weather-section.loading .forecast-card,
#weather-section.loading .hourly-chip {
  position: relative;
  color: transparent !important;
}
#weather-section.loading .forecast-card::before,
#weather-section.loading .hourly-chip::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.12) 37%, rgba(0,0,0,0.06) 63%);
  animation: shimmer 1.1s infinite linear;
}
@keyframes shimmer { 0% { transform: translateX(-40%); } 100% { transform: translateX(40%); } }

/* A11y & motion */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .hourly-scroll { scroll-behavior: auto; }
  #weather-section.loading .forecast-card::before,
  #weather-section.loading .hourly-chip::before { animation: none; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --brand-ink: #EADFCF;   /* primary text – warm sand */
    --brand-ink-2: #D6C6B3; /* secondary */
    --brand-muted: #B9AA97; /* muted */
    --brand-border: rgba(255,255,255,.18);
    --card-bg: #0b1212;
    --chip-bg: #e5e7eb;
    --chip-fg: #0b1212;
  }
  body { background: #060a0a; }

  .card { background: var(--card-bg); }
  input[type="text"], textarea, select {
    background: #0f1a1a;
    color: #e8edf2;
    border-color: rgba(255,255,255,.22);
  }
  input::placeholder, textarea::placeholder { color: #8aa0ad; }
  select option:checked { background-color: #17a29a !important; color: #031212 !important; }
  a.muted-link { color: var(--link-dark); }

  .preset-btn { border-color: #17464a; background: #0c1716; color: #d2faf3; }
  .preset-btn:hover, .preset-btn:focus { background: #11302d; border-color: #1e5b54; }

  .toggle-seg { background: #0f1a1a; color: #e5e7eb; border-color: rgba(255,255,255,.22); }
  .toggle-seg:has(input:checked) { background: #17a29a; color: #031212; border-color: #17a29a; }

  button.secondary { background: #0f1a1a; color: #e5e7eb; border-color: rgba(255,255,255,.28); }
  button.secondary:hover { background: #122121; }

  .weather-alerts .alert-item {
    background: #312e1b;
    color: #fff5cc;
    border-color: #5f5627;
  }

  .hourly-chip { background: #0e1616; border-color: rgba(255,255,255,.18); color: #e9f2f0; }

  .forecast-card { background: #0e1616; border-color: rgba(255,255,255,.18); }
  .forecast-date { color: #b7c1cd; }
  .forecast-temps .tmin { color: #bdc9d6; opacity: 1; }
  .forecast-desc { color: var(--brand-ink-2); }
  .forecast-card.today {
    background: #0f1c1b;
    border-color: #1a6d64;
    box-shadow: 0 0 0 2px #1a6d6433;
  }

  ul.history li { background: #0e1616; color: #eaf2f8; border-color: rgba(255,255,255,.22); }
  ul.history li .muted { color: #d6dee8; }
  ul.history li .mono { color: #eaf2f8; }
}
