/* ============================================================
   philoserf — Alpine theme
   Base styles first, then page components (home, archive, article).
   The header wordmark is rendered by baseof.html from .Site.Title.
   ============================================================ */

/* --- Tokens --- */

:root {
  /* Color — alpine: snow, slate, and denim. The background hexes are
     mirrored outside CSS via params.themeColor in hugo.yaml (theme-color
     metas, webmanifest) — keep them in sync when retinting. */
  --primary-color: #455a76;
  /* Hover shifts away from the resting link color: darker on the light
     scheme, brighter on the dark one — named by role, not lightness */
  --link-hover: #344458;
  --text-color: #354a54;
  --text-muted: #4f636c;
  --background-color: #dfe7eb;
  --surface-color: #d2dfe8;
  --border-color: #bcd2e3;

  /* Font stacks — platform-native */
  --font-sans:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-serif:
    ui-serif, "New York", "Iowan Old Style", Charter, Georgia, Cambria, serif;
  --font-mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;

  /* Fluid type — small viewport → large viewport */
  --fs-base: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem); /* 17 → 19 */
  --fs-h1: clamp(1.75rem, 1.4rem + 1.5vw, 2.25rem); /* 28 → 36 */
  --fs-h2: clamp(1.4rem, 1.25rem + 0.75vw, 1.75rem); /* 22 → 28 */
  --fs-h3: clamp(1.2rem, 1.1rem + 0.5vw, 1.4rem); /* 19 → 22 */
  --fs-h4: clamp(1.1rem, 1.05rem + 0.25vw, 1.2rem); /* 18 → 19 */
  --fs-small: 0.85rem;

  /* Page shell width; each <main> class sets its own measure */
  --measure-shell: 70rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #88b2d8;
    --link-hover: #acc9e4;
    --text-color: #dfe7eb;
    --text-muted: #a4adb2;
    --background-color: #1c272d;
    --surface-color: #27373f;
    --border-color: #324750;
  }
}

/* --- Reset & base --- */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  line-height: 1.68;
  color: var(--text-color);
  background: var(--background-color);
  max-width: var(--measure-shell);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 1.5rem;
  transition:
    background-color 0.2s,
    color 0.2s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (max-width: 640px) {
  body {
    padding: 1.5rem 1rem 1rem;
  }
}

/* --- Skip link (keyboard a11y) --- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary-color);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* --- Typography --- */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-serif);
  line-height: 1.22;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-color);
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-h1);
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--fs-h2);
  margin-top: 2.2rem;
  margin-bottom: 1rem;
}

h3 {
  font-size: var(--fs-h3);
  margin-top: 1.6rem;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: var(--fs-h4);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1.15rem;
  text-wrap: pretty;
}

/* --- Links --- */

a {
  color: var(--primary-color);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.2s;
}

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

/* --- Header & nav (centered wordmark over small-caps nav) --- */

header {
  margin-bottom: 2.2rem;
  padding: 0 0 1.4rem;
  border-bottom: 1px solid var(--border-color);
}

.primary-nav {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 0.9rem;
}

.nav-brand {
  flex-shrink: 0;
}

/* Text wordmark (rendered in baseof.html) */
.wordmark {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-color);
  text-decoration: none;
  /* ~51px tap target; negative margin cancels the padding so the
     centered header layout is unchanged */
  display: inline-block;
  padding: 0.75rem 0.5rem;
  margin: -0.75rem -0.5rem;
}

.wordmark:hover {
  color: var(--primary-color);
}

.nav-links {
  display: flex;
  gap: 1.6rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-link {
  font-family: var(--font-sans);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  position: relative;
  padding: 0.75rem 0.25rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s;
}

.nav-link::after {
  content: "";
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 0;
  height: 1.5px;
  background: var(--primary-color);
  transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary-color);
}

/* --- Main (prose-width container) --- */

main {
  margin: 0 auto;
  padding: 0.5rem 0;
  min-height: calc(100vh - 320px);
}

/* --- Code & blockquotes --- */

code {
  background: var(--surface-color);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

pre {
  background: var(--surface-color);
  padding: 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-left: 3px solid var(--primary-color);
  font-size: 0.85rem;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 1em;
}

blockquote {
  border-left: 3px solid var(--primary-color);
  padding: 0.1rem 0 0.1rem 1.25rem;
  margin: 0 0 1.15rem;
  color: var(--text-muted);
  font-size: 0.95em;
}

/* --- Lists & images --- */

ul,
ol {
  margin-left: 1.4rem;
  margin-bottom: 1.15rem;
}

li {
  margin-bottom: 0.4rem;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
  border-radius: 6px;
}

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

/* --- Tables --- */

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: var(--fs-small);
  font-variant-numeric: tabular-nums;
}

