/* ==========================================================================
   Dailies: stylesheet
   1. Design tokens
   2. Base
   3. Header and footer
   4. Home: masthead and story list
   5. Post page
   6. Forms
   7. States and utilities
   ========================================================================== */

/* 1. Design tokens --------------------------------------------------------
   Every colour and font is a variable, so a dark theme only has to
   redefine these values. */
:root {
  --paper: #f4f1ea;
  --paper-deep: #ebe6da;
  --ink: #171614;
  --ink-soft: #3d3a35;
  --muted: #6a655d;
  --rule: #d6d0c2;
  --accent: #b3311d;

  --font-display: "Instrument Serif", "Times New Roman", serif;
  --font-text: "Source Serif 4", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, sans-serif;

  --gutter: clamp(1rem, 4vw, 3rem);
  --page: 84rem;
  --measure: 38rem;

  color-scheme: light;
}

/* Dark theme. It follows the visitor's system setting, unless they picked
   a theme with the button, which sets data-theme on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141311;
    --paper-deep: #1e1d1a;
    --ink: #ece8df;
    --ink-soft: #c8c3b8;
    --muted: #9b958b;
    --rule: #34322d;
    --accent: #f07a5e;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #141311;
  --paper-deep: #1e1d1a;
  --ink: #ece8df;
  --ink-soft: #c8c3b8;
  --muted: #9b958b;
  --rule: #34322d;
  --accent: #f07a5e;
  color-scheme: dark;
}

/* 2. Base ----------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* A word longer than the line (a long link, or a test like "aaaa…")
     may break anywhere instead of making the page wider than the screen */
  overflow-wrap: anywhere;
}

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

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

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

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p {
  margin: 0;
}

/* Keep the hidden attribute working even on elements styled with display */
[hidden] {
  display: none !important;
}

/* Small uppercase labels: dates, categories, section names */
.label,
.meta {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.9rem;
}

.tag {
  color: var(--accent);
}

.skip-link {
  position: absolute;
  top: -4rem;
  left: var(--gutter);
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 0.875rem;
}

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

/* 3. Header and footer ---------------------------------------------------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.25rem var(--gutter);
}

.brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1;
  text-decoration: none;
}

.byline-link {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
}

.site-nav a {
  text-decoration: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--ink);
}

@media (max-width: 599px) {
  .site-nav {
    gap: 0.9rem;
  }

  /* Icon only on small screens; the button keeps its aria-label */
  .theme-toggle__text {
    display: none;
  }
}

.auth-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-nav:empty {
  display: none;
}

.auth-nav__who {
  color: var(--muted);
}

@media (max-width: 599px) {
  .auth-nav__who {
    display: none;
  }
}

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

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  max-width: var(--page);
  margin: 0 auto;
  padding: 2rem var(--gutter) 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  color: var(--muted);
}

/* 4. Home: masthead and story list ---------------------------------------- */
.masthead {
  display: grid;
  gap: 1.5rem;
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(2rem, 8vw, 6rem) var(--gutter) clamp(2.5rem, 6vw, 4.5rem);
}

.wordmark {
  margin-left: -0.04em;
  font-size: clamp(5.5rem, 24vw, 15rem);
  line-height: 0.8;
  letter-spacing: -0.03em;
}

.masthead__intro {
  max-width: 30ch;
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  line-height: 1.35;
  color: var(--ink-soft);
}

.masthead__note {
  max-width: 44ch;
  margin-top: 1rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.stories {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(3rem, 8vw, 6rem);
}

.stories__bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--ink);
}

/* Search and category filter */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem 2rem;
  padding: 0.5rem 0 1.5rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
}

.filter:hover {
  border-color: var(--ink);
}

