/* ============ Tokens ============ */
:root {
  --bg: #f6f3ec;
  --bg-elevated: #fffdf8;
  --ink: #201c15;
  --ink-soft: #6b6355;
  --ink-faint: #948c7c;
  --border: #e4ddcb;
  --accent: #a85f12;
  --accent-ink: #fffdf8;
  --accent-soft: #f0dcb8;
  --positive: #1e7b45;
  --negative: #b23b3b;
  --shadow: 0 1px 2px rgba(32, 28, 21, 0.05), 0 10px 28px -16px rgba(32, 28, 21, 0.18);

  --font-display: "Fraunces", Georgia, "Iowan Old Style", serif;
  --font-body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 14px;
  --gap: 1.1rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --bg-elevated: #1c2224;
    --ink: #f1ede3;
    --ink-soft: #a9a296;
    --ink-faint: #726b5e;
    --border: #2b3234;
    --accent: #e0a542;
    --accent-ink: #14181a;
    --accent-soft: #3a2e17;
    --positive: #4cc17e;
    --negative: #e37367;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -16px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14181a;
  --bg-elevated: #1c2224;
  --ink: #f1ede3;
  --ink-soft: #a9a296;
  --ink-faint: #726b5e;
  --border: #2b3234;
  --accent: #e0a542;
  --accent-ink: #14181a;
  --accent-soft: #3a2e17;
  --positive: #4cc17e;
  --negative: #e37367;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -16px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f3ec;
  --bg-elevated: #fffdf8;
  --ink: #201c15;
  --ink-soft: #6b6355;
  --ink-faint: #948c7c;
  --border: #e4ddcb;
  --accent: #a85f12;
  --accent-ink: #fffdf8;
  --accent-soft: #f0dcb8;
  --positive: #1e7b45;
  --negative: #b23b3b;
  --shadow: 0 1px 2px rgba(32, 28, 21, 0.05), 0 10px 28px -16px rgba(32, 28, 21, 0.18);
  color-scheme: light;
}

/* ============ Reset ============ */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  text-wrap: balance;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

input {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

/* ============ Header ============ */
.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 2.2rem clamp(1rem, 4vw, 2.5rem) 1.4rem;
  max-width: 1280px;
  margin: 0 auto;
}

.brand h1 {
  font-size: clamp(1.9rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0.15rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-size: 1.3rem;
  font-weight: 500;
}

.theme-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  transition: border-color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-label {
  font-size: 0.66rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============ Grid ============ */
.grid {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 3rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

.card-wide {
  grid-column: span 2;
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .card-wide {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .card-wide {
    grid-column: span 1;
  }
  .site-header {
    flex-wrap: wrap;
  }
}

/* ============ Card ============ */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.card-head h2 {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.card-head .icon {
  font-size: 1.05em;
}

.freshness {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.loading,
.error-state,
.empty-state {
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin: 0;
}

.error-state {
  color: var(--negative);
}

.error-state a,
.empty-state a {
  color: var(--accent);
  text-decoration: underline;
}

.stamp {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* ============ Dólar ============ */
.rate-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
}

.rate-row:last-of-type {
  border-bottom: none;
}

.rate-row .rate-name {
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.rate-row .rate-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 500;
}

.rate-featured .rate-row .rate-value {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent);
}

.rate-featured .rate-row .rate-value.na {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink-faint);
}

.rate-extra {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
}

/* ============ Clima ============ */
.city-search {
  position: relative;
}

.city-search input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.85rem;
}

.city-results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}

.city-results li button {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.7rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
}

.city-results li button:hover,
.city-results li button:focus-visible {
  background: var(--accent-soft);
}

.weather-now {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.weather-now .weather-icon {
  font-size: 2.4rem;
  line-height: 1;
}

.weather-now .weather-temp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent);
}

.weather-desc {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.weather-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.weather-city {
  font-size: 0.8rem;
  color: var(--ink-faint);
}

/* ============ Fútbol ============ */
.group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin-top: 0.3rem;
}

.group-label:first-child {
  margin-top: 0;
}

.match {
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.88rem;
}

.match:last-of-type {
  border-bottom: none;
}

.match-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.05rem 0;
}

.match-row .team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.match-row .team-score {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.match .meta {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.match .meta .status-live {
  color: var(--negative);
  font-weight: 600;
}

/* ============ Mercado / Cripto ============ */
.market-headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.15rem;
}

.market-headline .label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.market-headline .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent);
}

.ticker-row,
.coin-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.28rem 0;
  font-size: 0.85rem;
}

.ticker-row .symbol,
.coin-row .name {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--ink-soft);
  min-width: 0;
}

.ticker-row .symbol strong,
.coin-row .name strong {
  color: var(--ink);
  font-weight: 600;
}

.ticker-row .nums,
.coin-row .nums {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pct {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
}

.pct.up {
  color: var(--positive);
  background: color-mix(in srgb, var(--positive) 14%, transparent);
}

.pct.down {
  color: var(--negative);
  background: color-mix(in srgb, var(--negative) 14%, transparent);
}

.coin-secondary {
  color: var(--ink-faint);
  font-size: 0.78rem;
}

/* ============ Noticias ============ */
.news-list {
  gap: 0.05rem;
}

.news-item {
  display: block;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.news-item:last-child {
  border-bottom: none;
}

.news-item:hover .news-title,
.news-item:focus-visible .news-title {
  color: var(--accent);
}

.news-item.is-new {
  animation: news-highlight 2.5s ease-out;
}

@keyframes news-highlight {
  from {
    background-color: var(--accent-soft);
  }
  to {
    background-color: transparent;
  }
}

.news-meta {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-bottom: 0.15rem;
}

.news-source {
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.68rem;
}

.news-title {
  font-size: 0.92rem;
  color: var(--ink);
  line-height: 1.35;
}

/* ============ Feriado ============ */
.holiday-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.holiday-date {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-size: 0.95rem;
}

.holiday-countdown {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ============ Asistente ============ */
.assistant-form {
  display: flex;
  gap: 0.5rem;
}

.assistant-form input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.85rem;
}

.assistant-form button {
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.assistant-form button:hover {
  opacity: 0.9;
}

.assistant-form button:disabled {
  opacity: 0.55;
  cursor: default;
}

.assistant-response {
  margin-top: 0.8rem;
}

.assistant-answer {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink);
}

/* ============ Footer ============ */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
  color: var(--ink-faint);
  font-size: 0.8rem;
}
