/* Mail on Monday — CSS bolt-on layer.
   Warm, restrained, modern blog styling. No JS, no build step. */

:root {
  --color-bg: #faf8f3;
  --color-banner-bg: #ebe4d8;
  --color-banner-border: #c7bcae;
  --color-text: #1d1b18;
  --color-muted: #514a43;
  --color-accent: #006d75;
  --color-accent-hover: #004f55;
  --color-warm-accent: #b45127;
  --color-border: #c8beb0;
  --color-card-bg: #ffffff;
  --color-map-border: #b9afa2;
  --font-body: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #171512;
    --color-banner-bg: #211d18;
    --color-banner-border: #3b342c;
    --color-text: #f1ede5;
    --color-muted: #c4b8aa;
    --color-accent: #68c5c9;
    --color-accent-hover: #91dadd;
    --color-warm-accent: #e08b5e;
    --color-border: #4a4238;
    --color-card-bg: #211d18;
    --color-map-border: #5a5044;
  }
}

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: var(--color-border);
  text-underline-offset: 0.15em;
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2.5rem 0;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 1.25rem;
  border-left: 3px solid var(--color-warm-accent);
  color: var(--color-muted);
  font-style: italic;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-banner-bg);
  padding: 0.15em 0.4em;
  border-radius: 0.3em;
}

pre {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
}

ul,
ol {
  padding-left: 1.4rem;
}

li + li {
  margin-top: 0.35rem;
}

/* --- Layout scaffolding ---
   layout-grid holds the post/page content and the sidebar as siblings in
   one grid, so the post header, map, content, and widget sidebar can be
   placed consistently across breakpoints. */

.page-shell {
  width: min(92vw, 60rem);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "meta"
    "map"
    "content"
    "sidebar";
  column-gap: 2.5rem;
  row-gap: 1.5rem;
}

/* .post-article is a semantic wrapper only - its children (post-header,
   post-map, post-content) become direct grid items of .layout-grid. */
.post-article {
  display: contents;
}

.content-frame {
  grid-area: content;
  max-width: 40rem;
}

/* --- Banner / nav --- */

.site-banner {
  background: var(--color-banner-bg);
  border-bottom: 1px solid var(--color-banner-border);
  font-family: var(--font-sans);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-banner .page-shell {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.25rem;
}

.site-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

.site-nav {
  display: flex;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}

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

/* --- Main content --- */

main {
  padding-block: 2.5rem 4rem;
}

h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: 0;
}

/* --- Post header / map / content ---
   Each is a direct grid item (see .post-article above), placed by name
   in .layout-grid's grid-template-areas. The map stays inline with the
   post, directly below the heading/date, at every viewport width. */

.post-header {
  grid-area: meta;
  margin-bottom: 0;
}

.post-meta {
  min-width: 0;
}

.post-title {
  max-width: 12ch;
  margin: 0 0 0.6rem;
  font-size: clamp(2.2rem, 6vw, 3.35rem);
  color: var(--color-text);
  font-weight: 780;
  line-height: 1.06;
}

.post-date {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.post-map {
  grid-area: map;
  width: 100%;
  height: 220px;
  border-radius: 0.5rem;
  border: 1px solid var(--color-map-border);
  overflow: hidden;
}

.post-content {
  grid-area: content;
  max-width: 40rem;
}

.post-content h1,
.post-content h2,
.post-content h3 {
  font-family: var(--font-sans);
}

.post-content h1 {
  margin: 2.4rem 0 0.85rem;
  font-size: 1.45rem;
  font-weight: 720;
}

.post-content h2 {
  margin: 2.15rem 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 720;
}

.post-content h3 {
  margin: 1.8rem 0 0.65rem;
  font-size: 1.08rem;
  font-weight: 700;
}

.post-content p {
  margin: 0 0 1.2rem;
}

.post-hero {
  margin: 0 0 1.5rem;
}

.post-hero img {
  display: block;
  width: 100%;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
  margin: 1.5rem 0;
}

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

.post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.post-nav-link {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.15rem;
  font-family: var(--font-sans);
  text-decoration: none;
}

.post-nav-next {
  text-align: right;
}

.post-nav-label {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.post-nav-title {
  overflow-wrap: anywhere;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--color-border);
  text-underline-offset: 0.15em;
}

/* --- Widget sidebar / calendar --- */

.widget-sidebar {
  grid-area: sidebar;
  font-family: var(--font-sans);
}

.calendar-widget {
  background: var(--color-card-bg);
  border: 1px solid var(--color-map-border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
}

.calendar-widget h3 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar {
  border-collapse: collapse;
  margin: 0.5rem 0;
  width: 100%;
}

.calendar caption {
  text-align: left;
  font-weight: 600;
  padding-bottom: 0.35rem;
}

.calendar td,
.calendar th {
  width: 14.285%;
  padding: 0.2rem;
  text-align: center;
  font-size: 0.85rem;
}

.calendar th {
  color: var(--color-muted);
  font-weight: 500;
}

.calendar td.has-post a {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-card-bg);
  font-weight: 700;
  text-decoration: none;
}

.calendar td.has-post a:hover {
  background: var(--color-accent-hover);
  color: var(--color-card-bg);
}

.calendar-archive-link {
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
}

/* --- Archive pages --- */

.archive-index,
.archive-month {
  grid-area: content;
  max-width: 40rem;
}

.archive-index h1,
.archive-header,
.archive-nav,
.archive-month-list,
.archive-post-list {
  font-family: var(--font-sans);
}

.archive-index h1,
.archive-header h1 {
  margin-top: 0;
}

.archive-header {
  margin-bottom: 1.25rem;
}

.archive-map {
  width: 100%;
  aspect-ratio: 1;
  min-height: 280px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.archive-map-point {
  display: none;
}

.archive-map-popup a {
  font-weight: 700;
}

.archive-map-popup p {
  margin: 0.2rem 0 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.archive-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  font-size: 0.95rem;
}

.archive-month-list,
.archive-post-list {
  padding-left: 0;
  list-style: none;
}

.archive-month-list li,
.archive-post-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  padding-block: 0.65rem;
  border-bottom: 1px solid var(--color-border);
}

.archive-month-list span,
.archive-post-list time {
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* --- Footer --- */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding-block: 1.5rem;
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

/* --- Responsive behaviour ---
   Below 900px: everything stacks in one column.
   From 900px: the post remains in the main column while the widget sidebar
   behaves like fixed page chrome at the lower right of the viewport. */
@media (min-width: 900px) {
  .layout-grid {
    grid-template-columns: minmax(0, 40rem) 15rem;
    grid-template-areas:
      "meta    sidebar"
      "map     sidebar"
      "content sidebar";
    align-items: start;
  }

  .content-frame {
    max-width: none;
  }

  .post-content {
    max-width: none;
  }

  .widget-sidebar {
    position: fixed;
    right: max(calc(4vw + 1.5rem), calc((100vw - 60rem) / 2 + 1.5rem));
    bottom: 1.5rem;
    width: 15rem;
  }
}

@media (max-width: 480px) {
  .site-banner .page-shell {
    flex-direction: column;
    align-items: flex-start;
  }

  .post-title {
    max-width: none;
    font-size: 2rem;
  }

  .post-nav {
    grid-template-columns: 1fr;
  }

  .post-nav-next {
    text-align: left;
  }
}
