/* ============================================================
   Alexandria — news.al007ex.com
   A minimal, ad-free, tracker-free reading surface.
   No frameworks. No web fonts. No third-party requests.
   ============================================================ */

/* ---------- 1. Tokens ---------------------------------------------------- */

:root {
  --paper:        #fcfcfa;
  --paper-sunk:   #f4f3ee;
  --ink:          #1b1b18;
  --ink-soft:     #55554e;
  --ink-faint:    #86867c;
  --rule:         #e4e2da;
  --rule-heavy:   #1b1b18;
  --accent:       #a8391d;
  --accent-soft:  rgba(168, 57, 29, .10);
  --shadow:       rgba(27, 27, 24, .07);

  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter,
                Georgia, "Times New Roman", serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
                "Helvetica Neue", Arial, sans-serif;
  --font-mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure:  40rem;   /* article column          */
  --wide:     68rem;   /* page container          */
  --gutter:   clamp(1.15rem, 5vw, 2.5rem);

  --step--1: clamp(.78rem, .74rem + .18vw, .86rem);
  --step-0:  clamp(1.02rem, .98rem + .22vw, 1.14rem);
  --step-1:  clamp(1.2rem, 1.12rem + .4vw,  1.4rem);
  --step-2:  clamp(1.45rem, 1.3rem + .75vw, 1.9rem);
  --step-3:  clamp(1.8rem, 1.5rem + 1.5vw,  2.7rem);
  --step-4:  clamp(2.2rem, 1.7rem + 2.6vw,  3.9rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:       #121211;
    --paper-sunk:  #1a1a18;
    --ink:         #eceae3;
    --ink-soft:    #a5a29a;
    --ink-faint:   #75726b;
    --rule:        #2b2b27;
    --rule-heavy:  #eceae3;
    --accent:      #e5825f;
    --accent-soft: rgba(229, 130, 95, .13);
    --shadow:      rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --paper:       #121211;
  --paper-sunk:  #1a1a18;
  --ink:         #eceae3;
  --ink-soft:    #a5a29a;
  --ink-faint:   #75726b;
  --rule:        #2b2b27;
  --rule-heavy:  #eceae3;
  --accent:      #e5825f;
  --accent-soft: rgba(229, 130, 95, .13);
  --shadow:      rgba(0, 0, 0, .4);
}

/* ---------- 2. Reset ----------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-wrap: break-word;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--step-0);
  line-height: 1.62;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.15; letter-spacing: -.014em; }
p, ul, ol, figure, blockquote, pre, table { margin: 0; }

a { color: inherit; }

::selection { background: var(--accent-soft); }

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

/* ---------- 3. Layout scaffolding ---------------------------------------- */

.shell {
  width: 100%;
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.shell--narrow { max-width: calc(var(--measure) + var(--gutter) * 2); }

main { flex: 1 0 auto; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: .7em 1.1em;
  font-family: var(--font-sans);
  font-size: var(--step--1);
}
.skip-link:focus { left: .5rem; top: .5rem; }

/* ---------- 4. Masthead -------------------------------------------------- */

.masthead { padding-top: clamp(1.1rem, 3.5vw, 2.1rem); }

.masthead__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-sans);
  font-size: .68rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: .7rem;
}
.masthead__bar time { white-space: nowrap; }
.masthead__edition { display: none; text-transform: none; letter-spacing: .1em; }
@media (min-width: 34rem) { .masthead__edition { display: block; } }

.masthead__brand {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: clamp(1.4rem, 4.5vw, 2.6rem) 0 clamp(1.1rem, 3.5vw, 1.9rem);
  text-align: center;
}

.wordmark {
  display: inline-block;
  font-size: var(--step-4);
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: .95;
  text-decoration: none;
  color: var(--ink);
}
.wordmark:hover { color: var(--accent); }

.tagline {
  margin-top: .85rem;
  font-family: var(--font-sans);
  font-size: .66rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-left: .28em; /* optical: compensate trailing letter-space */
}

/* ---------- 5. Navigation ------------------------------------------------ */

.nav {
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav__links {
  display: flex;
  gap: clamp(1rem, 3.5vw, 2.1rem);
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav__links::-webkit-scrollbar { display: none; }

.nav__links a {
  display: block;
  padding: .85rem 0;
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.nav__links a:hover { color: var(--ink); }
.nav__links a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.theme-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-faint); }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: none; }
}

/* ---------- 6. Shared story pieces --------------------------------------- */

.kicker {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
}

.headline {
  font-size: var(--step-2);
  margin-top: .5rem;
  text-wrap: balance;
}
.headline a { text-decoration: none; }
.headline a:hover { color: var(--accent); }

