/* ==========================================================================
   Joseph Edward portfolio
   Hand-authored. Light editorial: paper ground, large type, hairline rules.
   ========================================================================== */

/* --- tokens ------------------------------------------------------------- */

:root {
  /* Light is the base palette. Dark redefines only these, twice, below. */
  --paper:        #faf9f7;
  --paper-raised: #ffffff;
  --paper-sunk:   #f2f0ea;
  --ink:          #16150f;
  --ink-soft:     #55524a;
  --ink-faint:    #8a8578;
  --rule:         #e2ded3;
  --rule-strong:  #c9c4b6;
  --accent:       #b4441f;
  --accent-soft:  #f0ded5;

  /* The code card is dark in both themes; it's the one dark object. */
  --code-bg:      #17161a;
  --code-chrome:  #201f24;
  --code-ink:     #d8d4cc;
  --code-dim:     #6d6a75;
  --code-key:     #c98ee8;
  --code-str:     #97c98e;
  --code-prop:    #86b6e6;
  --code-punc:    #7c7986;

  --font-display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body:    "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-serif:   "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Fluid scale. One set of sizes, no mobile fork to drift out of sync. */
  --t-mono:    clamp(0.6875rem, 0.64rem + 0.18vw, 0.8125rem);
  --t-body:    clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --t-lead:    clamp(1.125rem, 1rem + 0.6vw, 1.5rem);
  --t-h3:      clamp(1.375rem, 1.1rem + 1.2vw, 2rem);
  --t-h2:      clamp(2rem, 1.4rem + 2.8vw, 4rem);
  /* Sized so the longer of the two name lines still clears the column,
     since .hero__line clips horizontally as well as vertically. */
  --t-display: clamp(2.5rem, 0.5rem + 9.4vw, 8.75rem);
  --t-numeral: clamp(4rem, 2rem + 14vw, 13rem);

  --gutter:  clamp(1.25rem, 0.6rem + 3vw, 4.5rem);
  --section: clamp(5rem, 3rem + 9vw, 11rem);
  --bar-h:   clamp(3.75rem, 3.2rem + 1.6vw, 5rem);

  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #131210;
    --paper-raised: #1b1a17;
    --paper-sunk:   #0d0c0b;
    --ink:          #f2efe7;
    --ink-soft:     #a8a396;
    --ink-faint:    #736f65;
    --rule:         #2b2925;
    --rule-strong:  #423f38;
    --accent:       #e8794c;
    --accent-soft:  #33221a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper:        #131210;
  --paper-raised: #1b1a17;
  --paper-sunk:   #0d0c0b;
  --ink:          #f2efe7;
  --ink-soft:     #a8a396;
  --ink-faint:    #736f65;
  --rule:         #2b2925;
  --rule-strong:  #423f38;
  --accent:       #e8794c;
  --accent-soft:  #33221a;
  color-scheme: dark;
}

/* --- base --------------------------------------------------------------- */

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, figure, blockquote, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }

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

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 0;
  z-index: 200;
  padding: 0.75rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  font: 500 var(--t-mono)/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transform: translateY(-140%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus-visible { transform: translateY(0); }

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

/* --- shared primitives -------------------------------------------------- */

.shell {
  width: 100%;
  max-width: 92rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Reserve the strip the vertical rail floats in, so it never sits on top of
   content. Below this width the rail is a dock at the bottom instead. */
@media (min-width: 56rem) {
  .shell { padding-right: calc(var(--gutter) + 4.5rem); }
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rule {
  height: 1px;
  background: var(--rule);
  border: 0;
  transform-origin: left center;
}

/* Section headers: 01 / ABOUT ------------------------------------------- */

.section {
  scroll-margin-top: var(--bar-h);
  padding-block: var(--section);
}

.section__head {
  display: flex;
  align-items: baseline;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: clamp(2.5rem, 5vw, 5rem);
}

.section__index { color: var(--ink-faint); }

.section__title {
  font-family: var(--font-display);
  font-size: var(--t-h2);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.035em;
}

.section__aside {
  margin-left: auto;
  color: var(--ink-faint);
  text-align: right;
}
@media (max-width: 44rem) { .section__aside { display: none; } }

/* Link with a rule that draws under it ---------------------------------- */

.ln {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  text-decoration: none;
  padding-block: 0.15em;
}
.ln::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 0.4s var(--ease);
}
.ln:hover::after,
.ln:focus-visible::after { transform: scaleX(1); transform-origin: left center; }
.ln__arrow { transition: transform 0.4s var(--ease); }
.ln:hover .ln__arrow { transform: translate(0.2em, -0.2em); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  min-height: 3rem;
  padding: 0.85em 1.6em;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  background: transparent;
  color: var(--ink);
  transition: background 0.35s var(--ease), color 0.35s var(--ease),
              border-color 0.35s var(--ease);
}
.btn--solid { background: var(--ink); color: var(--paper); }

@media (hover: hover) {
  .btn:hover { background: var(--ink); color: var(--paper); }
  .btn--solid:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
}

/* ==========================================================================
   Top bar: wordmark only, navigation lives in the rail
   ========================================================================== */

.bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  height: var(--bar-h);
  pointer-events: none;
}

.bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 100%;
}

