:root {
  color-scheme: light;
  --paper: #f4f1e9;
  --ink: #18211d;
  --muted: #626b65;
  --line: #cbd0ca;
  --accent: #147d76;
  --accent-dark: #0d655f;
  --surface: #faf8f2;
}

* { box-sizing: border-box; }
html {
  background: var(--paper);
  scrollbar-gutter: stable;
}

body {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 24px;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
}

header,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  font-family: Arial, Helvetica, sans-serif;
}

header { padding-bottom: 22px; border-bottom: 1px solid var(--line); }

.mark {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

#archive { position: relative; flex: 0 0 auto; font-family: Arial, Helvetica, sans-serif; }

#archive-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font: 700 0.7rem/1 Arial, Helvetica, sans-serif;
}

#archive-toggle:hover { border-color: var(--accent); color: var(--accent-dark); }
#archive-toggle:focus-visible,
#archive-menu a:focus-visible,
#archive-menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#archive-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 14px 36px rgb(24 33 29 / 14%);
}

#archive-today {
  display: block;
  margin-top: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--paper);
  background: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

#archive-today:hover { background: var(--accent-dark); }
.calendar-heading { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; gap: 6px; }
#archive-month { margin: 0; font-size: 0.83rem; font-weight: 700; text-align: center; }

.calendar-nav {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 1.2rem;
}

.calendar-nav:disabled { color: var(--line); cursor: default; }
.calendar-weekdays,
#archive-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.calendar-weekdays { padding: 10px 0 5px; color: #a9afaa; font-size: 0.62rem; font-weight: 700; text-align: center; text-transform: uppercase; }

.calendar-day {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 0.75rem;
  text-decoration: none;
}

.calendar-nav:hover:not(:disabled),
a.calendar-day:hover { color: var(--paper); background: var(--accent); }
a.calendar-day[aria-current="date"] { color: var(--paper); background: var(--accent); font-weight: 700; }
button.calendar-day:disabled { color: #a9afaa; cursor: default; }
.calendar-day-empty { visibility: hidden; }
main { min-height: 50vh; }
#stories { padding: 18px 0 32px; }

article {
  border-bottom: 1px solid var(--line);
}

article:last-of-type { border-bottom: 0; }

h2 {
  margin: 0;
  padding: 22px 4px;
  font: 700 clamp(1.28rem, 4vw, 1.75rem)/1.15 Georgia, "Times New Roman", serif;
  letter-spacing: -0.025em;
}
.story-details { padding: 0 4px 22px; }
.has-illustration {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  column-gap: 26px;
  align-items: start;
}
.has-illustration .summary { grid-column: 1; grid-row: 1; }
.has-illustration .sources { grid-column: 1 / -1; }
.story-illustration { grid-column: 2; grid-row: 1; margin: 0; }
.story-illustration img { display: block; width: 100%; height: auto; border-radius: 6px; }
.summary {
  margin: 0;
  color: #36403b;
  font-size: 1.05rem;
  white-space: pre-line;
}
.sources,
footer {
  color: var(--muted);
  opacity: 0.7;
}
.sources {
  margin: 18px 0 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.68rem;
  text-align: right;
}
.sources:hover,
.sources:focus-within,
footer:hover,
footer:focus-within { opacity: 1; }
.source-group { display: block; }
.sources a { display: inline-block; color: inherit; text-underline-offset: 0.2em; }
.sources a:hover { color: var(--accent-dark); }

.empty { margin: 0; padding: 72px 0; color: var(--muted); font-size: 1.25rem; text-align: center; }

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

.loading-dots {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 1.25rem;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: loading-dot 900ms ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 150ms; }
.loading-dots span:nth-child(3) { animation-delay: 300ms; }

@keyframes loading-dot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 0.85; transform: translateY(-3px); }
}

footer {
  align-items: flex-start;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 0.72rem;
  line-height: 1.5;
}

footer p { margin: 0; }
footer a {
  color: inherit;
  text-underline-offset: 0.2em;
}
footer a:hover { color: var(--accent-dark); }
footer a:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}
.footer-copy { max-width: 420px; }
.footer-copy span { display: block; }
.credit { flex: 0 0 auto; text-align: right; white-space: nowrap; }
.credit span,
.credit > a { display: block; }
.hidden { display: none !important; }

@media (max-width: 560px) {
  body { padding: 20px 18px; }
  header { gap: 10px; }
  .mark { width: 36px; height: 36px; }
  #archive-menu { right: 2px; width: min(320px, calc(100vw - 36px)); }
  #stories { padding-top: 12px; }
  h2 { padding: 19px 2px; }
  .story-details { padding: 0 2px 19px; }
  .has-illustration { display: flex; flex-direction: column; }
  .story-illustration { width: 100%; margin-bottom: 20px; }
  .has-illustration .sources { align-self: flex-end; }
  footer { display: block; }
  .credit { margin-top: 12px; text-align: left; }
  .footer-copy { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-dots span { animation: none; opacity: 0.55; }
}
