/* ============================================================
   nathanpaine.net

   Concept: annotation. Ruby glosses — the layer Japanese
   typesetting has and Latin doesn't — carry the site's structure
   and the only colour on the page. Everything else stays quiet.

   Hand-written. No build step. Fonts are self-hosted (see fonts.css).
   ============================================================ */

@import url("fonts.css");

:root {
  --paper:  #eef0f3;
  --ink:    #171a21;
  --gloss:  #5b57c8;   /* the only colour — annotation ink */
  --muted:  #646c78;
  --rule:   #d3d8de;

  --display: "Fraunces", Georgia, serif;
  --body:    "IBM Plex Sans JP", system-ui, -apple-system, sans-serif;

  --measure: 62ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101319;
    --ink:   #e9ecf1;
    --gloss: #9d99ff;
    --muted: #8a929e;
    --rule:  #262c35;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---- annotation layer ------------------------------------ */
/* The glosses are the concept. They are never decoration: a
   label is glossed only where a real Japanese reading exists. */

ruby { ruby-position: over; }

rt {
  font-family: var(--body);
  font-weight: 400;
  color: var(--gloss);
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-align: center;
}

/* ---- layout ---------------------------------------------- */

.page {
  max-width: 74ch;
  margin: 0 auto;
  padding: clamp(3rem, 9vmin, 7rem) 6vw clamp(4rem, 12vmin, 9rem);
}

.eyebrow {
  margin: 0 0 2.6rem;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.name {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.6rem, 8.5vw, 5.6rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
}

.name rt { font-size: 0.2em; letter-spacing: 0.12em; }

.rule {
  height: 1px;
  margin: clamp(1.8rem, 4vmin, 3rem) 0 0;
  background: var(--rule);
}

.lead {
  max-width: 40ch;
  margin: clamp(1.6rem, 3.5vmin, 2.4rem) 0 0;
  font-family: var(--display);
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  line-height: 1.32;
}

.prose { max-width: var(--measure); }

.prose p { margin: 1.15em 0 0; line-height: 1.78; color: var(--muted); }

.prose p:first-child { margin-top: clamp(1.4rem, 3vmin, 2rem); }

.prose rt { font-size: 0.68em; }

/* ---- navigation ------------------------------------------ */

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(2rem, 4vw, 3.2rem);
  margin-top: clamp(2.6rem, 6vmin, 4rem);
}

.nav__link {
  position: relative;
  font-size: 1.02rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink);
  padding-bottom: 4px;
}

.nav__link rt { font-size: 0.66em; }

.nav__link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--gloss);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms ease;
}

.nav__link:hover::after,
.nav__link:focus-visible::after { transform: scaleX(1); }

.nav__link:focus-visible {
  outline: 2px solid var(--gloss);
  outline-offset: 6px;
  border-radius: 1px;
}

/* ---- back link (about page) ------------------------------ */

.back {
  display: inline-block;
  margin: 0 0 2.6rem;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
}

.back:hover, .back:focus-visible { color: var(--gloss); }

/* ---- load sequence --------------------------------------- */
/* The base text arrives first, then the annotation is written
   in over it — which is the order it happens on paper. */

@keyframes rise {
  from { opacity: 0; transform: translateY(0.4em); }
  to   { opacity: 1; transform: none; }
}

@keyframes gloss-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.eyebrow, .name, .lead, .prose, .nav {
  animation: rise 620ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

.name  { animation-delay: 70ms; }
.lead  { animation-delay: 340ms; }
.prose { animation-delay: 430ms; }
.nav   { animation-delay: 540ms; }

rt { animation: gloss-in 700ms ease 820ms backwards; }

@media (prefers-reduced-motion: reduce) {
  .eyebrow, .name, .lead, .prose, .nav, rt { animation: none; }
  .nav__link::after { transition: none; }
}

/* ---- section index (classroom, and later builds/notes) --- */

.intro {
  max-width: 52ch;
  margin: clamp(1.4rem, 3vmin, 2rem) 0 0;
  color: var(--muted);
}

.entries {
  margin: clamp(2.4rem, 5vmin, 3.4rem) 0 0;
  padding: 0;
  list-style: none;
}

.entry {
  padding: clamp(1.4rem, 3vmin, 2rem) 0;
  border-top: 1px solid var(--rule);
}

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

.entry__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  line-height: 1.2;
}

.entry__title rt { font-size: 0.4em; }

