/* ==========================================================================
   El Iletrado — main stylesheet

   Sections:
     1. Design tokens
     2. Base / reset
     3. Masthead
     4. Front page layout
     5. Story components
     6. Sidebar boxes
     7. Article (single post) page
     8. Footer
     9. Utilities

   Note on language: code identifiers and comments are in English so any
   agent or developer can work on it; all reader-facing text lives in the
   HTML and is in Spanish.
   ========================================================================== */

/* 1. Design tokens ---------------------------------------------------------
   Change the look of the whole site from here. Everything below references
   these variables rather than hard-coded values. */

:root {
  /* Color — a warm paper white with near-black ink, plus one accent. */
  --color-paper: #fbfaf7;
  --color-ink: #1a1a1a;
  --color-ink-muted: #575350;
  --color-rule: #d6d1c9;
  --color-accent: #8a1c1c;

  /* Type. System font stacks only — no web fonts, so pages load instantly
     and the site stays portable. */
  --font-serif: Georgia, "Times New Roman", "Liberation Serif", serif;
  --font-sans: "Helvetica Neue", Arial, "Liberation Sans", sans-serif;

  /* Type scale */
  --size-xs: 0.75rem;
  --size-sm: 0.875rem;
  --size-base: 1.0625rem;
  --size-md: 1.25rem;
  --size-lg: 1.5rem;
  --size-xl: 2rem;
  --size-2xl: 2.5rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  /* Layout */
  --measure: 68ch;        /* comfortable reading line length */
  --page-max: 62rem;
  --page-pad: 1.25rem;
}

/* 2. Base / reset ---------------------------------------------------------- */

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

body {
  margin: 0;
  padding: 0 var(--page-pad);
  background-color: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-serif);
  font-size: var(--size-base);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
  line-height: 1.15;
  margin: 0;
  font-weight: 700;
}

p {
  margin: 0 0 var(--space-md);
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--color-accent);
}

/* Visible keyboard focus. :focus-visible keeps it from firing on mouse
   clicks while remaining fully visible for keyboard users. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* 3. Masthead -------------------------------------------------------------- */

.masthead {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-lg) 0 var(--space-md);
  text-align: center;
  border-bottom: 3px double var(--color-ink);
}

.masthead__title {
  /* clamp() scales the nameplate with the viewport without media queries. */
  font-size: clamp(2.75rem, 12vw, 5.5rem);
  letter-spacing: -0.02em;
  margin: 0;
  /* Weight and line-height are set explicitly rather than inherited from the
     h1 rule, because the nameplate is an <h1> on the front page but a <p> on
     post pages (where the article title is the real h1). */
  font-weight: 700;
  line-height: 1.15;
}

.masthead__title a {
  text-decoration: none;
}

.masthead__title a:hover {
  color: inherit;
}

.masthead__tagline,
.masthead__dateline {
  font-family: var(--font-sans);
  font-size: var(--size-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  margin: 0;
}

.masthead__tagline {
  margin-bottom: var(--space-sm);
}

.masthead__dateline {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-rule);
}

/* 4. Front page layout ----------------------------------------------------- */

.frontpage {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-lg) 0;
  display: grid;
  gap: var(--space-lg);
}

/* Two columns once there is room. Below this width everything stacks. */
@media (min-width: 48em) {
  .frontpage {
    grid-template-columns: 2fr 1fr;
    gap: var(--space-xl);
  }

  /* Vertical hairline between columns, like a printed page. */
  .sidebar {
    border-left: 1px solid var(--color-rule);
    padding-left: var(--space-lg);
  }
}

/* Stories stack vertically, separated by rules. */
.stories > * + * {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-rule);
}

/* Older stories below the lead. Stacked by default; side by side once there
   is room, divided by a vertical rule like columns of print. */
.stories__secondary {
  display: grid;
  gap: var(--space-lg);
}

.stories__secondary > * + * {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-rule);
}

@media (min-width: 34em) {
  .stories__secondary {
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-lg);
  }

  .stories__secondary > * + * {
    padding-top: 0;
    border-top: 0;
  }

  .stories__secondary > :nth-child(even) {
    padding-left: var(--space-lg);
    border-left: 1px solid var(--color-rule);
  }

  .stories__secondary > :nth-child(n + 3) {
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-rule);
  }
}

/* Secondary headlines sit below the lead in the visual hierarchy. */
.stories__secondary .story__headline {
  font-size: var(--size-md);
}

