/* ==========================================================================
   Layout: drafting grid backdrop, section rhythm, section headings,
   scroll reveal and footer
   ========================================================================== */

/* ---------- drafting grid: 12 column lines that draw themselves on load ---------- */
.grid-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.grid-bg .wrap { height: 100%; display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gutter); }
.grid-bg span {
  border-inline: 1px solid var(--line); transform-origin: top;
  animation: grid-draw 1.4s var(--ease) both; animation-delay: calc(var(--i) * 45ms);
}
/* columns repeated outside the container out to the window edges (grid.js) */
.grid-ext { position: absolute; inset: 0; overflow: hidden; }
.grid-ext span { position: absolute; top: 0; bottom: 0; }
@keyframes grid-draw { from { transform: scaleY(0); } }
@media (max-width: 720px) {
  .grid-bg .wrap { grid-template-columns: repeat(4, 1fr); }
  .grid-bg .wrap span:nth-child(n+5) { display: none; }
}

main, header, footer { position: relative; z-index: 1; }

/* ---------- sections ---------- */
section { padding-block: clamp(64px, 10vw, 140px); }
section + section { padding-top: 0; }

.sec-head {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
  padding-bottom: 16px; margin-bottom: clamp(28px, 4.5vw, 56px); position: relative;
}
.sec-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--ink); transform-origin: left; }
.sec-head.in::after { animation: rule-draw 1.2s var(--ease) both; }
@keyframes rule-draw { from { transform: scaleX(0); } }

/* ---------- section titles ----------
   Large condensed display type with a numbered tag in front. The number is a CSS
   counter (not text) so the scroll ruler's section label still reads just the title.
   The hero counts as 01, so the first section is 02, matching the ruler. */
main { counter-reset: sec 1; }
.sec-head h2 {
  counter-increment: sec;
  display: flex; align-items: flex-start; gap: .4em; margin: 0; text-wrap: balance;
  font-family: var(--f-display); font-size: clamp(2rem, 1rem + 3.2vw, 3.6rem); line-height: .95; letter-spacing: -.035em;
  font-variation-settings: "wght" 300, "wdth" 82, "opsz" 96;
  transition: font-variation-settings .6s var(--ease), letter-spacing .6s var(--ease);
}
.sec-head h2::before {
  content: counter(sec, decimal-leading-zero);
  flex: none; margin-top: .3em; padding: 4px 7px; border: 1px solid currentColor; border-radius: 99px;
  font: 500 .6875rem/1 var(--f-mono); letter-spacing: .1em; color: var(--accent);
  transition: background .3s, color .3s;
}
/* hover: the title thickens and tightens, the tag fills */
.sec-head:hover h2 { font-variation-settings: "wght" 560, "wdth" 76, "opsz" 96; letter-spacing: -.045em; }
.sec-head:hover h2::before { background: var(--lime); color: var(--on-accent); border-color: var(--lime); }
/* scroll-in: the title wipes in from the left while it condenses and gains weight.
   Fill is backwards only, so once finished it hands back to the hover transition. */
.sec-head.in h2 { animation: head-in 1.1s var(--ease) .1s backwards; }
@keyframes head-in {
  from { clip-path: inset(-10% 100% -10% 0); font-variation-settings: "wght" 200, "wdth" 100, "opsz" 96; letter-spacing: .02em; }
  to { clip-path: inset(-10% -10% -10% 0); }
}

/* scroll reveal (.reveal.in) lives in components/motion.css */

/* ---------- footer ---------- */
.site-footer .wrap {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  padding-block: 28px calc(28px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); color: var(--ink-soft);
}

/* small details that pick up the accent */
#profile .stack-group .label { color: var(--accent); }
.record .yrs { color: var(--accent); }
