/* ------------------------------------------------------------------
   El meu món — estil tradicional de diari
   ------------------------------------------------------------------ */

:root {
  --bg: #fdfaf5;
  --surface: #ffffff;
  --surface-soft: #f5f0e8;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #d9d0c1;
  --accent: #8b1a1a;
  --accent-strong: #6e1515;
  --accent-soft: #fdf2f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 4px;
  --max-width: 960px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1814;
    --surface: #24221d;
    --surface-soft: #2d2a23;
    --text: #e8e4dc;
    --muted: #9c968a;
    --border: #3d3830;
    --accent: #c94a4a;
    --accent-strong: #db6b6b;
    --accent-soft: #2a1e1e;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1a1814;
  --surface: #24221d;
  --surface-soft: #2d2a23;
  --text: #e8e4dc;
  --muted: #9c968a;
  --border: #3d3830;
  --accent: #c94a4a;
  --accent-strong: #db6b6b;
  --accent-soft: #2a1e1e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: "Playfair Display", "Iowan Old Style", "Palatino Linotype",
    Palatino, Georgia, serif;
  font-weight: 600;
  line-height: 1.3;
}

p {
  margin: 0 0 1.2em;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 var(--radius) 0;
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

/* Header ---------------------------------------------------------- */

.site-header {
  border-bottom: 3px double var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 64px;
  position: relative;
}

.brand {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  font-variant: small-caps;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.theme-toggle {
  position: absolute;
  right: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

.theme-toggle .icon {
  width: 18px;
  height: 18px;
  display: block;
}

.theme-toggle .icon-sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* Section tabs ---------------------------------------------------- */

.section-tabs {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 64px;
  z-index: 9;
}

.section-tabs .wrap {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.section-tabs .wrap::-webkit-scrollbar {
  display: none;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  font-family: "Playfair Display", serif;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  text-transform: uppercase;
}

.section-tab:hover {
  color: var(--text);
  text-decoration: none;
  border-bottom-color: var(--border);
}

.section-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Intro ----------------------------------------------------------- */

.intro {
  padding: 48px 0 12px;
  text-align: center;
}

.site-title {
  margin: 0;
  font-size: clamp(2rem, 5.5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant: small-caps;
}

.site-title a {
  color: inherit;
}

.site-title a:hover {
  text-decoration: none;
  color: var(--accent);
}

.tagline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-style: italic;
}

/* Editions navigation -------------------------------------------- */

.editions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.editions-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.edition-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.edition-arrow svg {
  width: 16px;
  height: 16px;
  display: block;
}

.edition-arrow:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

.edition-arrow.is-disabled {
  visibility: hidden;
}

.edition-current {
  display: inline-block;
  font-size: 1rem;
  font-weight: 600;
  padding: 3px 12px;
  color: var(--text);
  user-select: none;
  min-width: 180px;
  text-align: center;
}

:root:not([data-view="events"]) .editions--today .edition-left {
  visibility: hidden;
  pointer-events: none;
}

/* Calendar -------------------------------------------------------- */

.calendar {
  position: relative;
  display: inline-flex;
}

.edition-calendar[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

.calendar-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: 272px;
  max-width: calc(100vw - 40px);
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.calendar-pop[hidden] {
  display: none;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.calendar-month {
  font-family: "Playfair Display", serif;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}

.calendar-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.calendar-nav svg {
  width: 14px;
  height: 14px;
  display: block;
}

.calendar-nav:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.calendar-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 0;
}

.calendar-day {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  border-radius: 999px;
}

a.calendar-day {
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

a.calendar-day:hover {
  color: #fff;
  background: var(--accent);
}

.calendar-day.is-current {
  color: #fff;
  background: var(--accent-strong);
}

.calendar-day.is-today {
  border: 2px solid var(--accent-strong);
  color: var(--accent-strong);
  background: var(--surface);
  font-weight: 700;
}

a.calendar-day.is-today:hover {
  color: #fff;
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.calendar-day.is-current.is-today {
  color: #fff;
  border-color: #fff;
  background: var(--accent-strong);
}

.calendar-day.is-blocked {
  opacity: 0.35;
}

@media (max-width: 560px) {
  .calendar-pop {
    position: fixed;
    top: 68px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100vw - 24px);
    max-width: none;
    max-height: calc(100vh - 88px);
    overflow-y: auto;
    padding: 16px;
  }

  .calendar-nav {
    width: 40px;
    height: 40px;
  }

  .calendar-nav svg {
    width: 16px;
    height: 16px;
  }

  .calendar-grid {
    gap: 4px;
  }

  .calendar-weekday {
    font-size: 0.72rem;
  }

  .calendar-day {
    font-size: 0.98rem;
    min-height: 44px;
  }
}

/* News grid ------------------------------------------------------- */

.news-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

@media (max-width: 640px) {
  .news-grid {
    grid-template-columns: 1fr;
  }
}

.news-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.news-card:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.news-card-title {
  margin: 0 0 16px;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
}

.news-card-title a {
  color: var(--text);
  transition: color 0.15s ease;
}

.news-card-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.news-card-summary {
  margin: 0 0 20px;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  flex: 1;
}

.news-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* News context (collapsible) -------------------------------------- */

.news-context {
  margin: 0 0 18px;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}

.news-context > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 0.15s ease;
}

.news-context > summary::-webkit-details-marker {
  display: none;
}

.news-context > summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform 0.2s ease;
}

.news-context[open] > summary::before {
  transform: rotate(-180deg);
}

.news-context > summary:hover {
  color: var(--text);
}

.news-context-body {
  padding: 0 0 14px;
}

.news-context-body p {
  margin: 0 0 0.9em;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--muted);
}

.news-context-body p:last-child {
  margin-bottom: 0;
}

.context-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 0.78rem;
}

.context-links a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 3px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.context-links a:hover {
  color: var(--surface);
  background: var(--accent);
  text-decoration: none;
}

.news-card-source {
  color: var(--muted);
}

.news-card-lang {
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.68rem;
}

/* Section block visibility ---------------------------------------- */

.section-block {
  display: none;
}

:root[data-section="spain"] .section-block[data-section="spain"],
:root[data-section="catalunya"] .section-block[data-section="catalunya"],
:root[data-section="international"] .section-block[data-section="international"],
:root[data-section="chile"] .section-block[data-section="chile"],
:root[data-section="trending"] .section-block[data-section="trending"] {
  display: block;
}

/* Footer ---------------------------------------------------------- */

.site-footer {
  margin-top: 56px;
  padding: 24px 0 40px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

.site-footer p {
  margin: 0 0 6px;
}

.footer-note {
  font-size: 0.8rem;
  opacity: 0.85;
  font-style: italic;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 40px 0;
}