/* ==========================================================================
   zacharyrubin.com
   Warm editorial system — paper ground, ink type, one clay accent.
   ========================================================================== */

:root {
  /* Surfaces — one warm family, no cool/warm mixing */
  --paper:      #fbf9f6;
  --paper-sunk: #f4f0ea;
  --paper-card: #fffdfb;

  /* Ink — warm near-black, never pure #000 */
  --ink:        #1c1917;
  --ink-2:      #44403c;
  --muted:      #7d746c;

  --line:       #e6ded3;
  --line-soft:  #efe9e0;

  /* Single accent: desaturated clay (h21 s64% l37%) */
  --accent:      #9c4a22;
  --accent-deep: #7d3a19;
  --accent-wash: #f5eae2;

  /* Shadows tinted with the paper hue, never neutral black */
  --shadow-sm: 0 1px 2px rgba(60, 42, 28, .05);
  --shadow-md: 0 2px 6px rgba(60, 42, 28, .06), 0 12px 28px rgba(60, 42, 28, .05);

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --wrap: 1180px;
  --gutter: clamp(20px, 5vw, 56px);

  /* z-scale — no magic 9999 */
  --z-grain: 1;
  --z-nav: 100;
  --z-skip: 200;
}

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

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.62;
  color: var(--ink-2);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Grain — breaks digital flatness. Fixed, inert. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: .038;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------- Typography */

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.08;
  letter-spacing: -.018em;
  margin: 0 0 .44em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.6rem, 6.2vw, 4.6rem); letter-spacing: -.03em; }
h2 { font-size: clamp(1.85rem, 3.6vw, 2.7rem); letter-spacing: -.024em; }
h3 { font-size: 1.24rem; line-height: 1.25; letter-spacing: -.012em; }

p { margin: 0 0 1.05rem; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

.lede {
  font-size: clamp(1.08rem, 1.7vw, 1.26rem);
  line-height: 1.58;
  color: var(--ink-2);
  max-width: 60ch;
}

.measure { max-width: 65ch; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-deep); }

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

/* Small caps label — used sparingly, never as a whole section of headers */
.label {
  font-family: var(--sans);
  font-size: .715rem;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
}

.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ Skeleton */

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

/* Optical rhythm: bottom padding runs slightly heavier than top */
.section { padding-block: clamp(64px, 9vw, 108px) clamp(76px, 10.5vw, 126px); }
.section--sunk { background: var(--paper-sunk); }
.section--tight { padding-block: clamp(48px, 6vw, 72px) clamp(56px, 7vw, 84px); }

.section__head { margin-bottom: clamp(36px, 5vw, 58px); max-width: 62ch; }
.section__head .label { display: block; margin-bottom: 14px; }
.section__head p { color: var(--muted); margin-bottom: 0; }

.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* -------------------------------------------------------------- Skip / focus */

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: var(--z-skip);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 18px;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  transition: top .18s ease;
}
.skip:focus { top: 12px; color: var(--paper); }

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

/* ---------------------------------------------------------------- Navigation */

.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: rgba(251, 249, 246, .82);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.nav__inner {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav__brand {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
}
.nav__brand::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
  transform: translateY(-2px);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
.nav__brand:hover { color: var(--ink); }
.nav__brand:hover::before { transform: translateY(-2px) rotate(45deg); }

.nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__links a {
  display: block;
  padding: 8px 14px;
  font-size: .93rem;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: 6px;
  transition: color .18s ease, background .18s ease;
}
.nav__links a:hover { color: var(--ink); background: var(--paper-sunk); }

/* Current page marker — a rule, not a colour swap */
.nav__links a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  background: transparent;
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 0;
}

.nav__toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  color: var(--ink);
  align-items: center;
  justify-content: center;
  transition: background .18s ease;
}
.nav__toggle:hover { background: var(--paper-sunk); }
.nav__toggle svg { width: 17px; height: 17px; }
.nav__toggle .icon-close { display: none; }
.nav__toggle[aria-expanded="true"] .icon-open { display: none; }
.nav__toggle[aria-expanded="true"] .icon-close { display: block; }

/* -------------------------------------------------------------------- Button */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 24px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-family: var(--sans);
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease,
              transform .12s ease, box-shadow .2s ease, color .2s ease;
}
.btn:active { transform: translateY(1px); }

.btn--solid {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-sm);
}
.btn--solid:hover {
  background: var(--accent-deep);
  color: var(--paper);
  box-shadow: 0 4px 14px rgba(124, 58, 25, .22);
}

.btn--line {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn--line:hover { border-color: var(--ink); color: var(--ink); background: transparent; }

/* Tertiary — reduces the two-button visual noise */
.btn--text {
  padding: 13px 4px;
  color: var(--accent);
  background: none;
}
.btn--text:hover { color: var(--accent-deep); }
.btn--text .arrow { transition: transform .22s cubic-bezier(.34, 1.4, .64, 1); }
.btn--text:hover .arrow { transform: translateX(4px); }

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

.hero {
  padding-block: clamp(60px, 9vw, 116px) clamp(48px, 6vw, 78px);
  position: relative;
  overflow: hidden;
}

/* Off-centre radial wash — asymmetric, not a 45° linear gradient */
.hero::before {
  content: "";
  position: absolute;
  top: -30%;
  right: -12%;
  width: min(760px, 78vw);
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 50%, var(--accent-wash) 0%, rgba(245, 234, 226, 0) 66%);
  pointer-events: none;
}

