/* Base: reset, typography, container, buttons, forms. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--f-sans);
  font-size: var(--fs-body);
  line-height: 1.65;
  color: var(--c-body);
  background: var(--c-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.is-locked {
  overflow: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}

a:hover {
  color: var(--c-accent);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sp-4);
  font-family: var(--f-serif);
  font-weight: 700;
  line-height: 1.18;
  color: var(--c-ink);
  letter-spacing: -0.01em;
}

/* Main headlines use the high-contrast display serif, matching the reference —
   a lighter weight keeps the elegant, thin-stroke feel of the original. */
h1 {
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: -0.005em;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }

p {
  margin: 0 0 var(--sp-4);
}

hr {
  border: 0;
  border-top: 1px solid var(--c-rule);
  margin: var(--sp-7) 0;
}

/* Keyboard focus must stay visible everywhere. */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 999;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-ink);
  color: #fff;
  font-weight: 700;
}

.skip-link:focus {
  left: var(--sp-4);
  top: var(--sp-4);
  color: #fff;
}

/* Layout ------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--container-pad);
}

.site-main {
  min-height: 60vh;
}

/* The feed/sidebar split used by home, category, author, tag and search. */
.layout-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  gap: var(--sp-8);
  align-items: start;
  padding: var(--sp-8) 0 var(--sp-9);
}

@media (max-width: 991px) {
  .layout-split {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-7);
    padding: var(--sp-6) 0 var(--sp-8);
  }
}

/* Section heading with the rule used above every feed block. */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--c-ink);
}

.section-head h2 {
  margin: 0;
  font-family: var(--f-sans);
  font-size: var(--fs-h4);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-head .section-more {
  font-size: var(--fs-meta);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-accent);
  white-space: nowrap;
}

/* Buttons ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 2px;
  font-family: var(--f-sans);
  font-size: var(--fs-small);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}

.btn-primary {
  background: var(--c-accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--c-accent-dark);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border-color: var(--c-ink);
  color: var(--c-ink);
}

.btn-outline:hover:not(:disabled) {
  background: var(--c-ink);
  color: #fff;
}

.btn-block {
  width: 100%;
}

.btn:disabled,
.btn.is-busy {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Inline spinner shown while an async form is in flight. */
.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.btn.is-busy .spinner {
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Forms -------------------------------------------------------------------- */

.field {
  margin-bottom: var(--sp-5);
}

.field label {
  display: block;
  margin-bottom: var(--sp-2);
  font-size: var(--fs-meta);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-ink);
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-rule);
  border-radius: 2px;
  background: var(--c-surface);
  font-family: var(--f-sans);
  font-size: var(--fs-body);
  color: var(--c-body);
  transition: border-color var(--t-fast) var(--ease);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--c-ink);
  outline: none;
}

.textarea {
  min-height: 160px;
  resize: vertical;
}

/* Invalid state is driven by the JS validator, not :invalid, so errors only
   appear after a field has been touched or the form submitted. */
.field.has-error .input,
.field.has-error .textarea,
.field.has-error .select {
  border-color: var(--c-accent);
  background: var(--c-accent-tint);
}

.field-error {
  display: none;
  margin-top: var(--sp-2);
  font-size: var(--fs-small);
  color: var(--c-accent);
  font-weight: 600;
}

.field.has-error .field-error {
  display: block;
}

/* Alerts ------------------------------------------------------------------- */

.alert {
  padding: var(--sp-4);
  border-radius: 2px;
  border-left: 3px solid;
  font-size: var(--fs-small);
  margin-bottom: var(--sp-5);
}

.alert-success {
  background: #f1f7f2;
  border-color: #3c763d;
  color: #2f5d31;
}

.alert-error {
  background: var(--c-accent-tint);
  border-color: var(--c-accent);
  color: var(--c-accent-dark);
}

.alert-info {
  background: var(--c-surface-sunk);
  border-color: var(--c-faint);
  color: var(--c-body);
}

/* Utilities ---------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.is-hidden {
  display: none !important;
}

/* Content is always visible (matching the reference, which does not fade content in).
   The .reveal class is kept only as a hook; it never hides content, so a feed or grid
   can never be left blank if the scroll observer does not fire. */
.reveal {
  opacity: 1;
  transform: none;
}

/* Newsletter form ---------------------------------------------------------- */

.newsletter-row {
  display: flex;
  gap: var(--sp-2);
}

.newsletter-row .input {
  flex: 1;
  /* Allow the field to shrink below its content width so the button never
     overflows a narrow container such as the sidebar panel. */
  min-width: 0;
}

.newsletter-row .btn {
  flex-shrink: 0;
}

.newsletter-note {
  margin: var(--sp-3) 0 0;
  padding: 10px var(--sp-3);
  border-radius: 2px;
  border-left: 3px solid;
  font-size: var(--fs-small);
  font-weight: 600;
}

/* On the dark footer/sidebar the default alert colours have too little contrast. */
.footer-newsletter .newsletter-note.alert-success,
.widget-newsletter .newsletter-note.alert-success,
.inline-newsletter .newsletter-note.alert-success,
.home-newsletter .newsletter-note.alert-success,
.side-subscribe .newsletter-note.alert-success {
  background: rgba(94, 168, 100, 0.14);
  border-color: #6fbf74;
  color: #a6dfaa;
}

.footer-newsletter .newsletter-note.alert-info,
.widget-newsletter .newsletter-note.alert-info,
.inline-newsletter .newsletter-note.alert-info,
.home-newsletter .newsletter-note.alert-info,
.side-subscribe .newsletter-note.alert-info {
  background: rgba(255, 255, 255, 0.08);
  border-color: #9a9a9a;
  color: #d5d5d5;
}

.footer-newsletter .newsletter-note.alert-error,
.widget-newsletter .newsletter-note.alert-error,
.inline-newsletter .newsletter-note.alert-error,
.home-newsletter .newsletter-note.alert-error,
.side-subscribe .newsletter-note.alert-error {
  background: rgba(184, 11, 48, 0.16);
  border-color: var(--c-accent);
  color: #f2a8b6;
}

@media (max-width: 600px) {
  .newsletter-row {
    flex-direction: column;
    min-width: 0;
  }
}

/* Empty / error states ----------------------------------------------------- */

.empty-state {
  padding: var(--sp-9) var(--sp-5);
  text-align: center;
  border: 1px dashed var(--c-rule);
  border-radius: 3px;
  background: var(--c-surface-alt);
}

.empty-state h2 {
  margin-bottom: var(--sp-2);
}

.empty-state p {
  color: var(--c-muted);
  margin: 0 auto var(--sp-5);
  max-width: 46ch;
}