.dek {
  margin-top: .55rem;
  color: var(--ink-soft);
  font-size: var(--step-0);
  line-height: 1.5;
  text-wrap: pretty;
}

.byline {
  margin-top: .8rem;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.byline__sep { opacity: .5; }
.byline strong { color: var(--ink-soft); font-weight: 500; }

.thumb {
  display: block;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.thumb img { width: 100%; }

/* Illustration plates carry their own warm paper tone, the way a printed
   photograph does. In dark mode they are eased down so they stop glaring. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .thumb img,
  :root:not([data-theme="light"]) figure img {
    filter: brightness(.84) contrast(1.04) saturate(.95);
  }
}
:root[data-theme="dark"] .thumb img,
:root[data-theme="dark"] figure img {
  filter: brightness(.84) contrast(1.04) saturate(.95);
}

/* ---------- 7. Lead story ------------------------------------------------ */

.lead {
  display: grid;
  gap: clamp(1.25rem, 4vw, 2.4rem);
  padding: clamp(1.9rem, 6vw, 3.4rem) 0;
  border-bottom: 1px solid var(--rule);
}
.lead__media { order: 2; }
@media (min-width: 52rem) {
  .lead { grid-template-columns: 1.05fr .95fr; align-items: center; }
}
.lead__media .thumb img { aspect-ratio: 3 / 2; object-fit: cover; }
.lead .headline { font-size: var(--step-4); line-height: 1.03; }
.lead .dek { font-size: var(--step-1); margin-top: .9rem; }

/* ---------- 8. Story list ------------------------------------------------ */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.7rem, 5vw, 2.6rem) 0 .2rem;
}
.section-head h2 {
  font-family: var(--font-sans);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.section-head a {
  font-family: var(--font-sans);
  font-size: .7rem;
  letter-spacing: .08em;
  color: var(--ink-faint);
  text-decoration: none;
}
.section-head a:hover { color: var(--accent); }

.stories { display: grid; gap: 0; }

.story {
  display: grid;
  gap: 1.15rem;
  padding: clamp(1.5rem, 4.5vw, 2.1rem) 0;
  border-top: 1px solid var(--rule);
}
.story:first-child { border-top: none; }
.story__media { display: none; }
@media (min-width: 34rem) {
  .story { grid-template-columns: 1fr 8.5rem; align-items: start; }
  .story__media { display: block; order: 2; }
}
@media (min-width: 52rem) {
  .story { grid-template-columns: 1fr 12rem; gap: 2rem; }
}
.story__media .thumb img { aspect-ratio: 1 / 1; object-fit: cover; }
.story .headline { font-size: var(--step-1); }

/* ---------- 9. Article --------------------------------------------------- */

.article { padding-bottom: clamp(2rem, 6vw, 3.5rem); }

.article__header {
  padding: clamp(2rem, 6vw, 3.4rem) 0 clamp(1.4rem, 4vw, 2rem);
  text-align: center;
  border-bottom: 1px solid var(--rule);
}
.article__header .headline {
  font-size: var(--step-3);
  line-height: 1.06;
  margin-top: .7rem;
}
.article__header .dek {
  font-size: var(--step-1);
  margin-top: 1rem;
  margin-inline: auto;
  max-width: 34rem;
}
.article__header .byline { justify-content: center; margin-top: 1.3rem; }

.article__hero { margin: clamp(1.6rem, 5vw, 2.6rem) 0; }

.prose { max-width: var(--measure); margin-inline: auto; }
.prose > * + * { margin-top: 1.35em; }
.prose p { text-wrap: pretty; }

.prose h2 {
  font-size: var(--step-2);
  margin-top: 2.4em;
  padding-top: 1.1em;
  border-top: 1px solid var(--rule);
}
.prose h3 { font-size: var(--step-1); margin-top: 2em; }
.prose h2 + *, .prose h3 + * { margin-top: .75em; }

.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
.prose a:hover { color: var(--accent); }

.prose ul, .prose ol { padding-left: 1.35em; }
.prose li + li { margin-top: .5em; }
.prose li::marker { color: var(--ink-faint); }

.prose strong { font-weight: 600; }

.prose hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin-block: 2.6em;
}

.prose code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .1em .35em;
}
.prose pre {
  font-family: var(--font-mono);
  font-size: .84em;
  line-height: 1.6;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }

blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.3em;
  color: var(--ink-soft);
  font-style: italic;
}
blockquote cite {
  display: block;
  margin-top: .7em;
  font-style: normal;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-faint);
}

.pullquote {
  border: 0;
  padding: 0;
  margin-block: 2em;
  font-size: var(--step-2);
  line-height: 1.28;
  font-style: normal;
  color: var(--ink);
  text-align: center;
  text-wrap: balance;
}
.pullquote::before {
  content: "";
  display: block;
  width: 2.2rem;
  height: 1px;
  background: var(--accent);
  margin: 0 auto 1.1em;
}
.pullquote::after {
  content: "";
  display: block;
  width: 2.2rem;
  height: 1px;
  background: var(--accent);
  margin: 1.1em auto 0;
}

