/* ==========================================================================
   Hamish Adourian — personal site
   Typography, composition and whitespace do the work. Keep it that way.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */

:root {
  /* Colour */
  --paper:        #faf7f1;  /* warm off-white */
  --paper-sunk:   #f4f0e8;  /* barely-there panel */
  --ink:          #16140f;  /* near-black */
  --ink-muted:    #57524a;
  --ink-faint:    #8b8478;
  --rule:         #dcd5c8;
  --accent:       #8d3b25;  /* one restrained accent: oxide red */

  /* Type */
  --serif: "Iowan Old Style", "Sitka Display", "Palatino Linotype", Palatino,
           "Book Antiqua", Constantia, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI",
          "Helvetica Neue", Arial, system-ui, sans-serif;

  /* Measure & rhythm */
  --measure: 34em;
  --gutter: clamp(1.5rem, 5.5vw, 5rem);
  --shell: 72rem;
  --section-space: clamp(4rem, 9vw, 8rem);

  color-scheme: light;
}

/* --- Reset ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1.0625rem, 0.99rem + 0.34vw, 1.1875rem);
  line-height: 1.65;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }

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

p { margin: 0 0 1.25em; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }

/* --- Links ---------------------------------------------------------------- */

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--rule);
  transition: text-decoration-color 180ms ease, color 180ms ease;
}

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

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

/* --- Utilities ------------------------------------------------------------ */

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  transition: top 160ms ease;
}
.skip-link:focus { top: 1rem; color: var(--paper); }

/* --- Masthead ------------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 250ms ease;
}
.masthead.is-stuck { border-bottom-color: var(--rule); }

/* On phones the five links wrap to two rows; don't pin that much header. */
@media (max-width: 39.99rem) {
  .masthead { position: static; }
  html { scroll-padding-top: 1.5rem; }
}

.masthead__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 2rem;
  padding-block: clamp(1.1rem, 2.4vw, 1.6rem);
}

.masthead__name {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
}
.masthead__name:hover { color: var(--accent); }

.masthead__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.75rem;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.masthead__nav a { text-decoration-color: transparent; }
.masthead__nav a:hover { text-decoration-color: var(--accent); }

/* --- Hero ----------------------------------------------------------------- */

.hero {
  padding-block: clamp(3.5rem, 9vw, 7.5rem) var(--section-space);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(2.25rem, 5vw, 3.5rem);
}

.hero__title {
  font-size: clamp(2.75rem, 1.35rem + 6.1vw, 6rem);
  line-height: 1.02;
  letter-spacing: -0.022em;
  margin: 0;
}

/* Below tablet the forced break strands the ampersand; let it wrap naturally. */
@media (max-width: 47.99rem) {
  .hero__br { display: none; }
}

.hero__intro {
  font-size: clamp(1.1875rem, 1.06rem + 0.6vw, 1.4375rem);
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 28em;
}

/* A small portrait sits beside the introduction, like a byline photograph. */
.hero__portrait { width: clamp(5.5rem, 4rem + 5vw, 8.5rem); }

.hero__portrait img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: 50% 35%;
  background: var(--paper-sunk);
}

@media (min-width: 30rem) {
  .hero__grid {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "title    title"
      "portrait intro";
    column-gap: clamp(1.25rem, 3vw, 2.25rem);
    align-items: center;
  }
  .hero__title    { grid-area: title; }
  .hero__portrait { grid-area: portrait; }
  .hero__intro    { grid-area: intro; }
}

/* --- About ---------------------------------------------------------------- */

.about {
  padding-bottom: var(--section-space);
}

.about__body {
  max-width: var(--measure);
  color: var(--ink-muted);
}

@media (min-width: 62rem) {
  /* Align the passage with the numbered sections' text column. */
  .about__body { margin-left: calc(14rem + clamp(2rem, 5vw, 4.5rem)); }
}

/* --- Numbered entries ----------------------------------------------------- */

.entry {
  border-top: 1px solid var(--rule);
  padding-block: var(--section-space);
}

.entry__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 2.5rem) clamp(2rem, 5vw, 4.5rem);
}