.content th,
.content td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.content th {
  background: var(--surface-color);
  font-weight: 600;
}

.content tbody tr:hover {
  background: var(--surface-color);
}

@media (max-width: 640px) {
  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Articles (single post) --- */

article {
  margin-bottom: 2rem;
}

/* --- Utilities --- */

.latin-motto {
  font-family: var(--font-serif);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 2.4rem 0;
}

.latin-motto p {
  letter-spacing: 0.05em;
  margin-bottom: 0;
}

/* --- Footer --- */

footer {
  margin-top: 3rem;
  padding-top: 1.3rem;
  padding-bottom: 1rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-family: var(--font-sans);
  color: var(--text-muted);
  font-size: 0.75rem;
}

footer p {
  margin-bottom: 0.5rem;
}

footer a {
  color: var(--text-muted);
}

footer a:hover {
  color: var(--primary-color);
}

/* --- Focus styles (keyboard) --- */

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

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Print --- */

@media print {
  body {
    max-width: 100%;
    padding: 0;
    font-size: 11pt;
    background: #fff;
    color: #000;
  }

  header,
  footer,
  nav {
    display: none;
  }

  a {
    color: inherit;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  article {
    background: none;
    padding: 0;
    box-shadow: none;
  }
}

/* --- Editorial redesign --- */
.home-main {
  max-width: none;
  padding-top: 0;
}

.eyebrow {
  margin: 0 0 0.9rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.hero {
  display: flex;
  align-items: center;
  gap: 3rem;
  max-width: 68rem;
  padding: 4rem 0;
}

.hero-text {
  flex: 1 1 auto;
  min-width: 0;
}

.hero-logo {
  flex: 0 0 auto;
  width: clamp(9rem, 15vw, 12.5rem);
  height: auto;
}

.motto-logo {
  display: none;
}

.hero h1 {
  max-width: 52rem;
  margin: 0;
  font-size: clamp(2.5rem, 1.5rem + 3.5vw, 3.75rem); /* 40 → 60 */
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.hero-copy {
  max-width: 45rem;
  margin: 2rem 0 0;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1.5;
}

.front-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 4.6rem;
  padding: 3.6rem 0 5.6rem;
  border-top: 1px solid var(--border-color);
}

.featured-stack {
  display: grid;
  gap: 2rem;
  align-self: start;
}

.featured-stack .featured {
  margin-bottom: 0; /* cancel the single-post article margin, which doubles the stack gap */
}

.featured {
  padding: 2.6rem;
  background: var(--surface-color);
  border-top: 4px solid var(--text-color);
}

.featured-stack .featured:nth-child(n + 2) {
  border-top-width: 1px;
  border-top-color: var(--border-color);
}

.featured-stack .featured:nth-child(n + 2) h2 {
  font-size: clamp(1.35rem, 1.2rem + 0.8vw, 1.6rem);
}

.featured h2 {
  margin: 0 0 1.5rem;
  font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem);
  font-weight: 500;
  letter-spacing: -0.015em;
}

.featured h2 a,
.post-row h3 a,
.start-grid h3 a,
.archive-row h3 a {
  color: inherit;
  text-decoration: none;
}

.featured > p:not(.eyebrow) {
  font-size: 1.1rem;
}

.meta {
  display: flex;
  gap: 1.1rem;
  margin-top: 2.1rem;
  color: var(--text-muted);
  font: 0.8rem var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 500;
}

.section-heading > a,
.continue > a {
  color: var(--primary-color);
  font: 0.75rem var(--font-sans);
}

/* Shared list-row rhythm (homepage recent, start-here, archive) */
.post-row,
.start-grid article,
.archive-row {
  display: grid;
  margin-bottom: 0; /* cancel the single-post article margin, which doubles the row gap */
  padding: 1.2rem 0;
  border-top: 1px solid var(--border-color);
}

.post-row {
  grid-template-columns: 1fr auto;
  gap: 0.2rem 1rem;
}

.post-row h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.post-row time {
  color: var(--text-muted);
  font: 0.8rem var(--font-sans);
}

.post-row p {
  grid-column: 1 / -1;
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.48;
}

.start-here {
  display: grid;
  grid-template-columns: minmax(14rem, 0.72fr) minmax(0, 1.55fr);
  gap: 4.5rem;
  padding: 4.8rem 0 5.8rem;
  border-top: 1px solid var(--border-color);
}

.start-intro h2 {
  margin: 0 0 1.1rem;
  font-size: 1.75rem; /* matches .section-heading h2 */
  font-weight: 500;
}

.start-intro > p:last-child,
.start-grid p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.start-grid article {
  grid-template-columns: 2.6rem 1fr;
  gap: 1rem;
}

.start-grid article > span {
  color: var(--text-muted);
  font: 0.8rem var(--font-sans);
  letter-spacing: 0.12em;
}

.start-grid h3 {
  margin: 0 0 0.45rem;
  font-size: 1.25rem;
  font-weight: 500;
}

.start-grid p {
  margin: 0;
}

.motto {
  padding: 3.4rem 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-muted);
}

.motto p {
  margin: 0;
  letter-spacing: 0.15em;
  font-size: 0.9rem;
}

.archive {
  max-width: 58rem;
  margin: auto;
  padding: 2.5rem 0 4rem;
}

.archive > h1 {
  margin: 0;
  font-size: clamp(2.125rem, 1.6rem + 1.6vw, 2.75rem); /* 34 → 44, matches .article-head h1 */
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.archive-intro {
  max-width: 42rem;
  margin: 1.2rem 0 3rem;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.archive-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 4.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  font: 0.8rem var(--font-sans);
  letter-spacing: 0.08em;
}

.archive-nav strong:not(:first-child) {
  margin-left: 1.5rem;
}

.archive-nav a {
  min-width: 2.4rem;
  padding: 0.3rem 0.5rem;
  text-align: center;
  border: 1px solid var(--border-color);
  text-decoration: none;
}

.month {
  display: grid;
  grid-template-columns: 7.8rem 1fr;
  gap: 1.8rem;
  margin-top: 4.5rem;
  scroll-margin-top: 2rem;
}

.month > h2 {
  margin: 0;
  color: var(--text-muted);
  font: 0.85rem var(--font-sans);
  letter-spacing: 0.08em;
}

.archive-row {
  grid-template-columns: 2rem 1fr;
  gap: 0.25rem 1.1rem;
}

.archive-row h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
}

.archive-row time {
  padding-top: 0.25rem;
  color: var(--text-muted);
  font: 0.8rem var(--font-sans);
}

.archive-row p {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

main.prose {
  max-width: 42rem;
  padding: 2.5rem 0 4rem;
}

article > .article-head {
  margin-bottom: 1.6rem;
  padding-bottom: 1.8rem;
  border-bottom: 1px solid var(--border-color);
}

.article-head h1 {
  margin: 0;
  font-size: clamp(2.125rem, 1.6rem + 1.6vw, 2.75rem); /* 34 → 44 */
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.article-head .deck {
  margin: 1.1rem 0 1rem;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1.48;
}

.article-head time {
  display: block;
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.content {
  padding: 2rem 0;
  font-size: clamp(1.08rem, 1rem + 0.25vw, 1.2rem);
  line-height: 1.64;
}

.continue {
  margin-top: 1rem;
  padding: 1.8rem 0;
  border-top: 1px solid var(--border-color);
}

@media (max-width: 760px) {
  .primary-nav {
    align-items: flex-start;
  }
  .hero {
    padding: 2rem 0 2.5rem;
  }
  .hero-logo {
    display: none;
  }
  .motto-logo {
    display: block;
    width: clamp(6rem, 22vw, 8rem);
    height: auto;
    margin: 2rem auto 0;
  }
  .front-grid {
    grid-template-columns: 1fr;
    gap: 3rem;
    padding: 2.6rem 0 3.8rem;
  }
  .featured {
    padding: 1.8rem;
  }
  .start-here {
    grid-template-columns: 1fr;
    gap: 1.8rem;
  }
  .archive {
    padding: 1.5rem 0 3rem;
  }
  .month {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  main.prose {
    padding: 1.5rem 0 3rem;
  }
  article > .article-head {
    padding-bottom: 1.4rem;
  }
  .article-head .deck {
    font-size: 1.08rem;
  }
  .content {
    padding-top: 1.5rem;
  }
}

@media (max-width: 480px) {
  .primary-nav {
    flex-direction: column;
    gap: 0.6rem;
  }
  .nav-links {
    gap: 1rem;
  }
  .post-row {
    grid-template-columns: 1fr;
  }
  .post-row p {
    grid-column: 1;
  }
  .archive-nav strong:not(:first-child) {
    margin-left: 0.5rem;
  }
  .archive-row {
    grid-template-columns: 1.6rem 1fr;
  }
}