figure { margin-block: 2em; }
figure img {
  width: 100%;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
}
figcaption {
  margin-top: .7rem;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--ink-faint);
}
/* let figures breathe past the text column on wide screens */
@media (min-width: 58rem) {
  .prose figure.wide {
    width: min(54rem, 92vw);
    margin-inline: calc(50% - min(27rem, 46vw));
  }
}

.article__footer {
  max-width: var(--measure);
  margin: clamp(2.4rem, 6vw, 3.6rem) auto 0;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}
.tags { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: 0; padding: 0; }
.tags a {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .3rem .7rem;
}
.tags a:hover { color: var(--accent); border-color: var(--accent); }

.pager {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
}
@media (min-width: 34rem) { .pager { grid-template-columns: 1fr 1fr; } }
.pager a {
  display: block;
  text-decoration: none;
  border: 1px solid var(--rule);
  padding: 1rem 1.1rem;
  transition: border-color .15s ease;
}
.pager a:hover { border-color: var(--ink-faint); }
.pager span {
  display: block;
  font-family: var(--font-sans);
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: .4rem;
}
.pager strong { font-weight: 600; font-size: var(--step-0); line-height: 1.3; }
.pager .pager--next { text-align: right; }

/* ---------- 10. Archive -------------------------------------------------- */

.page-head {
  padding: clamp(2rem, 6vw, 3.4rem) 0 clamp(1.3rem, 4vw, 2rem);
  border-bottom: 1px solid var(--rule);
}
.page-head h1 { font-size: var(--step-3); }
.page-head p { margin-top: .8rem; color: var(--ink-soft); max-width: 34rem; }

.year-head {
  font-family: var(--font-sans);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .2em;
  color: var(--ink-faint);
  padding: clamp(1.8rem, 5vw, 2.6rem) 0 .6rem;
}

.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li { border-top: 1px solid var(--rule); }
.archive-list a {
  display: grid;
  gap: .15rem .9rem;
  padding: 1rem 0;
  text-decoration: none;
}
@media (min-width: 40rem) {
  .archive-list a { grid-template-columns: 5.5rem 1fr; align-items: baseline; }
}
.archive-list time {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-faint);
  white-space: nowrap;
}
.archive-list strong { font-weight: 600; font-size: var(--step-1); line-height: 1.28; }
.archive-list a:hover strong { color: var(--accent); }
.archive-list em {
  display: block;
  font-style: normal;
  font-family: var(--font-sans);
  font-size: .64rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .3rem;
}
@media (min-width: 40rem) { .archive-list em { grid-column: 2; } }

/* ---------- 11. Notice / 404 --------------------------------------------- */

.notice {
  text-align: center;
  padding: clamp(3.5rem, 14vw, 8rem) 0;
  max-width: 32rem;
  margin-inline: auto;
}
.notice__code {
  font-family: var(--font-sans);
  font-size: .68rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--accent);
}
.notice h1 { font-size: var(--step-3); margin-top: 1rem; }
.notice p { margin-top: 1rem; color: var(--ink-soft); }

.button {
  display: inline-block;
  margin-top: 1.8rem;
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--paper);
  background: var(--ink);
  padding: .8rem 1.5rem;
  border: 1px solid var(--ink);
  transition: background .15s ease, color .15s ease;
}
.button:hover { background: transparent; color: var(--ink); }

/* ---------- 12. Footer --------------------------------------------------- */

.footer {
  margin-top: clamp(3rem, 8vw, 5rem);
  border-top: 1px solid var(--rule);
  padding: clamp(1.8rem, 5vw, 2.6rem) 0 clamp(2.2rem, 6vw, 3rem);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-faint);
}
.footer__grid {
  display: grid;
  gap: 1.4rem;
  align-items: start;
}
@media (min-width: 46rem) {
  .footer__grid { grid-template-columns: 1fr auto; }
}
.footer__mark {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  color: var(--ink);
  letter-spacing: -.02em;
}
.footer__note { margin-top: .5rem; max-width: 28rem; line-height: 1.55; }
.footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.3rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer__links a { text-decoration: none; color: var(--ink-faint); }
.footer__links a:hover { color: var(--accent); }
.footer__legal {
  margin-top: 1.8rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  justify-content: space-between;
  font-size: .68rem;
  letter-spacing: .04em;
}

/* ---------- 13. Print ---------------------------------------------------- */

@media print {
  .nav, .theme-toggle, .footer__links, .pager, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .prose a { text-decoration: none; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
}
