/* ==========================================================================
   Alex Rivera — Personal site
   A minimal, editorial design. One serif display face, one accent, lots of air.
   Tokens live in :root so the whole site can be re-themed from one place.
   ========================================================================== */

:root {
  /* Color — a whisper-off-white canvas, near-black ink, one quiet blue accent */
  --bg:        #FCFCFA;
  --ink:       #17170F;
  --muted:     #6E6E64;
  --line:      #E7E6DE;
  --line-soft: #EFEEE8;
  --accent:    #2E5EAA;
  --accent-ink:#234A87;

  /* Type */
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Layout */
  --container: 68rem;   /* ~1088px */
  --gutter:    clamp(1.25rem, 5vw, 3rem);
  --section-y: clamp(4.5rem, 11vh, 8.5rem);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem; /* keeps anchored sections clear of sticky nav */
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

ul[role="list"] { list-style: none; padding: 0; }

::selection { background: var(--accent); color: #fff; }

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: var(--section-y);
  border-top: 1px solid var(--line);
}

/* Two-column label/content grid used by the About section */
.section__grid {
  display: grid;
  gap: 1.5rem 3rem;
}

@media (min-width: 48rem) {
  .section__grid {
    grid-template-columns: 12rem 1fr;
  }
}

.section__label { margin-bottom: 2.25rem; }

@media (min-width: 48rem) {
  .section__grid .section__label { margin-bottom: 0; }
}

/* --------------------------------------------------------------------------
   Typography helpers
   -------------------------------------------------------------------------- */
.eyebrow {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.prose p + p { margin-top: 1.15rem; }
.prose {
  max-width: 34rem;
  color: #2c2c22;
  font-size: 1.125rem;
  line-height: 1.72;
}

/* --------------------------------------------------------------------------
   Skip link
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 0.4rem;
  font-size: 0.875rem;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 1rem; }

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.nav.is-scrolled { border-bottom-color: var(--line); }

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

.nav__brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 0.01em;
}

.nav__links {
  display: flex;
  gap: 1.85rem;
}

.nav__link {
  font-size: 0.9rem;
  color: var(--muted);
  position: relative;
  transition: color 0.2s var(--ease);
}
.nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.35rem;
  width: 100%;
  height: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.28s var(--ease);
}
.nav__link:hover,
.nav__link.is-active { color: var(--ink); }
.nav__link.is-active::after { transform: scaleX(1); }

/* Mobile menu toggle — hidden on desktop */
.nav__toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.nav__toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.nav.is-open .nav__toggle span:nth-child(1) { transform: translateY(3.25px) rotate(45deg); }
.nav.is-open .nav__toggle span:nth-child(2) { transform: translateY(-3.25px) rotate(-45deg); }

@media (max-width: 40rem) {
  .nav__toggle { display: flex; }
  .nav__links {
    position: absolute;
    top: 4rem;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem var(--gutter) 1.25rem;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  }
  .nav.is-open .nav__links {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .nav__link {
    padding-block: 0.85rem;
    font-size: 1.05rem;
    border-bottom: 1px solid var(--line-soft);
  }
  .nav__link:last-child { border-bottom: none; }
  .nav__link::after { display: none; }
}

/* --------------------------------------------------------------------------
   Hero — the loudest thing on the page, by design
   -------------------------------------------------------------------------- */
.hero {
  padding-block: clamp(4rem, 16vh, 10rem) var(--section-y);
}

.hero .eyebrow { margin-bottom: 1.75rem; }

.hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.75rem, 7.5vw, 6rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  max-width: 20ch;
  text-wrap: balance;
}
.hero__title-em {
  color: var(--accent);
  font-style: italic;
}

.hero__lede {
  margin-top: 2rem;
  max-width: 38rem;
  font-size: 1.2rem;
  line-height: 1.62;
  color: #3a3a30;
}

.hero__meta {
  margin-top: 2.75rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.hero__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--accent-ink);
  font-weight: 500;
}
.hero__cta .arrow { transition: transform 0.25s var(--ease); }
.hero__cta:hover .arrow { transform: translateX(4px); }

/* Availability pill */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3f9d5c;
  box-shadow: 0 0 0 0 rgba(63, 157, 92, 0.5);
}

/* --------------------------------------------------------------------------
   The index — signature element for Selected Work
   Hairline-ruled rows that nudge and reveal an arrow on hover.
   -------------------------------------------------------------------------- */
.index { margin-top: 1rem; }

.index__row { border-top: 1px solid var(--line); }
.index__row:last-child { border-bottom: 1px solid var(--line); }

.index__link {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  align-items: baseline;
  gap: 1.5rem;
  padding-block: 1.9rem;
  transition: padding-left 0.3s var(--ease), background 0.3s var(--ease);
}
.index__link:hover {
  padding-left: 0.85rem;
  background: linear-gradient(90deg, var(--line-soft), transparent 60%);
}

.index__year {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 0.3rem;
}

.index__title {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.35rem);
  line-height: 1.1;
}
.index__desc {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.98rem;
  max-width: 40ch;
}

.index__arrow {
  align-self: center;
  font-size: 1.3rem;
  color: var(--accent-ink);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.index__link:hover .index__arrow,
.index__link:focus-visible .index__arrow {
  opacity: 1;
  transform: translateX(0);
}

@media (max-width: 40rem) {
  .index__link {
    grid-template-columns: 1fr auto;
    gap: 0.5rem 1rem;
    padding-block: 1.5rem;
  }
  .index__year { grid-column: 1; order: 2; padding-top: 0; }
  .index__body { grid-column: 1; order: 1; }
  .index__arrow { grid-row: 1; grid-column: 2; align-self: start; }
}

/* --------------------------------------------------------------------------
   Writing list
   -------------------------------------------------------------------------- */
.notes { margin-top: 1rem; }

.notes__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.25rem;
  border-top: 1px solid var(--line-soft);
  transition: color 0.2s var(--ease);
}
.notes__row:last-child .notes__link { border-bottom: 1px solid var(--line-soft); }

.notes__title {
  font-size: 1.15rem;
  transition: color 0.2s var(--ease);
}
.notes__link:hover .notes__title { color: var(--accent-ink); }

.notes__meta {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Contact
   -------------------------------------------------------------------------- */
.contact__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.08;
  margin-top: 2rem;
  max-width: 16ch;
  text-wrap: balance;
}
.contact__email {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  color: var(--accent-ink);
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
  transition: opacity 0.2s var(--ease);
}
.contact__email:hover { opacity: 0.7; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--line);
  padding-block: 2.5rem;
}
.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}
.footer__time { font-variant-numeric: tabular-nums; }
.footer__social { display: flex; gap: 1.25rem; }
.footer__social a { transition: color 0.2s var(--ease); }
.footer__social a:hover { color: var(--ink); }

/* --------------------------------------------------------------------------
   Focus states (keyboard accessibility)
   -------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   Motion — scroll reveals + subtle pulse. All opt-in via prefers-reduced-motion.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  }
  .js .reveal.is-visible {
    opacity: 1;
    transform: none;
  }

  .status__dot { animation: pulse 2.6s ease-out infinite; }
  @keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(63, 157, 92, 0.5); }
    70%  { box-shadow: 0 0 0 7px rgba(63, 157, 92, 0); }
    100% { box-shadow: 0 0 0 0 rgba(63, 157, 92, 0); }
  }
}