.entry__meta {
  margin: 0.55rem 0 0;
  font-size: 0.76rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--gloss);
}

.entry__desc {
  max-width: 58ch;
  margin: 0.7rem 0 0;
  line-height: 1.7;
  color: var(--muted);
}

.entries { animation: rise 620ms cubic-bezier(0.22, 0.61, 0.36, 1) 430ms backwards; }

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

/* ---- unit / project pages -------------------------------- */

.meta {
  margin: clamp(1.2rem, 2.6vmin, 1.8rem) 0 0;
  font-size: 0.76rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--gloss);
}

.section {
  margin: clamp(2.2rem, 5vmin, 3.2rem) 0 0;
  max-width: var(--measure);
}

.section__head {
  margin: 0 0 0.2rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.1rem, 2.1vw, 1.35rem);
  line-height: 1.25;
}

.section p {
  margin: 0.7rem 0 0;
  line-height: 1.78;
  color: var(--muted);
}

.section rt { font-size: 0.62em; }

.section { animation: rise 620ms cubic-bezier(0.22, 0.61, 0.36, 1) 430ms backwards; }

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

.entry__title a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}

.entry__title a:hover,
.entry__title a:focus-visible { border-bottom-color: var(--gloss); }

.entry__title a:focus-visible {
  outline: 2px solid var(--gloss);
  outline-offset: 5px;
}

/* ============================================================
   One-page hub (index.html only). New classes throughout so the
   sub-pages, which share this stylesheet, are untouched.
   ============================================================ */

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.hub {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- the margin ------------------------------------------ */

.hub__margin {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 4rem 0 0 6.6vw;
  border-right: 1px solid var(--rule);
}

.hub__site {
  margin: 0 0 15rem;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.hub__nav { display: flex; flex-direction: column; gap: 1.9rem; }

.hub__nav a {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-decoration: none;
  color: var(--ink);
  opacity: 0.55;
  transition: opacity 240ms ease;
}

.hub__nav a::after {
  content: "";
  width: 28px;
  height: 2px;
  margin-top: 0.25rem;
  background: var(--gloss);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms ease;
}

.hub__nav a:hover,
.hub__nav a:focus-visible,
.hub__nav a.is-active { opacity: 1; }

.hub__nav a.is-active::after { transform: scaleX(1); }

.hub__nav a:focus-visible { outline: 2px solid var(--gloss); outline-offset: 6px; border-radius: 1px; }

.hub__gloss { font-size: 0.8rem; letter-spacing: 0.1em; color: var(--gloss); }
.hub__label { font-size: 1rem; }

/* ---- the page -------------------------------------------- */

.hub__main { padding: 0 8.3vw 0 6.6vw; }

.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: clamp(3rem, 10vh, 6rem);
}

/* The name at the size the concept always wanted. 13.6vw is 196px at 1440. */
.hero__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.6rem, 13.6vw, 12.25rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.hero__name rt {
  font-family: var(--body);
  font-size: 0.11em;
  letter-spacing: 0.14em;
  color: var(--gloss);
  line-height: 1.2;
}

.hero__rule { height: 1px; margin-top: clamp(1.6rem, 3vw, 2.75rem); background: var(--gloss); }

.hero__lede {
  margin: clamp(1.4rem, 2.4vw, 2.1rem) 0 0;
  max-width: 34ch;
  font-family: var(--display);
  font-size: clamp(1.3rem, 2.1vw, 1.875rem);
  line-height: 1.3;
}

/* ---- sections -------------------------------------------- */

.hub__section {
  padding: clamp(4rem, 8vw, 7.5rem) 0;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 2rem;
}

.hub__section--last { padding-bottom: clamp(3rem, 6vw, 6rem); }

.hub__h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 3.9vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.hub__h2 rt {
  font-family: var(--body);
  font-size: 0.27em;
  letter-spacing: 0.12em;
  color: var(--gloss);
  line-height: 1.2;
}

.hub__lede {
  margin: 1.6rem 0 0;
  max-width: 52ch;
  font-size: 1.06rem;
  line-height: 1.75;
  color: var(--muted);
}

.hub__grid {
  display: grid;
  /* As many columns as cards fit at >=280px each: two cards get two wide columns,
     a third narrows them to three. Adding a card never needs a CSS change. */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.9rem;
  margin-top: 3rem;
}

.hub__card { display: flex; flex-direction: column; gap: 0.75rem; }
.hub__card h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.375rem; line-height: 1.2; }
.hub__card p  { margin: 0; font-size: 0.94rem; line-height: 1.6; color: var(--muted); }

