/*
 * Look & feel modeled on the "Shhh" WordPress theme by Automattic (GPLv2):
 * DM Mono everywhere, light weight, big text, one blue accent.
 * Values below are taken from its theme.json.
 */

@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/fonts/dm-mono-latin-300-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Mono';
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url('/fonts/dm-mono-latin-300-italic.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/dm-mono-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/dm-mono-latin-500-normal.woff2') format('woff2');
}

:root {
  /* Palette */
  --base: #ffffff;
  --primary: #2f5ee9;
  --secondary: #111111;
  --tertiary: #878787;
  --accent: #2f5ee911;
  --accent-2: #2f5ee91f;
  --accent-3: #11111111;
  --accent-4: #abb8c3;

  /* Spacing (WordPress default presets) */
  --space-30: 0.67rem;
  --space-50: 1.5rem;
  --space-60: 2.25rem;
  --space-70: 3.38rem;
  --space-80: 5.06rem;

  /* Type scale */
  --text-x-small: 0.8rem;
  --text-small: 1rem;
  --text-medium: 1.125rem;
  --text-large: 1.37rem;

  --font: 'DM Mono', ui-monospace, monospace;
  /* Content width: the theme's fluid width, capped at ~62 characters per line */
  --content-max: 51rem;
  --content-size: min(calc(100% - 2 * var(--space-60)), max(68vw, 80vw + (500px - 100vw) * 0.5), var(--content-max));

  color-scheme: light dark;
}

/* "Dark" style variation (dark.json) */
@media (prefers-color-scheme: dark) {
  :root {
    --base: #111111;
    --secondary: #ffffff;
    --accent-3: #ffffff11;
    --accent-4: #473c47;
  }
}

/* Base */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--base);
  color: var(--secondary);
  font-family: var(--font);
  font-size: var(--text-large);
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

.wrap {
  width: var(--content-size);
  margin-inline: auto;
}

a {
  color: var(--secondary);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  background: var(--accent);
  color: var(--primary);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 300;
  line-height: 1.6;
  margin: var(--space-70) 0 var(--space-30);
}

h1,
h2,
h3 {
  font-size: var(--text-large);
  font-weight: 700;
  line-height: 1.1;
}

h4,
h5 {
  font-size: var(--text-medium);
}

h6 {
  font-size: var(--text-small);
}

img {
  max-width: 100%;
  height: auto;
}

.muted {
  color: var(--tertiary);
}

/* Header & footer */

.site-header,
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-30) var(--space-50);
}

/* Header starts lower on the page: title · subpages */
.site-header {
  gap: var(--space-30) var(--space-60);
  padding-block: clamp(var(--space-80), 22vh, 15rem) var(--space-80);
}

.site-header .separator {
  color: var(--tertiary);
}

.site-footer {
  justify-content: space-between;
  padding-block: var(--space-80) var(--space-60);
  font-size: var(--text-small);
  color: var(--tertiary);
}

.site-title {
  font-weight: 300;
}

.site-title:hover,
.site-title:focus-visible {
  background: var(--accent-2);
  color: var(--primary);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-30) var(--space-50);
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: var(--accent-3);
  color: inherit;
}

.site-footer .site-nav a {
  color: var(--tertiary);
}

/* Narrow screens: title and subpages on separate lines, no dot */
@media (max-width: 40rem) {
  .site-header {
    flex-direction: column;
    gap: var(--space-30);
  }

  .site-header .separator {
    display: none;
  }
}

/* Post titles: hanging ⌗ in the margin */

.post-title {
  margin: 0;
  font-size: var(--text-large);
  font-weight: 700;
  line-height: 1.1;
}

.post-title::before {
  content: '⌗';
  position: absolute;
  margin-left: -24px;
  color: var(--accent-4);
  font-weight: normal;
}

.post-title:hover::before {
  color: var(--primary);
}

.post-date {
  color: var(--tertiary);
  font-size: var(--text-medium);
}

.draft-badge {
  margin-left: 0.5em;
  padding: 0 0.4em;
  background: var(--accent-2);
  color: var(--primary);
  font-size: var(--text-x-small);
  font-weight: 400;
  vertical-align: middle;
}