.entry__label {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.entry__number {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.entry__heading {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.4;
}

@media (min-width: 62rem) {
  .entry__grid { grid-template-columns: 14rem minmax(0, 1fr); }
  .entry__label {
    position: sticky;
    top: 7rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    align-self: start;
  }
}

/* --- Entry typography ----------------------------------------------------- */

.lede {
  font-family: var(--serif);
  font-size: clamp(1.375rem, 1.12rem + 1.1vw, 1.875rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 1.4em;
  max-width: 24em;
}

.about .lede { color: var(--ink); }

.entry__body p:not(.lede):not(.pull):not(.note) { color: var(--ink-muted); }

.pull {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 1.25rem + 2.2vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.018em;
  max-width: 14em;
  text-wrap: balance;
  margin-bottom: clamp(2.5rem, 5vw, 3.5rem);
}

.note {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  padding-left: 1.25rem;
  border-left: 2px solid var(--rule);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-faint);
  max-width: 30em;
}

/* --- Work items (book, projects) ------------------------------------------ */

.work-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2.25rem);
  padding-block: clamp(1.75rem, 3.5vw, 2.5rem);
  border-top: 1px solid var(--rule);
}
.work-item:first-of-type { border-top: 0; padding-top: 0; }

.work-item__title {
  font-size: clamp(1.25rem, 1.12rem + 0.6vw, 1.5rem);
  letter-spacing: -0.008em;
  margin-bottom: 0.65rem;
}

.work-item__cover {
  max-width: 13rem;
  overflow: hidden;
  background: var(--paper-sunk);
}
.work-item__cover a { display: block; }
.work-item__cover img {
  width: 100%;
  transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}
.work-item__cover:hover img { transform: scale(1.02); }

@media (min-width: 40rem) {
  .work-item:not(.work-item--plain) {
    grid-template-columns: 13rem minmax(0, 1fr);
    align-items: start;
  }
  .work-item__cover { max-width: none; }
}

/* --- Arrow links ---------------------------------------------------------- */

.arrow-link-row { margin-top: 1.5rem; margin-bottom: 0; }

.arrow-link-row--pair {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.75rem;
}

.arrow-link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5em;
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration-color: var(--rule);
}
.arrow-link .arrow {
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.arrow-link:hover .arrow { transform: translateX(0.28em); }

/* --- Contact form ------------------------------------------------------- */

.contact-form {
  display: grid;
  gap: 1.75rem;
  max-width: 30rem;
  margin-top: 0.5rem;
}

.field { margin: 0; padding: 0; border: 0; min-width: 0; }

.field > label,
.field > legend {
  display: block;
  padding: 0;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.field__optional {
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--ink-faint);
}

.field input[type="text"] {
  display: block;
  width: 100%;
  padding: 0.55rem 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  transition: border-color 180ms ease;
}
.field input[type="text"]:hover { border-bottom-color: var(--ink-faint); }
.field input[type="text"]:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}
.field input[aria-invalid="true"] { border-bottom-color: var(--accent); }

.field__error {
  margin: 0.45rem 0 0;
  font-size: 0.875rem;
  color: var(--accent);
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 2rem;
  padding-top: 0.35rem;
}
.choices label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}
.choices input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
}

.contact-form__trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.contact-form__actions { padding-top: 0.5rem; }

.contact-form button {
  padding: 0.9rem 1.75rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease;
}
.contact-form button:hover { background: var(--accent); border-color: var(--accent); }
.contact-form button:disabled { opacity: 0.55; cursor: progress; }

.contact-form__status { margin: 0; min-height: 1.5em; font-size: 0.9375rem; color: var(--ink-muted); }
.contact-form__status.is-error { color: var(--accent); }

.contact-thanks {
  font-family: var(--serif);
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  line-height: 1.4;
}

/* --- Footer --------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--rule);
  padding-block: clamp(3rem, 6vw, 4.5rem);
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  font-size: 0.9375rem;
  margin-bottom: clamp(2rem, 4vw, 3rem);
}
.footer__links a { text-decoration-color: transparent; }
.footer__links a:hover { text-decoration-color: var(--accent); }

.footer__colophon {
  margin: 0;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* --- Reveal on scroll (progressive enhancement) --------------------------- */

.js .reveal {
  opacity: 0;
  transform: translateY(12px);
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity 700ms ease, transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Print ---------------------------------------------------------------- */

@media print {
  :root { --paper: #fff; --ink: #000; --ink-muted: #222; --rule: #bbb; }
  body { font-family: var(--serif); font-size: 11pt; line-height: 1.45; background: #fff; }
  .masthead, .skip-link, .hero__portrait, #contact { display: none; }
  .js .reveal { opacity: 1; transform: none; }
  .hero { padding-top: 0; }
  .entry, .footer { break-inside: avoid; }
  .entry__grid, .hero__grid, .work-item { display: block; }
  .entry__label { position: static; }
  a { text-decoration: none; }
  .entry__body a[href^="http"]::after,
  .footer__links a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    word-break: break-all;
  }
  .arrow-link .arrow { display: none; }
}
