/* ==========================================================================
   Tokens
   ========================================================================== */

:root {
  /* Colour */
  --paper: #ffffff;       /* page background */
  --ink: #000000;         /* text */
  --ink-soft: #595959;    /* subtitles, dates, footer */
  --rule: #dcdcdc;        /* hairlines between essays */
  --accent: #0095FF;      /* link hover and keyboard focus only */

  /* Type */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Helvetica, Arial, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.5rem;
  --step-3: clamp(2rem, 1.3rem + 3.2vw, 3.5rem);

  /* Layout: full width with side gutters on phones and tablets */
  --content-width: 100%;
  --gutter: 1.25rem;
}

/* Tablet */
@media (min-width: 40rem) {
  :root {
    --gutter: 2.5rem;
  }
}

/* Desktop: content is centred and takes 60% of the screen width */
@media (min-width: 64rem) {
  :root {
    --content-width: 60%;
    --gutter: 0rem;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Shared column: header, main and footer all sit on the same left edge */
.site-header,
main,
.site-footer {
  width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main {
  flex: 1;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
  padding-block: 0.75rem;
  background: var(--paper);
}

/* Search */

.search {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.search-input {
  flex: 0 1 16rem;
  min-width: 0;
  padding: 0.3rem 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}

.search-input[hidden] {
  display: none;
}

.search-input::placeholder {
  color: var(--ink-soft);
  font-style: italic;
}

.search-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 var(--accent);
}

.search-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: -0.6rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.search-toggle:hover {
  color: var(--accent);
}

.search-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* On small screens the open search field takes the row; the name steps aside */
@media (max-width: 30rem) {
  .site-header.is-searching .site-name {
    display: none;
  }

  .site-header.is-searching .search-input {
    flex-basis: 100%;
  }
}

.site-name {
  font-size: var(--step--1);
  font-weight: 700;
  text-decoration: none;
}

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

/* ==========================================================================
   Intro
   ========================================================================== */

.intro {
  padding-top: clamp(3.5rem, 12vh, 7rem);
  padding-bottom: clamp(3rem, 9vh, 5rem);
}

.intro h1 {
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin-bottom: 2rem;
}

.intro p {
  max-width: 32rem;
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--ink);
}

.intro p + p {
  margin-top: 1rem;
  color: var(--ink-soft);
}

/* ==========================================================================
   Section break
   ========================================================================== */

.section-break {
  border: 0;
  height: 1px;
  margin: 0;
  background: var(--ink);
}

/* ==========================================================================
   Essays
   ========================================================================== */

.essays {
  scroll-margin-top: 4.5rem; /* clears the sticky header when scrolled to */
  padding-top: 1.25rem;
  padding-bottom: clamp(4rem, 12vh, 7rem);
}

.essays h2 {
  font-size: var(--step-0);
  font-weight: 400;
  margin-bottom: 1rem;
}

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

.essay {
  padding-block: 1.75rem;
  border-top: 1px solid var(--rule);
}

.essay:last-child {
  border-bottom: 1px solid var(--rule);
}

.essay-title {
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.essay-title a {
  text-decoration: none;
  transition: color 120ms ease;
}

.essay-title a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.essay-subtitle {
  margin-top: 0.4rem;
  color: var(--ink-soft);
}

.essay-meta {
  margin-top: 0.9rem;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.essay-meta .author {
  color: var(--ink);
  font-weight: 600;
}

/* Quiet "Pinned" marker at the end of the name and date line */
.essay-pin {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  margin-left: 0.9em;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.essay-pin svg {
  flex: none;
  transform: rotate(35deg);
}

.notice {
  color: var(--ink-soft);
  font-style: italic;
}

.site-name-essays {
  color: #0095FF; /* bright blue */
}


/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  padding-block: 2rem;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

/* ==========================================================================
   Motion preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}