/* Palette and typography inherited from the `this-is-england` project, with a
   dark scheme layered on top (AGENTS.md requires both). */
:root {
  color-scheme: light dark;

  --ink: #181512;
  --ink-soft: #4a4540;
  --paper: #fbf7ef;
  --paper-2: #f2ecdf;
  --paper-3: #e9e1cf;
  --card: #ffffff;
  --rule: #d9cfbd;
  --red: #b22234;
  --red-deep: #8a1824;
  --blue: #2a3f7a;
  --accent: #e0b34a;
  --history-bg: #fff7ea;
  --history-rule: #ecd7a5;
  --history-ink: #8a5a00;
  --shadow: 0 1px 2px rgba(24, 21, 18, .06), 0 8px 24px rgba(24, 21, 18, .08);
  --shadow-lift: 0 4px 10px rgba(24, 21, 18, .08), 0 18px 36px rgba(24, 21, 18, .12);
  --radius: 14px;
  --max: 720px;
  --max-hero: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f3eee4;
    --ink-soft: #a9a094;
    --paper: #14120f;
    --paper-2: #1d1a15;
    --paper-3: #262119;
    --card: #201c17;
    --rule: #38322a;
    --red: #e07685;
    --red-deep: #f0949f;
    --blue: #93a6dd;
    --accent: #e0b34a;
    --history-bg: #241d12;
    --history-rule: #4a3c22;
    --history-ink: #e0b34a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lift: 0 4px 10px rgba(0, 0, 0, .45), 0 18px 36px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
html { background: var(--paper); }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: -.01em;
}

.topbar__title { line-height: 1; }

/* The project mark — a book and quill. Masked rather than dropped in as an
   <img> so it takes currentColor and follows the theme. */
.mark {
  width: 26px;
  height: 26px;
  flex: none;
  display: inline-block;
  background-color: var(--red);
  -webkit-mask: url(icon.svg) center / contain no-repeat;
  mask: url(icon.svg) center / contain no-repeat;
}

.topbar__back {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

.topbar__back:hover { background: var(--paper-3); }

/* ---- View transitions ---- */
.view { flex: 1; }
.view > * { animation: fade .25s ease-out; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view > * { animation: none; }
}

/* ---- Hero (home) ---- */
.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 16px 12px;
  text-align: left;
}

.hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 900;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.02;
  letter-spacing: -.02em;
  margin: 0 0 10px;
}

.hero h1 em {
  font-style: italic;
  color: var(--red);
}

.hero p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 52ch;
}

/* ---- Grid of entries ---- */
.grid {
  max-width: var(--max);
  margin: 16px auto 40px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
  }
}

.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}

.card:active { transform: scale(.98); }

@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
  }
}

.card__img {
  aspect-ratio: 4 / 3;
  width: 100%;
  /* `height: auto` is required, or the img's height attribute wins over aspect-ratio */
  height: auto;
  object-fit: cover;
  background: var(--paper-2);
  display: block;
}

.card__body { padding: 10px 12px 14px; }

.card__num {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: .78rem;
  color: var(--red);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.card__title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.2;
  margin: 2px 0 0;
  letter-spacing: -.01em;
}

/* ---- Article (entry) ---- */
.article { padding: 0 0 60px; }

.article__content {
  max-width: var(--max);
  margin: 0 auto;
}

/* The hero image is the centrepiece — let it run wider than the text column,
   and taller on small screens where there is no width to spend. */
.article__hero {
  position: relative;
  max-width: var(--max-hero);
  margin: 0 auto;
  aspect-ratio: 3 / 2;
  background: var(--paper-2);
  overflow: hidden;
}

@media (min-width: 900px) {
  .article__hero {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    margin-top: 18px;
  }
}

.article__hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.article__hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 45%;
  background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent);
}

.article__headline {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  color: #fff;
  z-index: 1;
}

@media (min-width: 900px) {
  .article__headline {
    left: 32px;
    right: 32px;
    bottom: 26px;
  }
}

.article__num {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}

.article__title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 900;
  font-size: clamp(1.8rem, 6.5vw, 3rem);
  line-height: 1.05;
  letter-spacing: -.02em;
  margin: 2px 0 0;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .35);
}

.article__credit {
  margin: 6px 18px 0;
  font-size: .75rem;
  color: var(--ink-soft);
  text-align: right;
}

.article__credit a { color: inherit; }

.article__body {
  padding: 22px 18px 0;
  font-size: 1.05rem;
}

.article__body p { margin: 0 0 1em; }

.article__lede {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 1.15rem;
  color: var(--ink);
}

.article__lede::first-letter {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 900;
  font-size: 3.5rem;
  float: left;
  line-height: .9;
  padding: 6px 8px 0 0;
  color: var(--red);
}

/* ---- Callouts ---- */
.callout {
  margin: 22px 18px 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--paper-2);
  position: relative;
}

.callout__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 6px;
}

.callout__label::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 2px;
  background: var(--red);
}

.callout p { margin: 0; font-size: 1rem; }
.callout p + p { margin-top: .7em; }

/* Scoped with .callout so it outranks the `.callout p + p` rule above without
   reaching for !important. */
.callout .callout__source {
  font-size: .8rem;
  line-height: 1.4;
  color: var(--ink-soft);
  margin-top: .9em;
  padding-top: .7em;
  border-top: 1px solid var(--rule);
}

.callout--history .callout__source { border-top-color: var(--history-rule); }

.callout__source a {
  color: inherit;
  text-underline-offset: 2px;
}

.callout__source a:hover { color: var(--red-deep); }

.callout--history {
  background: var(--history-bg);
  border-color: var(--history-rule);
}

.callout--history .callout__label { color: var(--history-ink); }
.callout--history .callout__label::before { background: var(--history-ink); }

.callout__subtitle {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 6px;
  color: var(--ink);
}

/* ---- Further reading ---- */
.reading {
  margin: 26px 18px 0;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.reading h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 900;
  font-size: 1.2rem;
  margin: 0 0 10px;
  letter-spacing: -.01em;
}

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

.reading li { margin: 0; }

.reading a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 8px;
  font-weight: 500;
  line-height: 1.3;
}

.reading a:hover { border-color: var(--red); color: var(--red-deep); }
.reading a::after { content: " →"; color: var(--ink-soft); }

.reading__source {
  display: block;
  font-weight: 400;
  font-size: .82rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* ---- Nav between articles ---- */
.nextprev {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 28px 18px 0;
}

.nextprev a,
.nextprev span {
  display: block;
  padding: 14px 14px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  text-decoration: none;
  color: var(--ink);
  font-size: .95rem;
  line-height: 1.25;
}

.nextprev a:hover { border-color: var(--red); }

.nextprev .mini {
  display: block;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 2px;
}

.nextprev .next { text-align: right; }

.nextprev .disabled {
  opacity: .4;
  pointer-events: none;
}

/* ---- Footer ---- */
.sitefoot {
  border-top: 1px solid var(--rule);
  padding: 18px 16px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  color: var(--ink-soft);
  font-size: .88rem;
  text-align: center;
  background: var(--paper-2);
}

.sitefoot a { color: var(--red-deep); }

/* ---- Empty / loading ---- */
.loading,
.notfound,
.empty {
  max-width: var(--max);
  margin: 0 auto;
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-soft);
}

.empty code {
  font-family: 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
  font-size: .9em;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 2px 6px;
}