/* When a filter is active, use one stable column. This avoids newspaper
   dividers appearing in the wrong place when some grid items are hidden. */
.stories__secondary--filtered {
  grid-template-columns: 1fr;
}

.stories__secondary--filtered > .story:not([hidden]) {
  padding-top: var(--space-lg);
  padding-left: 0;
  border-top: 1px solid var(--color-rule);
  border-left: 0;
}

.stories__secondary--filtered > .story--filter-first {
  padding-top: 0;
  border-top: 0;
}

.stories--lead-hidden > .stories__secondary {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.filter-empty {
  font-style: italic;
  color: var(--color-ink-muted);
}

/* 5. Story components ------------------------------------------------------ */

.kicker {
  font-family: var(--font-sans);
  font-size: var(--size-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 var(--space-sm);
}

.story__headline {
  font-size: var(--size-lg);
  margin-bottom: var(--space-sm);
}

.story__headline a {
  text-decoration: none;
}

/* The lead story is the visual anchor of the page. */
.story--lead .story__headline {
  font-size: clamp(1.75rem, 5vw, var(--size-2xl));
}

.story__standfirst {
  font-size: var(--size-md);
  font-style: italic;
  color: var(--color-ink-muted);
}

.byline {
  font-family: var(--font-sans);
  font-size: var(--size-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-md);
}

.more {
  font-family: var(--font-sans);
  font-size: var(--size-sm);
  font-weight: 700;
}

/* 6. Sidebar boxes --------------------------------------------------------- */

.box {
  border: 1px solid var(--color-rule);
  padding: var(--space-md);
  background: #fff;
}

.box__title {
  font-size: var(--size-md);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-rule);
}

.box p:last-child {
  margin-bottom: 0;
}

.category-browser {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-rule);
}

.category-browser__title {
  margin-bottom: var(--space-sm);
  font-family: var(--font-sans);
  font-size: var(--size-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.category-filter {
  border-top: 1px solid var(--color-rule);
}

.category-filter:last-of-type {
  border-bottom: 1px solid var(--color-rule);
}

.category-filter summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--size-sm);
  font-weight: 700;
  list-style: none;
}

.category-filter summary::-webkit-details-marker {
  display: none;
}

.category-filter summary::after {
  content: "+";
  color: var(--color-accent);
  font-size: var(--size-md);
  font-weight: 400;
  line-height: 1;
}

.category-filter[open] summary::after {
  content: "−";
}

.filter-options {
  padding-bottom: var(--space-sm);
}

.filter-option {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  border: 0;
  background: transparent;
  color: var(--color-ink-muted);
  font: inherit;
  font-family: var(--font-sans);
  font-size: var(--size-xs);
  text-align: left;
  cursor: pointer;
}

.filter-option:hover,
.filter-option[aria-pressed="true"] {
  color: var(--color-accent);
}

.filter-option[aria-pressed="true"] {
  font-weight: 700;
}

.filter-option__count {
  font-variant-numeric: tabular-nums;
}

.filter-status {
  margin-top: var(--space-sm);
  font-family: var(--font-sans);
  font-size: var(--size-xs);
  color: var(--color-ink-muted);
}

/* 7. Article (single post) page -------------------------------------------- */

.article {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-xl) 0;
}

.article__title {
  font-size: clamp(2rem, 6vw, 3.25rem);
  margin-bottom: var(--space-md);
}

.article__standfirst {
  font-size: var(--size-md);
  font-style: italic;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-md);
}

.article__body {
  font-size: var(--size-md);
  line-height: 1.7;
}

/* Drop cap on the opening paragraph — a newspaper convention. */
.article__body > p:first-of-type::first-letter {
  float: left;
  font-size: 3.6em;
  line-height: 0.82;
  padding-right: 0.08em;
  color: var(--color-accent);
}

.article__body h2 {
  font-size: var(--size-lg);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.back-link {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--size-sm);
  margin-top: var(--space-lg);
}

/* 8. Footer ---------------------------------------------------------------- */

.site-footer {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-lg) 0;
  border-top: 3px double var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--size-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  text-align: center;
}

.site-footer p {
  margin: 0;
}

/* 9. Utilities ------------------------------------------------------------- */

/* Skip link: hidden until focused, so keyboard users can jump past the
   masthead straight to the content. */
.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  position: static;
  display: inline-block;
  margin: var(--space-sm) 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-ink);
  color: var(--color-paper);
}

[hidden] {
  display: none !important;
}
