/* ==========================================================================
   Samuel Mbugua — black & white newspaper theme
   Shared by every page on the site.
   ========================================================================== */

:root {
  --paper: #ffffff;
  --ink: #141414;
  --ink-soft: #3a3a3a;
  --ink-faint: #6e6e6e;
  --rule-thin: 1px solid var(--ink);
  --rule-thick: 3px solid var(--ink);
  --rule-double: 4px double var(--ink);

  --font-headline: "Playfair Display", "Times New Roman", Times, serif;
  --font-body: "Old Standard TT", "Times New Roman", Times, serif;

  --gutter: clamp(1rem, 2.2vw, 3rem);
}

/* --- Base --------------------------------------------------------------- */

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

html {
  /* Type scales with the viewport so wide screens are filled, not padded */
  font-size: clamp(16px, 0.55vw + 9px, 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  font-family: var(--font-body);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

::selection {
  background: var(--ink);
  color: var(--paper);
}

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

ul {
  padding: 0;
  list-style: none;
}

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

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 var(--gutter) var(--gutter);
}

.page > main {
  flex: 1;
}

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

.masthead {
  padding-top: var(--gutter);
  text-align: center;
}

.masthead__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  padding: 0.6rem 0;
  border-top: var(--rule-thick);
  border-bottom: var(--rule-double);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.masthead__nav a + a::before {
  content: "•";
  display: inline-block;
  margin: 0 0.9em;
  font-weight: 400;
  text-decoration: none;
}

.masthead__nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}

@media (max-width: 480px) {
  .masthead__nav {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
  }

  .masthead__nav a + a::before {
    margin: 0 0.5em;
  }
}

/* --- Shared type -------------------------------------------------------- */

/* Section bar used at the head of every column / page section */
.section-head {
  margin-bottom: 1rem;
  padding: 0.3rem 0;
  border-top: var(--rule-thick);
  border-bottom: var(--rule-thin);
  font-family: var(--font-headline);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}

.headline {
  margin-bottom: 0.9rem;
  font-family: var(--font-headline);
  font-size: clamp(2rem, 2.6vw, 4.5rem);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.kicker {
  margin: 1.1rem 0 0.4rem;
  padding-bottom: 0.2rem;
  border-bottom: var(--rule-thin);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.justify {
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

/* Photographs printed in "newsprint": greyscale, punchy contrast, halftone dots */
.photo {
  position: relative;
  border: var(--rule-thin);
  background: var(--ink);
  overflow: hidden;
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%) contrast(1.12) brightness(1.02);
  transition: filter 0.3s ease;
}

.photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(0, 0, 0, 0.28) 0.7px, transparent 1.3px);
  background-size: 3px 3px;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* --- Front page (index.html) ------------------------------------------- */

.front-page {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "lead"
    "experience"
    "updates";
  align-content: start;
  row-gap: 2.25rem;
  padding-top: 1.75rem;
}

.column--lead { grid-area: lead; }
.column--experience { grid-area: experience; }
.column--updates { grid-area: updates; }

.column {
  font-size: 0.95rem;
}

/* Lead story */
.lead-photo {
  aspect-ratio: 4 / 3;
  margin-bottom: 1rem;
}

.lead-photo img {
  object-position: 50% 30%;
}

.column--lead .kicker {
  display: flow-root;
}

.column--lead p + p {
  margin-top: 0.6rem;
}

.interests {
  padding-top: 0.15rem;
  font-style: italic;
}

.column--lead::after {
  content: "";
  display: block;
  clear: both;
}

/* Updates */
.dispatch {
  padding: 0.7rem 0;
  border-bottom: var(--rule-thin);
}

.dispatch:first-of-type {
  padding-top: 0;
}

.dateline {
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.06em;
}

.dateline::after {
  content: " —";
  font-weight: 400;
}

/* Experience */
.ledger li {
  padding: 0.2rem 0 0.2rem 1em;
  text-indent: -1em;
}

.ledger li + li {
  border-top: 1px dotted var(--ink-faint);
}

.school {
  font-family: var(--font-headline);
  font-size: 1.15rem;
  font-weight: 700;
}

.school small {
  font-family: var(--font-body);
  font-size: 0.85em;
  font-weight: 400;
}

.degree {
  display: block;
  font-style: italic;
  color: var(--ink-soft);
}

.column--experience p + p {
  margin-top: 0.6rem;
}

@media (min-width: 700px) {
  .front-page {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "lead lead"
      "updates experience";
    column-gap: 0;
  }

  .column--updates {
    padding-right: var(--gutter);
  }

  .column--experience {
    padding-left: var(--gutter);
    border-left: var(--rule-thin);
  }

  .lead-photo {
    float: left;
    width: 38%;
    aspect-ratio: 5 / 6;
    margin: 0.35rem var(--gutter) 0.5rem 0;
  }

  .column--lead .kicker:first-of-type {
    margin-top: 0;
  }
}

@media (min-width: 1000px) {
  .front-page {
    grid-template-columns: 1fr 1.45fr 1.2fr;
    grid-template-areas: "updates lead experience";
    align-content: stretch;
  }

  .column--lead {
    padding: 0 var(--gutter);
    border-left: var(--rule-thin);
    border-right: var(--rule-thin);
  }

  .column--experience {
    border-left: 0;
  }

  .lead-photo {
    float: none;
    width: auto;
    aspect-ratio: 4 / 3;
    max-height: 50vh;
    margin: 0 0 1rem;
  }

  .column--lead .kicker:first-of-type {
    margin-top: 1.1rem;
  }
}

/* --- Feature page (about/) --------------------------------------------- */

.feature {
  display: flex;
  flex-direction: column;
  padding-top: 1.75rem;
  text-align: center;
}

/* Auto margins on the ticker and lead centre the story vertically on the page */
.ticker {
  align-self: center;
  height: 1.2em;
  margin: auto 0 clamp(1.5rem, 5vh, 3.5rem);
  overflow: hidden;
  font-family: var(--font-headline);
  font-size: clamp(1.6rem, 6.5vw, 8rem);
  font-weight: 900;
  line-height: 1.2;
}

/* --words is set inline to the number of words; each word gets 3s */
.ticker__words {
  animation: ticker-roll calc(var(--words, 4) * 3s) steps(var(--words, 4)) infinite;
}

.ticker__words li {
  white-space: nowrap;
}

.ticker__words span {
  display: inline-block;
  vertical-align: top;
  animation: ticker-type 3s steps(14) infinite;
}

@keyframes ticker-roll {
  to { transform: translateY(-100%); }
}

@keyframes ticker-type {
  0% { clip-path: inset(0 100% 0 0); }
  40%, 75% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 100% 0 0); }
}