.filter[aria-pressed="true"] {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

.filter__count {
  font-size: 0.75rem;
  opacity: 0.65;
}

.search {
  flex: 1 1 14rem;
  max-width: 22rem;
}

.search__input {
  width: 100%;
  padding: 0.55rem 0.1rem;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
}

.search__input::placeholder {
  color: var(--muted);
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 1.25rem;
  padding: 3rem 0 4rem;
}

.empty-state__text {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.1;
}

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

.entry {
  position: relative;
  display: grid;
  gap: 1.25rem;
  padding: 2.5rem 0;
  border-top: 1px solid var(--rule);
}

.story-list > li:first-child .entry {
  border-top: 0;
}

.entry__media {
  justify-self: start;
}

.entry__media img {
  width: auto;
  max-height: 70vh;
}

.entry__title {
  margin: 0.6rem 0 1rem;
  font-size: clamp(2rem, 4.5vw, 3.5rem);
}

.entry__title a {
  text-decoration: none;
}

/* The title link stretches over the whole card, so the image is clickable
   too, while screen readers only hear one link per story. */
.entry__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.entry:hover .entry__title a {
  color: var(--accent);
}

.entry__summary {
  max-width: 34rem;
  color: var(--ink-soft);
}

@media (min-width: 900px) {
  .masthead {
    grid-template-columns: auto 1fr;
    align-items: end;
    column-gap: 4rem;
  }

  .masthead__text {
    justify-self: end;
    padding-bottom: 0.75rem;
  }

  .entry {
    grid-template-columns: 7fr 5fr;
    align-items: center;
    column-gap: clamp(2rem, 5vw, 5rem);
    padding: 4rem 0;
  }

  /* Images keep their own shape, centred in their column */
  .entry__media {
    justify-self: center;
  }

  /* Every other story puts its image on the right */
  .story-list > li:nth-child(even) .entry {
    grid-template-columns: 5fr 7fr;
  }

  .story-list > li:nth-child(even) .entry__media {
    order: 2;
  }

  /* The newest story gets a bigger image and title */
  .entry--lead {
    align-items: end;
    padding-top: 2rem;
  }

  .entry--lead .entry__media img {
    max-height: 82vh;
  }

  .entry--lead .entry__title {
    font-size: clamp(3rem, 5.5vw, 5.5rem);
  }
}

/* 5. Post page ------------------------------------------------------------ */
.post {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(3rem, 8vw, 6rem);
}

.back {
  display: inline-block;
  padding: 0.5rem 0;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.post__header {
  max-width: 62rem;
  padding: clamp(1.5rem, 5vw, 4rem) 0 clamp(1.5rem, 4vw, 3rem);
}

.post__title {
  margin: 1rem 0 1.25rem;
  font-size: clamp(2.75rem, 8vw, 7rem);
  line-height: 0.95;
}

.post__summary {
  max-width: 40rem;
  margin-bottom: 1.25rem;
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-style: italic;
  line-height: 1.45;
  color: var(--ink-soft);
}

.post__summary-label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.post__byline {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--muted);
}

.post__cover {
  margin: 0 0 clamp(2.5rem, 6vw, 4.5rem);
}

.post__cover img {
  width: auto;
  max-height: 85vh;
  margin: 0 auto;
}

.prose {
  max-width: var(--measure);
  margin: 0 auto;
  font-size: clamp(1.125rem, 1.6vw, 1.25rem);
  line-height: 1.7;
}

.prose p + p {
  margin-top: 1.25em;
}

/* The first paragraph works as an intro */
.prose p:first-child {
  font-size: 1.2em;
  line-height: 1.5;
}

.prose .credits {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted);
}

.post-section {
  max-width: var(--measure);
  margin: clamp(3rem, 7vw, 5rem) auto 0;
}

.post-section__label {
  margin-bottom: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ink);
}

.post-section--wide {
  max-width: 60rem;
}

.post-section video {
  width: auto;
  max-height: 80vh;
  margin: 0 auto;
  background: #000;
}