.bar::before {
  content: "";
  position: absolute;
  inset: 0;
  /* Solid, not a backdrop-filter: blurring the backdrop forces a GPU readback
     of whatever is underneath every frame, and underneath is the pinned deck's
     full-width composited track. That combination stalls the renderer. */
  background: var(--paper);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.bar.is-stuck::before { opacity: 1; }

.bar__rule {
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: var(--rule);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.6s var(--ease);
}
.bar.is-stuck .bar__rule { transform: scaleX(1); }

.bar__mark,
.bar__meta { position: relative; z-index: 1; pointer-events: auto; }

.bar__mark {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.1rem);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.bar__mark-full { display: none; }
@media (min-width: 34rem) {
  .bar__mark-short { display: none; }
  .bar__mark-full { display: block; }
}

.bar__meta { color: var(--ink-faint); }
@media (max-width: 44rem) { .bar__meta { display: none; } }

/* Theme icon swap (used inside the rail) ---------------------------------- */

.bar__sun, .bar__rays, .bar__moon {
  transition: opacity 0.35s var(--ease), transform 0.5s var(--ease);
  transform-origin: center;
}
.bar__moon { opacity: 0; transform: rotate(-70deg) scale(0.5); }

:root[data-theme="dark"] .bar__sun,
:root[data-theme="dark"] .bar__rays { opacity: 0; transform: scale(0.4); }
:root[data-theme="dark"] .bar__moon { opacity: 1; transform: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bar__sun,
  :root:not([data-theme="light"]) .bar__rays { opacity: 0; transform: scale(0.4); }
  :root:not([data-theme="light"]) .bar__moon { opacity: 1; transform: none; }
}

/* ==========================================================================
   Floating rail: a flat cylinder that expands to labels on hover
   ========================================================================== */

.rail {
  position: fixed;
  z-index: 70;
  top: 50%;
  right: clamp(0.75rem, 2vw, 1.75rem);
  transform: translateY(-50%);
}

.rail__pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-raised);
  box-shadow: 0 1px 2px rgba(20, 18, 12, 0.04),
              0 10px 30px -12px rgba(20, 18, 12, 0.22);
  transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.rail:hover .rail__pill,
.rail:focus-within .rail__pill {
  border-color: var(--rule-strong);
  box-shadow: 0 1px 2px rgba(20, 18, 12, 0.05),
              0 18px 44px -14px rgba(20, 18, 12, 0.3);
}

/* Avatar ---------------------------------------------------------------- */

.rail__avatar {
  position: relative;
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  border-radius: 50%;
  overflow: visible;
}
.rail__avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  transition: transform 0.5s var(--ease);
}
.rail__avatar:hover img { transform: scale(1.06); }

/* Ring that draws itself around the avatar on hover. */
.rail__ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.4s var(--ease), transform 0.5s var(--ease);
}
.rail__avatar:hover .rail__ring,
.rail__avatar:focus-visible .rail__ring { opacity: 1; transform: scale(1); }

.rail__divider {
  width: 1rem;
  height: 1px;
  background: var(--rule);
  flex: none;
}

/* Items ----------------------------------------------------------------- */

.rail__list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
}

.rail__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 2.5rem;
  padding-inline: 0.7rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-faint);
  white-space: nowrap;
  transition: color 0.3s var(--ease), background 0.3s var(--ease);
}

.rail__dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  transition: opacity 0.3s var(--ease), transform 0.4s var(--ease);
}