.hub__more {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gloss);
  text-decoration: none;
}
.hub__more:hover, .hub__more:focus-visible { text-decoration: underline; text-underline-offset: 4px; }
.hub__more--section { display: inline-block; margin-top: 2rem; }

.hub__list { margin: 2.75rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }

.hub__list li {
  display: grid;
  grid-template-columns: 1.1fr 2fr auto;
  gap: 2.5rem;
  align-items: baseline;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.hub__list h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.3rem; line-height: 1.2; }
.hub__list h3 a { color: var(--ink); text-decoration: none; }
.hub__list h3 a:hover { border-bottom: 1px solid var(--gloss); }
.hub__list h3 rt { font-size: 0.5em; letter-spacing: 0.1em; color: var(--gloss); }
.hub__list p { margin: 0; font-size: 0.94rem; line-height: 1.6; color: var(--muted); }

.hub__prose { max-width: 58ch; margin-top: 1.8rem; }
.hub__prose p { margin: 0 0 1.1em; font-size: 1.06rem; line-height: 1.8; }
.hub__prose p:last-child { margin-bottom: 0; color: var(--muted); }
.hub__prose rt { font-size: 0.62em; }

.hub__email {
  display: inline-block;
  margin-top: 1.6rem;
  font-family: var(--display);
  font-size: clamp(1.4rem, 2.4vw, 2.125rem);
  color: var(--ink);
  text-decoration: none;
}
.hub__email:hover { color: var(--gloss); }

.hub__links { display: flex; gap: 2.5rem; margin-top: 1.9rem; font-size: 0.95rem; }
.hub__links a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--gloss); padding-bottom: 3px; }
.hub__links a.hub__top { color: var(--muted); border-bottom-color: var(--rule); }
.hub__links rt { font-size: 0.6em; color: var(--gloss); letter-spacing: 0.08em; }

/* ---- motion ---------------------------------------------- */

/* Arrival: the hero writes itself in on load, as the old page did. */
.hero__name, .hero__lede { animation: rise 620ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards; }
.hero__lede { animation-delay: 320ms; }
.hero__name rt { animation: gloss-in 700ms ease 600ms backwards; }
.hero__rule { transform-origin: left center; animation: rule-in 760ms cubic-bezier(0.22, 0.61, 0.36, 1) 260ms backwards; }
@keyframes rule-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Scroll: each section's gloss writes in as it enters view. Zero JavaScript.
   Browsers without scroll timelines simply show the gloss. */
@supports (animation-timeline: view()) {
  .hub__section .hub__h2 rt {
    animation: gloss-in linear both;
    animation-timeline: view();
    animation-range: entry 15% entry 55%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero__name, .hero__lede, .hero__name rt, .hero__rule, .hub__section .hub__h2 rt { animation: none; }
  .hub__nav a, .hub__nav a::after { transition: none; }
}

/* ---- narrow screens: the margin becomes a sticky strip ---- */

@media (max-width: 899px) {
  .hub { grid-template-columns: 1fr; }

  .hub__margin {
    height: auto;
    padding: 0.9rem 6vw;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
    z-index: 2;
    overflow-x: auto;
  }
  .hub__site { display: none; }
  .hub__nav { flex-direction: row; gap: 1.6rem; }
  .hub__gloss { font-size: 0.7rem; }
  .hub__label { font-size: 0.95rem; }
  .hub__nav a::after { display: none; }
  .hub__nav a.is-active .hub__label { border-bottom: 2px solid var(--gloss); }

  .hub__main { padding: 0 6vw; }
  .hero { min-height: calc(100vh - 3.6rem); }
  .hero__name { font-size: clamp(3.4rem, 17vw, 6rem); }
  .hub__grid { grid-template-columns: 1fr; gap: 2.2rem; }
  .hub__list li { grid-template-columns: 1fr; gap: 0.5rem; }
}

/* Card images: fixed 16:9 slot so cards with and without one still line up.
   Below the fold, so lazy. */
.hub__card figure {
  margin: 0 0 0.35rem;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 2px;
  border: 1px solid var(--rule);
  background: var(--rule);
}
.hub__card img { display: block; width: 100%; height: 100%; object-fit: cover; }