/* Kindred work */
.kindred__card {
  display: grid;
  gap: 1.25rem;
  padding: clamp(1rem, 3vw, 1.75rem);
  background: var(--paper-deep);
}

.kindred__media img {
  width: auto;
  max-height: 60vh;
}

.kindred__placeholder {
  height: 14rem;
  background: var(--rule);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

/* Grey stand-ins for stories while the list loads */
.placeholder {
  background: var(--rule);
  animation: pulse 1.4s ease-in-out infinite;
}

.placeholder--image {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 60vh;
}

.placeholder--line {
  width: 40%;
  height: 0.8rem;
  margin: 0.4rem 0 1rem;
}

.placeholder--title {
  width: 85%;
  height: 2.5rem;
  margin-bottom: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  .kindred__placeholder,
  .placeholder {
    animation: none;
  }
}

.kindred__title {
  margin: 0.6rem 0 0.5rem;
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
}

.kindred__artist {
  font-weight: 600;
}

.kindred__date {
  color: var(--ink-soft);
}

.kindred__link {
  display: inline-block;
  margin-top: 1rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
}

.kindred__status,
.kindred__credit {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--muted);
}

.kindred__message {
  display: grid;
  justify-items: start;
  gap: 0.5rem;
  padding: 1.25rem 0;
}

.kindred__message .link-button {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
}

.kindred__credit {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
}

@media (min-width: 700px) {
  .kindred__card {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
  }

  .kindred__placeholder {
    height: 18rem;
  }
}

.post__admin {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
}

.post__delete {
  color: var(--accent);
}

/* Comments */
.comments__status {
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  color: var(--muted);
}

.comments__status:empty {
  display: none;
}

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

.comment {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}

.comment:first-child {
  padding-top: 0.25rem;
}

.comment__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  color: var(--muted);
}

.comment__name {
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Keep the visitor's line breaks, and wrap very long words */
.comment__body {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.comment-form {
  margin-top: 2.5rem;
}

.comment-form__title {
  font-size: 2rem;
}

.comment-form textarea {
  min-height: 8rem;
}

/* The spam trap: moved off-screen instead of display: none, because some
   bots skip fields that are hidden with CSS display */
.trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.post__end {
  max-width: var(--measure);
  margin: clamp(3rem, 7vw, 5rem) auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

/* 6. Forms ---------------------------------------------------------------- */
.form-page {
  max-width: 30rem;
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(3rem, 8vw, 6rem);
}

.form-page__title {
  margin: clamp(1.5rem, 5vw, 3rem) 0 0.75rem;
  font-size: clamp(3rem, 10vw, 5.5rem);
}

.form-page__intro {
  margin-bottom: 2rem;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  color: var(--muted);
}

.form {
  display: grid;
  gap: 1.25rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* 1rem (16px) text stops iPhones from zooming in on the field */
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--muted);
  border-radius: 2px;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  border-color: var(--ink);
  outline-offset: 1px;
}

.form-page--wide {
  max-width: 46rem;
}

.field textarea {
  min-height: 18rem;
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.6;
  resize: vertical;
}

.field [aria-invalid="true"] {
  border-color: var(--accent);
}

.field-hint {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  color: var(--muted);
}

.field-error {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
}

.field-error:empty {
  display: none;
}

.optional {
  font-weight: 400;
  color: var(--muted);
}

.cover-upload {
  margin-top: 0.25rem;
}

.cover-preview {
  max-height: 16rem;
  width: auto;
  margin-top: 0.5rem;
}

.form-error {
  min-height: 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--accent);
}

.button {
  justify-self: start;
  padding: 0.8rem 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 2px;
  cursor: pointer;
}

.button:hover {
  background: var(--accent);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.link-button {
  padding: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.link-button:hover {
  color: var(--accent);
}

/* 7. States and utilities ------------------------------------------------- */
.status {
  padding: 3rem 0;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  color: var(--muted);
}

.status:empty {
  display: none;
}

.status--error {
  color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