.hero__grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: clamp(36px, 6vw, 84px);
  align-items: end;
}

.hero h1 { margin-bottom: .34em; }
.hero h1 em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}

.hero .label { display: block; margin-bottom: 20px; }

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 30px;
}

/* At-a-glance definition list — the asymmetric counterweight */
.glance {
  margin: 0;
  padding: 26px 0 4px;
  border-top: 2px solid var(--ink);
}
.glance div + div { margin-top: 17px; padding-top: 17px; border-top: 1px solid var(--line); }
.glance dt {
  font-size: .705rem;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.glance dd { margin: 0; font-size: .97rem; color: var(--ink); line-height: 1.45; }

/* -------------------------------------------------------------------- Facts */

.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.facts > div {
  padding: 26px 30px 28px;
  border-left: 1px solid var(--line-soft);
}
.facts > div:first-child { border-left: 0; padding-left: 0; }

.facts b {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3vw, 2.15rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--ink);
}
.facts span {
  display: block;
  margin-top: 8px;
  font-size: .845rem;
  line-height: 1.4;
  color: var(--muted);
}

/* ------------------------------------------------- Numbered editorial rows */
/* Replaces the three-equal-cards pattern.                                    */

.rows { border-top: 1px solid var(--line); }

.rows > li {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) minmax(0, 1.5fr);
  gap: clamp(20px, 4vw, 52px);
  padding-block: clamp(28px, 3.6vw, 42px);
  border-bottom: 1px solid var(--line);
  align-items: start;
}

.rows__n {
  font-family: var(--display);
  font-size: .96rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  padding-top: .34em;
}

.rows h3 { margin-bottom: 0; }
.rows p { color: var(--ink-2); margin-bottom: 0; font-size: .985rem; }

/* -------------------------------------------------------- Ledger / index list */
/* Ventures as a record, not a card grid.                                       */

.ledger { border-top: 2px solid var(--ink); }

.ledger > li { border-bottom: 1px solid var(--line); }

.ledger__row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1.05fr) minmax(0, 1.45fr);
  gap: clamp(18px, 3.5vw, 44px);
  padding: clamp(24px, 3.2vw, 34px) 14px clamp(26px, 3.4vw, 36px);
  margin-inline: -14px;
  border-radius: 8px;
  align-items: baseline;
  transition: background .22s ease;
}
.ledger > li:hover .ledger__row { background: var(--paper-card); }

.ledger__when {
  font-size: .845rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  letter-spacing: .01em;
}

.ledger__what h3 { margin-bottom: 5px; }

.ledger__kind {
  display: block;
  font-size: .81rem;
  color: var(--accent);
  letter-spacing: .02em;
}

.ledger__note { font-size: .985rem; color: var(--ink-2); }

/* ------------------------------------------------------------------ Timeline */
/* Year lives in a gutter column — no dot-and-line decoration.                  */

.record { border-top: 1px solid var(--line); }

.record > li {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  gap: clamp(20px, 4vw, 48px);
  padding-block: clamp(30px, 4vw, 46px);
  border-bottom: 1px solid var(--line);
}

.record__when {
  font-size: .845rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  line-height: 1.5;
  padding-top: .3em;
}
.record__when b {
  display: block;
  font-weight: 600;
  color: var(--ink);
  font-size: .88rem;
  margin-bottom: 2px;
}

.record__body h3 { margin-bottom: 3px; }

.record__org {
  display: block;
  font-size: .93rem;
  color: var(--accent);
  margin-bottom: 15px;
}

.record__body ul { margin: 0; padding: 0; list-style: none; }
.record__body li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 9px;
  font-size: .975rem;
}
.record__body li:last-child { margin-bottom: 0; }
.record__body li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .66em;
  width: 9px;
  height: 1px;
  background: var(--muted);
}

/* -------------------------------------------------------------------- Notes */

.notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 268px), 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.notes > div {
  background: var(--paper);
  padding: 28px 26px 30px;
  transition: background .22s ease;
}
.notes > div:hover { background: var(--paper-card); }
.notes h3 { font-size: 1.06rem; margin-bottom: 7px; }
.notes p { font-size: .945rem; color: var(--muted); margin-bottom: 0; }

/* ------------------------------------------------------------------- Skills */

.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(28px, 4vw, 52px);
}
.cols h3 { font-size: 1.02rem; margin-bottom: 15px; }

.tags { display: flex; flex-wrap: wrap; gap: 7px; list-style: none; margin: 0; padding: 0; }
.tags li {
  font-size: .855rem;
  color: var(--ink-2);
  background: var(--paper-card);
  border: 1px solid var(--line);
  padding: 6px 13px;
  border-radius: 5px;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
  gap: clamp(38px, 6vw, 82px);
  align-items: start;
}