/* Home: short intro about the blog, above the first article */
.intro {
  /* 54px below the nav instead of the usual 81px, as in the template */
  margin-top: calc(var(--space-70) - var(--space-80));
  margin-bottom: 8.5rem;
  font-size: var(--text-small);
}

/* Home: title, excerpt with "— read more", date (spacing as in the Shhh theme) */

.post-list {
  display: grid;
  gap: 7.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/*
 * Excerpt: max. 3 lines, "— read more" always at the end of the last line.
 * The link comes first in the HTML and floats to the bottom right, pushed down
 * by an invisible float that's as tall as the box minus one line.
 */
.post-excerpt {
  display: flex;
  margin-top: var(--space-60);
}

.post-excerpt p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  margin: 0;
}

.post-excerpt p::before {
  content: '';
  float: right;
  height: 100%;
  margin-bottom: -1.6em; /* one line */
}

.read-more {
  float: right;
  clear: both;
  margin-left: 1ch;
  background: var(--accent-2);
  white-space: nowrap;
}

.read-more:hover,
.read-more:focus-visible {
  background: var(--primary);
  color: var(--base);
}

.post-list .post-date {
  display: block;
  margin-top: 2.5rem; /* 40px */
}

/* Home: clear break between the last article and the signup */
.post-list + .newsletter {
  margin-top: 10rem;
}

/* Single post */

.post-header {
  margin-bottom: var(--space-60);
}

.back-link {
  display: inline-block;
  margin-bottom: var(--space-60);
  color: var(--tertiary);
  font-size: var(--text-medium);
}

.post-meta {
  margin-top: var(--space-60);
}

.post-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-30) var(--space-60);
  margin-top: var(--space-70);
}

/* Article body */

.prose > * {
  margin-block: 0;
}

.prose > * + * {
  margin-block-start: var(--space-60);
}

.prose > :is(h1, h2, h3, h4, h5, h6) {
  margin-block-start: var(--space-70);
}

.prose a {
  background: var(--accent-2);
}

.prose a:hover,
.prose a:focus-visible {
  background: var(--accent);
  color: var(--primary);
}

.prose ul,
.prose ol {
  padding-left: var(--space-70);
}

.prose blockquote {
  margin-inline: 0;
  padding-left: var(--space-50);
  border-left: 4px solid;
}

.prose blockquote > * {
  margin-block: 0;
}

.prose blockquote > * + * {
  margin-block-start: var(--space-50);
}

.prose pre {
  padding: var(--space-50);
  border: 2px solid var(--accent-4);
  overflow-x: auto;
  font-size: var(--text-medium);
}

.prose code {
  font-family: var(--font);
}

.prose hr {
  border: 0;
  border-bottom: 1px solid currentColor;
}

/* Newsletter signup */

.newsletter {
  display: grid;
  gap: var(--space-30);
  margin-top: var(--space-80);
  font-size: var(--text-medium);
}

.newsletter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-30);
}

.newsletter input {
  flex: 1 1 14rem;
  min-width: 0;
  padding: var(--space-30);
  border: 1px solid var(--accent-4);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.newsletter input::placeholder {
  color: var(--tertiary);
}

.newsletter input:focus-visible {
  border-color: var(--primary);
  outline-offset: -1px;
}

/* Buttons: square, dark, blue on hover (theme.json "button") */
button {
  padding: var(--space-30) var(--space-50);
  border: 0;
  border-radius: 0;
  background: var(--secondary);
  color: var(--base);
  font: inherit;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--primary);
  color: var(--base);
}

.newsletter-note {
  margin: 0;
  color: var(--tertiary);
  font-size: var(--text-small);
}

/*
 * After the form posts, /api/subscribe sends the reader back with #subscribed or #subscribe-error.
 * :target shows the matching message; on success it replaces the whole form (heading, input, hint).
 */
.newsletter-message {
  margin: 0;
  padding-block: var(--space-30);
  border-block: 1px solid transparent; /* same height as the input row */
  scroll-margin-top: 30vh; /* jumping to #subscribed lands mid-screen, not at the very top */
}

.newsletter-message:target {
  display: block;
}

#subscribed:target ~ * {
  display: none;
}

/* Spam trap: invisible to people, bots fill it in */
.honeypot {
  position: absolute;
  left: -9999px;
}