.feature__rule {
  height: 0;
  margin: 0;
  border: 0;
  border-top: var(--rule-double);
}

.feature__intro {
  max-width: 62ch;
  margin: clamp(1.5rem, 5vh, 3.5rem) auto auto;
}

.feature__lead {
  font-size: 1.3rem;
  line-height: 1.65;
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.feature__lead + .feature__lead {
  margin-top: 1rem;
}

.feature__intro::after {
  content: "* * *";
  display: block;
  margin-top: 1.75rem;
  font-size: 1.1rem;
  letter-spacing: 0.4em;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .ticker {
    height: auto;
  }

  .ticker__words,
  .ticker__words span {
    animation: none;
  }

  .ticker__words li {
    display: inline;
  }

  .ticker__words li + li::before {
    content: " · ";
  }
}

/* --- Projects page (projects/) ----------------------------------------- */

.projects {
  padding-top: 1.75rem;
}

.story-grid {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 2rem;
}

.story__photo {
  aspect-ratio: 3 / 2;
}

.story__title {
  margin-top: 0.6rem;
  font-family: var(--font-headline);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.story a:hover {
  text-decoration: none;
}

.story a:hover .story__title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.story a:hover .photo img {
  filter: grayscale(100%) contrast(1.3) brightness(0.95);
}

/* Column rules sit in the middle of the gap so every column stays the same width */
.story {
  position: relative;
}

.story::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--gutter) * -1);
  border-left: var(--rule-thin);
  display: none;
}

@media (min-width: 640px) {
  .story-grid {
    grid-template-columns: repeat(2, 1fr);
    column-gap: calc(var(--gutter) * 2);
  }

  .story:nth-child(2n)::before {
    display: block;
  }
}

@media (min-width: 1000px) {
  .story-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .story:nth-child(n)::before {
    display: block;
  }

  .story:nth-child(3n + 1)::before {
    display: none;
  }
}

/* --- Colophon / footer -------------------------------------------------- */

.colophon {
  margin-top: 3rem;
  padding-top: 0.9rem;
  border-top: var(--rule-double);
  text-align: center;
}

.colophon__contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.colophon__contact li + li::before {
  content: "•";
  margin: 0 0.9em;
  font-weight: 400;
}

.colophon__credit {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-faint);
}