/* The number is what shows while collapsed; the label replaces it on expand. */
.rail__num {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}

.rail__label {
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 0.45s var(--ease), opacity 0.3s var(--ease);
}

.rail:hover .rail__label,
.rail:focus-within .rail__label { max-width: 7rem; opacity: 1; }

.rail__item.is-current { color: var(--ink); }
.rail__item.is-current .rail__dot {
  opacity: 1;
  background: var(--accent);
  transform: scale(1.35);
}

@media (hover: hover) {
  .rail__item:hover { color: var(--ink); background: var(--paper-sunk); }
  .rail__item:hover .rail__dot { opacity: 1; }
}
.rail__item:focus-visible { color: var(--ink); background: var(--paper-sunk); }

/* Theme toggle ---------------------------------------------------------- */

.rail__theme {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  border-radius: 50%;
  color: var(--ink-faint);
  transition: color 0.3s var(--ease), background 0.3s var(--ease);
}
@media (hover: hover) {
  .rail__theme:hover { color: var(--ink); background: var(--paper-sunk); }
}

/* Mobile: the rail becomes a dock at the bottom, in thumb reach ---------- */

@media (max-width: 56rem) {
  .rail {
    top: auto;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    right: 50%;
    transform: translateX(50%);
  }

  .rail__pill {
    flex-direction: row;
    gap: 0.25rem;
    padding: 0.375rem;
  }

  .rail__list { flex-direction: row; width: auto; gap: 0.1rem; }
  .rail__divider { width: 1px; height: 1.25rem; }

  .rail__avatar { width: 2.25rem; height: 2.25rem; }
  .rail__theme { width: 2.5rem; height: 2.5rem; }

  /* There is no hover on touch, so nothing can expand. Show the labels
     outright, and fall back to numbers only when they genuinely won't fit. */
  .rail__item {
    min-width: 2.75rem;
    height: 2.75rem;
    padding-inline: 0.6rem;
    justify-content: center;
  }
  .rail__dot { display: none; }
  .rail__num { position: static; opacity: 1; }
  .rail__label {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .rail__item.is-current { background: var(--paper-sunk); color: var(--accent); }
}

@media (max-width: 56rem) and (min-width: 22rem) {
  .rail__num {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    opacity: 1;
  }
  .rail__label {
    position: static;
    width: auto;
    height: auto;
    max-width: none;
    opacity: 1;
    overflow: visible;
    clip-path: none;
  }
}

/* Keep the last section clear of the dock. */
@media (max-width: 56rem) {
  .foot { padding-bottom: calc(clamp(2.5rem, 6vw, 4rem) + 4rem); }
}

@media (prefers-reduced-motion: reduce) {
  .rail__label { transition: none; }
}

/* ==========================================================================
   Preloader
   ========================================================================== */

.pre {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  background: var(--paper);
  clip-path: inset(0 0 0 0);
  transition: clip-path 0.9s var(--ease-in-out);
}
/* Only ever shown by the pre-paint script, so the page is never blocked. */
html.intro-pending .pre { display: block; }
.pre.is-done { clip-path: inset(0 0 100% 0); }

.pre__inner {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: clamp(1.25rem, 4vh, 2.75rem) var(--gutter) clamp(2rem, 5vh, 3.25rem);
}

.pre__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink-faint);
}
.pre__mark { color: var(--ink); }
@media (max-width: 34rem) { .pre__place { display: none; } }

.pre__bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
}

.pre__count {
  display: flex;
  align-items: flex-start;
  font-family: var(--font-display);
  font-size: clamp(4rem, 1rem + 14vw, 11rem);
  font-weight: 600;
  line-height: 0.8;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.pre__pct {
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 0.6rem + 0.5vw, 1rem);
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-faint);
  margin-left: 0.35rem;
  transform: translateY(0.35em);
}

/* Status line: the word swaps as loading progresses. */
.pre__status {
  position: relative;
  overflow: hidden;
  height: 1.5em;
  padding-bottom: 0.35rem;
  color: var(--ink-soft);
  text-align: right;
}
.pre__word { display: block; }
.pre__word.is-entering { animation: word-in 0.5s var(--ease) both; }
@keyframes word-in {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: none; }
}
.pre__status.is-ready { color: var(--accent); }