.reach { list-style: none; margin: 0 0 26px; padding: 0; }
.reach li { padding-block: 15px; border-bottom: 1px solid var(--line); }
.reach li:first-child { padding-top: 0; }
.reach .label { display: block; margin-bottom: 4px; }
.reach a, .reach span { font-size: 1.03rem; color: var(--ink); text-decoration: none; }
.reach a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Form sits on a raised surface, no heavy border */
.form {
  background: var(--paper-card);
  border-radius: 12px;
  padding: clamp(26px, 3.6vw, 38px);
  box-shadow: var(--shadow-md);
}

.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: .97rem;
  color: var(--ink);
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field textarea { resize: vertical; min-height: 138px; line-height: 1.55; }

.field input:hover, .field select:hover, .field textarea:hover { border-color: #d9cfc1; }

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  background: var(--paper-card);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(156, 74, 34, .13);
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%237d746c' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 40px;
}

/* Inline validation — never window.alert */
.field__error {
  display: none;
  margin-top: 7px;
  font-size: .845rem;
  color: #9a3324;
}
.field.is-invalid .field__error { display: block; }
.field.is-invalid input,
.field.is-invalid textarea {
  border-color: #c0553f;
  background: #fdf6f4;
}

.form .btn { width: 100%; }

.form__note {
  margin: 15px 0 0;
  font-size: .845rem;
  color: var(--muted);
  text-align: center;
}

.form__status {
  display: none;
  margin: 0 0 18px;
  padding: 13px 15px;
  border-radius: 7px;
  font-size: .92rem;
  line-height: 1.5;
}
.form__status.is-shown { display: block; }
.form__status[data-tone="ok"]  { background: #edf3ed; color: #2f5136; }
.form__status[data-tone="bad"] { background: #fbefec; color: #8f3826; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* -------------------------------------------------------------------- Close */

.close { padding-block: clamp(64px, 8vw, 100px) clamp(72px, 9vw, 112px); }
.close__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(26px, 5vw, 64px);
  align-items: end;
  padding-top: clamp(38px, 5vw, 56px);
  border-top: 2px solid var(--ink);
}
.close h2 { margin-bottom: .3em; }
.close p { color: var(--muted); max-width: 46ch; margin-bottom: 0; }
.close__actions { display: flex; flex-wrap: wrap; gap: 12px; }

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

.footer {
  border-top: 1px solid var(--line);
  padding-block: 34px 40px;
  font-size: .9rem;
  color: var(--muted);
}
.footer__inner {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  flex-wrap: wrap;
  gap: 14px 30px;
  align-items: center;
  justify-content: space-between;
}
.footer nav { display: flex; flex-wrap: wrap; gap: 22px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

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

.lost { padding-block: clamp(84px, 13vw, 168px); }
.lost__code {
  font-family: var(--display);
  font-size: clamp(4rem, 13vw, 8rem);
  font-weight: 600;
  line-height: .9;
  letter-spacing: -.045em;
  color: var(--accent);
  margin-bottom: 22px;
}
.lost__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

/* ------------------------------------------------------------------- Motion */
/* transform + opacity only — GPU friendly, staggered by inline delay.        */

.rise {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .68s cubic-bezier(.22, .61, .36, 1),
              transform .68s cubic-bezier(.22, .61, .36, 1);
  will-change: opacity, transform;
}
.rise.is-in { opacity: 1; transform: none; }

/* --------------------------------------------------------------- Responsive */

@media (max-width: 1000px) {
  .hero__grid { grid-template-columns: 1fr; align-items: start; gap: 40px; }
  .glance { max-width: 460px; }
  .split { grid-template-columns: 1fr; }
  .close__inner { grid-template-columns: 1fr; align-items: start; }
}

@media (max-width: 860px) {
  .facts { grid-template-columns: repeat(2, 1fr); }
  .facts > div { padding: 22px 22px 24px; }
  .facts > div:nth-child(3) { border-left: 0; padding-left: 0; }
  .facts > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .rows > li { grid-template-columns: 42px minmax(0, 1fr); }
  .rows__n { padding-top: .28em; }
  .rows p { grid-column: 2; }
  .ledger__row { grid-template-columns: 1fr; gap: 10px; }
  .ledger__when { order: -1; }
  .record > li { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 680px) {
  body { font-size: 16px; }

  .nav__toggle { display: inline-flex; }

  .nav__links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-md);
  }
  .nav__links.is-open { display: flex; }
  .nav__links a { padding: 13px 14px; }
  .nav__links a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--accent); }

  .hero__actions .btn:not(.btn--text) { flex: 1 1 auto; }
  .footer__inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 420px) {
  .facts { grid-template-columns: 1fr; }
  .facts > div { border-left: 0; padding-inline: 0; }
  .facts > div + div { border-top: 1px solid var(--line-soft); }
}

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

@media print {
  .nav, .close, .form, body::after { display: none; }
  body { background: #fff; color: #000; }
}