.pre__track {
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: var(--rule);
}
.pre__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--ink);
}
.pre__status.is-ready ~ * .pre__fill,
.pre.is-ready .pre__fill { background: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .pre { transition: opacity 0.2s linear; }
  .pre.is-done { clip-path: none; opacity: 0; }
  .pre__word.is-entering { animation: none; }
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding-block: calc(var(--bar-h) + 2rem) clamp(5rem, 12vh, 8rem);
}
@media (max-width: 56rem) {
  /* Clear the floating dock. */
  .hero { padding-bottom: 6rem; }
}

.hero__inner {
  display: grid;
  gap: clamp(2.5rem, 6vw, 5rem);
  align-items: center;
  width: 100%;
}
@media (min-width: 60rem) {
  .hero__inner { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); }
}

/* Name ------------------------------------------------------------------ */

.hero__name {
  font-family: var(--font-display);
  font-size: var(--t-display);
  font-weight: 600;
  line-height: 0.86;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
}

.hero__line { display: block; overflow: hidden; }
.hero__line-in { display: block; will-change: transform; }

/* Animation is additive: this is the resting state, so no-JS is correct. */
html.intro-pending .hero .hero__line-in { transform: translateY(105%); }
.hero.is-revealing .hero__line-in {
  transform: translateY(0);
  transition: transform 0.95s var(--ease);
}
.hero.is-revealing .hero__line:nth-child(2) .hero__line-in {
  transition-delay: 0.09s;
}

.hero__rule { margin-bottom: clamp(1.25rem, 3vw, 2rem); }
html.intro-pending .hero .hero__rule { transform: scaleX(0); }
.hero.is-revealing .hero__rule {
  transform: scaleX(1);
  transition: transform 1s var(--ease) 0.35s;
}

.hero__role {
  font-size: var(--t-h3);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0.9rem;
}

.hero__blurb {
  max-width: 34ch;
  color: var(--ink-soft);
  font-size: var(--t-body);
  line-height: 1.65;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: clamp(1.75rem, 4vw, 2.5rem);
}

.hero__status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

.hero__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2f9e5f;
  box-shadow: 0 0 0 0 rgba(47, 158, 95, 0.55);
  animation: pulse 2.4s var(--ease-in-out) infinite;
  flex: none;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(47, 158, 95, 0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(47, 158, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 158, 95, 0); }
}

/* Fade the supporting copy up after the name lands. */
html.intro-pending .hero .hero__role,
html.intro-pending .hero .hero__blurb,
html.intro-pending .hero .hero__actions,
html.intro-pending .hero .hero__status,
html.intro-pending .hero .hero__scroll {
  opacity: 0;
  transform: translateY(1rem);
}
.hero.is-revealing .hero__role,
.hero.is-revealing .hero__blurb,
.hero.is-revealing .hero__actions,
.hero.is-revealing .hero__status,
.hero.is-revealing .hero__scroll {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease), transform 0.8s var(--ease);
}
.hero.is-revealing .hero__role    { transition-delay: 0.30s; }
.hero.is-revealing .hero__blurb   { transition-delay: 0.38s; }
.hero.is-revealing .hero__actions { transition-delay: 0.46s; }
.hero.is-revealing .hero__status  { transition-delay: 0.54s; }
.hero.is-revealing .hero__scroll  { transition-delay: 0.70s; }

.hero__scroll {
  position: absolute;
  left: var(--gutter);
  bottom: clamp(1.25rem, 4vh, 2.5rem);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink-faint);
  text-decoration: none;
}
.hero__scroll svg { animation: nudge 2.6s var(--ease-in-out) infinite; }
@keyframes nudge {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50%      { transform: translateY(4px); opacity: 1; }
}
@media (max-width: 60rem) { .hero__scroll { display: none; } }

/* ==========================================================================
   Code card: the one dark object on the page
   ========================================================================== */

.hero__code { position: relative; }

.code {
  position: relative;
  background: var(--code-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 1px rgba(20, 18, 12, 0.05),
              0 8px 20px -8px rgba(20, 18, 12, 0.18),
              0 30px 60px -30px rgba(20, 18, 12, 0.35);
}

html.intro-pending .hero .code { opacity: 0; transform: translateY(1.5rem) scale(0.985); }
.hero.is-revealing .code {
  opacity: 1;
  transform: none;
  transition: opacity 0.8s var(--ease) 0.1s, transform 0.9s var(--ease) 0.1s;
}

.code__chrome {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0.95rem;
  background: var(--code-chrome);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.code__dots { display: flex; gap: 0.4rem; }
.code__dots i {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #3b3944;
}
.code__dots i:first-child  { background: #e0655b; }
.code__dots i:nth-child(2) { background: #e0b04a; }
.code__dots i:last-child   { background: #5aa963; }
.code__file { color: var(--code-dim); letter-spacing: 0.04em; text-transform: none; }

.code__body {
  margin: 0;
  padding: clamp(1rem, 3vw, 1.6rem) clamp(0.9rem, 3vw, 1.6rem);
  font-family: var(--font-mono);
  font-size: clamp(0.72rem, 0.6rem + 0.45vw, 0.875rem);
  line-height: 1.85;
  color: var(--code-ink);
  /* Fixed floor so the card doesn't jolt the layout as lines are typed. */
  min-height: 16.5em;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  tab-size: 2;
}

.code__out { font: inherit; }
.tok-key  { color: var(--code-key); }
.tok-str  { color: var(--code-str); }
.tok-prop { color: var(--code-prop); }
.tok-punc { color: var(--code-punc); }

.code__caret {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 0.06em;
  vertical-align: text-bottom;
  background: var(--code-ink);
  opacity: 0;
}
.code.is-typing .code__caret { opacity: 1; animation: blink 1.05s steps(1) infinite; }
.code.is-done .code__caret { opacity: 0.35; animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* Autocomplete flourish */
.code__ac {
  position: absolute;
  left: clamp(2.5rem, 9vw, 5.5rem);
  top: 58%;
  min-width: 13rem;
  padding: 0.3rem;
  background: #26252c;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.6);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0;
  transform: translateY(-4px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.code__ac.is-on { opacity: 1; transform: none; }

.code__ac-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.28rem 0.5rem;
  border-radius: 4px;
  color: var(--code-dim);
  white-space: nowrap;
}
.code__ac-row.is-on { background: #35333d; color: var(--code-ink); }
.code__ac-kind {
  font-size: 0.6rem;
  font-style: normal;
  letter-spacing: 0.06em;
  color: var(--code-prop);
  opacity: 0.8;
}

@media (max-width: 40rem) {
  .code__ac { display: none; }
  .code__body { min-height: 17em; }
}

/* ==========================================================================
   About
   ========================================================================== */

.about__grid {
  display: grid;
  gap: clamp(1.5rem, 5vw, 4.5rem);
  align-items: start;
}
@media (min-width: 58rem) {
  .about__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
}

/* Opening statement, set large. This is the first thing anyone reads. */
.about__lead {
  font-size: clamp(1.375rem, 1rem + 1.9vw, 2.5rem);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.03em;
  max-width: 20ch;
}

.about__p {
  color: var(--ink-soft);
  max-width: 56ch;
  line-height: 1.65;
}
.about__p + .about__p { margin-top: 1.1em; }

.about__close {
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: clamp(1.5rem, 4vw, 2.25rem);
  border-top: 1px solid var(--rule);
  font-size: clamp(1.125rem, 0.95rem + 1vw, 1.75rem);
  line-height: 1.35;
  letter-spacing: -0.02em;
  max-width: 44ch;
}

/* Services + stack ------------------------------------------------------ */

.about__split {
  display: grid;
  gap: clamp(2.5rem, 6vw, 5rem);
  margin-top: clamp(3rem, 7vw, 5.5rem);
  padding-top: clamp(2rem, 4vw, 3rem);
  border-top: 1px solid var(--rule);
}
@media (min-width: 58rem) {
  .about__split { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
}

.about__label {
  color: var(--ink-faint);
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
}

.services__item {
  display: flex;
  align-items: baseline;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  padding-block: clamp(0.7rem, 1.6vw, 1rem);
  border-bottom: 1px solid var(--rule);
}
.services__item:first-child { border-top: 1px solid var(--rule); }
.services__num { color: var(--ink-faint); flex: none; }
.services__text {
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  letter-spacing: -0.01em;
}

.stack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.stack__item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: clamp(0.85rem, 2vw, 1.15rem);
  background: var(--paper);
}
.stack__name {
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.stack__note { color: var(--ink-faint); letter-spacing: 0.08em; }

.about__note {
  margin-top: clamp(1.25rem, 3vw, 1.75rem);
  color: var(--ink-faint);
  font-size: 0.9375rem;
  line-height: 1.6;
  max-width: 42ch;
}

/* ==========================================================================
   Work: pinned horizontal deck
   ========================================================================== */

.work {
  position: relative;
  scroll-margin-top: 0;
  background: var(--paper-sunk);
  border-block: 1px solid var(--rule);
}

/* Height is set by JS to (panels + 1) x viewport once pinning is on. The
   default is the unpinned, vertically stacked layout. */
.work__pin { position: relative; }

.work__head {
  display: flex;
  align-items: baseline;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  padding-block: clamp(1.5rem, 4vw, 2.5rem) 1rem;
}

.work__meter {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.work__counter { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.work__counter b { color: var(--ink); font-weight: 500; }

.work__segs { display: flex; gap: 0.4rem; }
.work__seg {
  width: clamp(1.5rem, 4vw, 2.75rem);
  height: 2px;
  padding: 0;
  background: var(--rule-strong);
  transition: background 0.4s var(--ease);
}
.work__seg.is-on { background: var(--ink); }

/* Panels ---------------------------------------------------------------- */

.panel { display: flex; align-items: center; }

.panel__inner {
  display: grid;
  gap: clamp(1.75rem, 4vw, 4rem);
  align-items: center;
  width: 100%;
}

.panel__num {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2rem, min(1.5rem + 3.2vw, 7vh), 4.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--rule-strong);
  margin-bottom: 0.25em;
}

.panel__name {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, min(1.2rem + 3.2vw, 8vh), 4rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.panel__kind {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1rem, min(0.95rem + 0.85vw, 3.2vh), 1.625rem);
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

.panel__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem clamp(1.25rem, 3vw, 2.5rem);
  margin-top: clamp(0.85rem, min(3vw, 2.2vh), 1.6rem);
  padding-block: clamp(0.6rem, min(2vw, 1.6vh), 1.1rem);
  border-block: 1px solid var(--rule);
}
.panel__meta div { display: flex; gap: 0.55rem; align-items: baseline; }
.panel__meta dt { color: var(--ink-faint); }
.panel__meta dd { margin: 0; color: var(--ink); }
.panel__live { color: #2f9e5f; }
.panel__live--wip { color: var(--ink-soft); }

.panel__summary {
  margin-top: clamp(0.75rem, min(2.5vw, 2vh), 1.4rem);
  color: var(--ink-soft);
  max-width: 52ch;
  line-height: 1.6;
}

.panel__features {
  display: grid;
  gap: 0.3rem;
  margin-top: clamp(0.75rem, min(2.5vw, 2vh), 1.4rem);
  max-width: 52ch;
}
.panel__features li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}
.panel__features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 0.45rem;
  height: 1px;
  background: var(--rule-strong);
}

.panel__tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: clamp(0.85rem, min(3vw, 2.2vh), 1.6rem);
}
.panel__tech li {
  padding: 0.4em 0.75em;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--paper);
}

.panel__links {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1rem, 3vw, 2rem);
  margin-top: clamp(1rem, min(3.5vw, 2.6vh), 2rem);
}
.panel__link {
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 2.75rem;
}

/* Source links get their own row so a project with two builds doesn't wrap
   its four links into a ragged block. */
.panel__links--repos { margin-top: 0.75rem; gap: clamp(0.85rem, 2.5vw, 1.5rem); }

/* Source sits a step quieter than the live links: the demo is the headline,
   the repo is for whoever wants to read it. */
.panel__link--repo { color: var(--ink-faint); }
@media (hover: hover) {
  .panel__link--repo:hover { color: var(--ink); }
}
.panel__link--repo:focus-visible { color: var(--ink); }

.panel__side {
  display: flex;
  flex-direction: column;
  gap: clamp(0.85rem, min(2.5vw, 2vh), 1.5rem);
  min-width: 0;
}

.panel__shot { margin: 0; overflow: hidden; }
.panel__shot img {
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  background: var(--paper);
}

/* Phone demos ----------------------------------------------------------- */

/* The two mobile apps are portrait screen recordings, so they get a device
   frame instead of the landscape plate the web projects use. Sized from its
   height, not its width: in a wide panel the height is what's scarce, and a
   9:20 clip fitted to the column width would tower off the screen. */
.panel__phone {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.panel__phone-body {
  position: relative;
  padding: 0.4rem;
  border-radius: 1.9rem;
  /* Dark, like the hero's IDE card. Deliberately the same move: a screen is
     the one object on this paper that should read as lit rather than printed. */
  background: #17161a;
  box-shadow:
    0 0 0 1px var(--rule-strong),
    0 1.5rem 2.5rem -1.25rem rgb(0 0 0 / 0.35);
}

.panel__video {
  display: block;
  height: clamp(15rem, 42vh, 25rem);
  width: auto;
  aspect-ratio: 288 / 640;
  border-radius: 1.55rem;
  background: #000;
  object-fit: cover;
}

/* Autoplay is a request, not a guarantee, and phones refuse it often enough
   that it cannot be the only way in. The frame always carries a play control
   and hides it only while the clip is actually running, so a refused autoplay
   degrades to a tap rather than to a still image that does nothing. */
.panel__play {
  position: absolute;
  inset: 0.4rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 1.55rem;
  background: rgb(0 0 0 / 0.3);
  color: #fff;
  cursor: pointer;
  transition: opacity 160ms ease;
}
.panel__play span {
  display: grid;
  place-items: center;
  /* Comfortably past the 44px minimum tap target. */
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.92);
  color: #17161a;
  /* The glyph is a triangle, which reads as off-centre when truly centred. */
  padding-left: 0.15rem;
}
.panel__play:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: -4px;
}
.panel__phone.is-playing .panel__play {
  opacity: 0;
  pointer-events: none;
}

.panel__phone-cap {
  font-size: var(--t-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* Awaiting media -------------------------------------------------------- */

/* A project can ship before its screenshot does. This holds the column's
   weight so the panel doesn't look half-built, and reads as typography
   rather than as a broken image. */
.panel__plate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  aspect-ratio: 16 / 10;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--rule);
  background:
    repeating-linear-gradient(
      -45deg,
      transparent 0 10px,
      var(--rule) 10px 11px
    );
}
.panel__plate-name {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, min(2.2vw, 3.4vh), 2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink-soft);
}
.panel__plate-kind {
  font-size: var(--t-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* Pinned mode ----------------------------------------------------------- */

.work.is-pinned .work__pin {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  /* The head sits inside the pinned area, so it has to clear the fixed bar. */
  padding-top: var(--bar-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.work.is-pinned .work__track {
  flex: 1 1 auto;
  /* Without min-height:0 a flex child refuses to shrink below its content,
     which makes the pinned column fight its own layout every frame. */
  min-height: 0;
  display: flex;
}
.work.is-pinned .panel {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}
.work.is-pinned .panel__inner {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  max-height: 100%;
}
.work.is-pinned .panel__shot img { max-height: 38vh; object-fit: cover; }

/* Pinned panels get exactly one viewport, so the media is capped against the
   viewport height rather than allowed to set the panel's height. */
.work.is-pinned .panel__video { height: min(44vh, 23rem); }
.work.is-pinned .panel__plate { max-height: 38vh; }

.work.is-pinned .work__head { padding-block: clamp(0.85rem, 2.2vh, 1.5rem) 0.75rem; }
.work.is-pinned .work__head .section__title {
  font-size: clamp(1.375rem, min(2.4vw, 4.2vh), 2.25rem);
}
.work.is-pinned .panel__tech,
.work.is-pinned .panel__links { margin-top: 0; }

/* Everything below has to clear one viewport minus the bar and the head, so
   the feature list runs two-up and the vertical rhythm tightens. */
.work.is-pinned .panel__features { grid-template-columns: 1fr 1fr; column-gap: 1.25rem; }
.work.is-pinned .panel__summary { max-width: 46ch; }
.work.is-pinned .panel__meta { gap: 0.4rem clamp(1rem, 2.4vw, 2rem); }

@media (max-height: 780px) {
  .work.is-pinned .panel__features li { font-size: 0.875rem; }
  .work.is-pinned .panel__tech li { padding: 0.3em 0.65em; }
  /* The caption is the first thing that can go without losing meaning, and
     dropping it buys the frame back the height it costs. */
  .work.is-pinned .panel__phone-cap { display: none; }
}

/* Unpinned (mobile, reduced motion, no JS): plain vertical stack --------- */

.work:not(.is-pinned) .work__meter { display: none; }
.work:not(.is-pinned) .work__track {
  display: grid;
  gap: clamp(3rem, 8vw, 5rem);
  padding-bottom: clamp(3rem, 8vw, 5rem);
}
.work:not(.is-pinned) .panel { scroll-margin-top: var(--bar-h); }
.work:not(.is-pinned) .panel__shot,
.work:not(.is-pinned) .panel__phone,
.work:not(.is-pinned) .panel__plate { margin-top: 1.5rem; }

@media (min-width: 48rem) {
  .work:not(.is-pinned) .panel__inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .work:not(.is-pinned) .panel__shot,
  .work:not(.is-pinned) .panel__phone,
  .work:not(.is-pinned) .panel__plate { margin-top: 0; }
}

/* ==========================================================================
   Contact
   ========================================================================== */

.contact__grid {
  display: grid;
  gap: clamp(2.5rem, 6vw, 5rem);
  align-items: start;
}
@media (min-width: 58rem) {
  .contact__grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
}

.contact__lead {
  font-size: clamp(1.25rem, 1rem + 1.2vw, 1.875rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
  max-width: 24ch;
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

/* Flash messages -------------------------------------------------------- */

.notes { display: grid; gap: 0.5rem; margin-bottom: clamp(1.5rem, 4vw, 2.5rem); }

.note {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-left-width: 2px;
  background: var(--paper-raised);
  animation: note-in 0.45s var(--ease);
}
@keyframes note-in {
  from { opacity: 0; transform: translateY(-0.4rem); }
  to   { opacity: 1; transform: none; }
}
.note--success { border-left-color: #2f9e5f; }
.note--error   { border-left-color: #c0392b; }
.note--info    { border-left-color: var(--accent); }
.note__text { flex: 1; font-size: 0.9375rem; line-height: 1.55; }
.note__x {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--ink-faint);
}

/* Form ------------------------------------------------------------------ */

.form { display: grid; gap: clamp(1.25rem, 3vw, 1.75rem); }

.field { display: grid; gap: 0.5rem; }
.field__label { color: var(--ink-faint); }
.field__label span { color: var(--accent); }

.field__input {
  width: 100%;
  padding: 0.85rem 0;
  font-family: inherit;
  font-size: var(--t-body);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule-strong);
  border-radius: 0;
  transition: border-color 0.35s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.field__input::placeholder { color: var(--ink-faint); }
.field__input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}
.field__input:focus-visible { outline: none; }
.field__input--area { resize: vertical; min-height: 8rem; line-height: 1.6; }

.form__foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-top: 0.5rem;
}
.form__req { color: var(--ink-faint); }

[data-submit][disabled] { opacity: 0.55; cursor: progress; }
[data-submit][data-state="sending"] svg { animation: nudge-x 0.9s var(--ease-in-out) infinite; }
@keyframes nudge-x {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(3px); }
}

/* Direct channels ------------------------------------------------------- */

.direct__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: clamp(0.7rem, 1.6vw, 0.95rem);
  border-bottom: 1px solid var(--rule);
}
.direct__row:first-child { border-top: 1px solid var(--rule); }
.direct__label { color: var(--ink-faint); flex: none; }

.direct__value {
  position: relative;
  text-align: right;
  font-size: 0.9375rem;
  text-decoration: none;
  word-break: break-word;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
}
@media (hover: hover) {
  .direct__value:hover { color: var(--accent); border-bottom-color: currentColor; }
}
.direct__value:focus-visible { color: var(--accent); }

.contact__status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: clamp(1.5rem, 4vw, 2.25rem);
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  line-height: 1.5;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.foot {
  border-top: 1px solid var(--rule);
  padding-block: clamp(2.5rem, 6vw, 4rem);
}

.foot__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.75rem 2.5rem;
}

.foot__mark {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1rem + 2vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1;
}
.foot__line {
  margin-top: 0.5rem;
  color: var(--ink-faint);
  font-size: 0.875rem;
}

.foot__socials { display: flex; flex-wrap: wrap; gap: clamp(1rem, 3vw, 1.75rem); }
.foot__socials a { min-height: 2.75rem; display: inline-flex; align-items: center; }

.foot__legal {
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  width: 100%;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

/* Narrow phones: label-above-value reads better than a squeezed two-column
   row, especially for the long LinkedIn URL. */
@media (max-width: 30rem) {
  .direct__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  .direct__value { text-align: left; }
}
