/* Jonathan Brennan.net - shared styles (from Home.dc.html design) */

html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  scroll-padding-top: 62px;
}

/* JavaScript briefly owns the scroll position during one wheel/trackpad
   gesture so native momentum cannot skip across several stage boundaries. */
html.is-gesture-scrolling {
  scroll-behavior: auto;
  scroll-snap-type: none;
}

/* overflow-x: clip (not hidden) - clips stray overflow without creating a
   scroll container, which would break the sticky sections */
html, body { overflow-x: clip; }

body {
  margin: 0;
  background: #f7f3ec;
  color: #1c1a17;
  font-family: 'Newsreader', serif;
}

a { color: #1c1a17; text-decoration: none; }
a:hover { color: #7a2a1f; }
::selection { background: #7a2a1f; color: #f7f3ec; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes typew { from { width: 0; } to { width: var(--tw, 40ch); } }
@keyframes cueDrop {
  0%   { transform: scaleY(0); transform-origin: top; }
  45%  { transform: scaleY(1); transform-origin: top; }
  55%  { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}
@keyframes cueNudge {
  0%, 100% { transform: translateY(-2px); }
  50% { transform: translateY(4px); }
}

.anim-fade { animation: fadeUp .8s both; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 20px 48px;
  background: rgba(247, 243, 236, .92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(28, 26, 23, .35);
  font-family: 'Archivo', sans-serif;
  font-size: 11px;
  letter-spacing: .18em;
}
.topbar-name { font-weight: 600; letter-spacing: .26em; }
.topbar-nav { display: flex; gap: 22px; }
.topbar-nav .accent { color: #7a2a1f; }

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

.hero-track {
  position: relative;
  height: 165vh;
  scroll-snap-align: start;
}

.hero {
  position: sticky;
  top: 62px;
  height: calc(100vh - 62px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sheen {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 200px;
  background: linear-gradient(transparent, rgba(122, 42, 31, .08), transparent);
  transform: translateY(-200px);
  opacity: 0;
  will-change: transform, opacity;
  pointer-events: none;
  z-index: 2;
}

.hero-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  will-change: opacity, transform;
}

.hero-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1.14fr 1fr;
  gap: 72px;
  align-items: center;
  padding: 40px 48px 0;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.kicker {
  font-family: 'Archivo', sans-serif;
  font-size: 11px;
  letter-spacing: .3em;
  color: #7a2a1f;
}

.hero-title {
  margin: 26px 0 0;
  font-weight: 400;
  font-size: clamp(56px, 6.5vw, 88px);
  line-height: 1.02;
  letter-spacing: -0.015em;
}
.hero-title span { display: block; }

.hero-subtitle {
  margin: 24px 0 0;
  max-width: 520px;
  font-size: 23px;
  line-height: 1.35;
  font-style: italic;
  color: #1c1a17;
}

.hero-lede {
  margin: 18px 0 0;
  max-width: 590px;
  font-size: 17px;
  line-height: 1.57;
  color: #57524a;
}

.hero-side {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
}

.profile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding-bottom: 13px;
  border-bottom: 1px solid #1c1a17;
}
.profile-label {
  font-family: 'Archivo', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .22em;
  color: #7a2a1f;
}
.terminal {
  display: flex;
  align-items: baseline;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.terminal-prompt { color: #98928a; margin-right: 9px; }
.profile-terminal {
  width: min(100%, 300px);
  padding: 9px 11px;
}
.profile-terminal .terminal {
  width: 100%;
}
.terminal-type {
  --tw: 6ch;
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  width: 6ch;
  color: #7a2a1f;
  animation: typew .8s steps(6, end) .8s both;
}
.terminal-cursor {
  display: inline-block;
  width: 5px;
  height: 10px;
  background: #7a2a1f;
  margin-left: 3px;
  animation: blink 1.1s step-end infinite;
}
.profile-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 15px;
  padding: 16px 0 17px;
  border-bottom: 1px solid rgba(28, 26, 23, .22);
}
.profile-row-last { border-bottom-color: #1c1a17; }
.profile-no {
  font-family: 'Archivo', sans-serif;
  font-size: 10px;
  letter-spacing: .12em;
  color: #7a2a1f;
}
.profile-title {
  font-size: 20px;
  line-height: 1.1;
}
.profile-row p {
  margin: 5px 0 0;
  font-size: 14.5px;
  line-height: 1.45;
  color: #57524a;
}

.hero-foot { padding: 0 48px 56px; }

.scroll-cue {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 13px;
  margin-top: 32px;
  padding: 10px 0;
  font-family: 'Archivo', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .2em;
  color: #1c1a17;
}
.scroll-cue:hover { color: #7a2a1f; }
.scroll-cue-line {
  width: 42px;
  height: 1px;
  background: #7a2a1f;
}
.scroll-cue-arrow {
  color: #7a2a1f;
  font-size: 15px;
  animation: cueNudge 1.6s ease-in-out infinite;
}

/* ---------- Sticky stages ---------- */

.stage {
  position: relative;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.stage-pattern { z-index: 2; margin-top: -65vh; height: 180vh; }
.stage-toc     { z-index: 3; margin-top: -48vh; height: 180vh; }

.stage-pin {
  position: sticky;
  top: 62px;
  min-height: calc(100vh - 62px);
  background: #f7f3ec;
  border-top: 1px solid rgba(28, 26, 23, .35);
  display: flex;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
}

.stage-in {
  width: 100%;
  padding: 60px 48px;
  box-sizing: border-box;
  opacity: 0;
  transform: translateY(46px);
  will-change: opacity, transform;
}

.stage-inner { max-width: 1180px; margin: 0 auto; }
.stage-inner.narrow { max-width: 980px; }

/* ---------- Pattern ---------- */

.pattern-headline {
  margin-top: 28px;
  font-size: clamp(40px, 4.6vw, 58px);
  line-height: 1.12;
  letter-spacing: -0.01em;
}

.pattern-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 44px;
  margin-top: 56px;
}
.pattern-cols p {
  margin: 0;
  font-size: 18px;
  line-height: 1.7;
  color: #57524a;
}

/* ---------- Table of contents ---------- */

.toc-kicker {
  font-family: 'Archivo', sans-serif;
  font-size: 11px;
  letter-spacing: .3em;
  color: #98928a;
  margin-bottom: 14px;
}

.toc-list { display: flex; flex-direction: column; }

[data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .9s ease, transform .9s cubic-bezier(.22, .61, .36, 1);
}

.toc-row {
  display: flex;
  align-items: baseline;
  gap: 26px;
  padding: 26px 8px;
  border-top: 1px solid rgba(28, 26, 23, .18);
  transform: translateY(30px);
  transition: opacity .9s ease, transform .9s cubic-bezier(.22, .61, .36, 1),
              padding-left .25s, background .25s;
}
.toc-row-first { border-top: 1px solid rgba(28, 26, 23, .35); }
.toc-row-last  { border-bottom: 1px solid rgba(28, 26, 23, .35); }
.toc-row:hover {
  padding-left: 26px;
  background: rgba(122, 42, 31, .05);
  color: inherit;
}

.toc-no {
  font-family: 'Archivo', sans-serif;
  font-size: 12px;
  letter-spacing: .1em;
  color: #7a2a1f;
}
.toc-title { font-size: 40px; flex: 1; }
.toc-sub { font-style: italic; font-size: 16px; color: #98928a; }
.toc-arrow { font-size: 22px; color: #7a2a1f; }

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

.stage-contact {
  z-index: 4;
  margin-top: -48vh;
  background: #f7f3ec;
  border-top: 1px solid rgba(28, 26, 23, .35);
  min-height: calc(100vh - 62px);
  display: flex;
  box-sizing: border-box;
}

.contact-in {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 80px 48px 40px;
}

.contact-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .78fr);
  gap: clamp(52px, 7vw, 110px);
  align-items: start;
  margin-top: 24px;
}

.contact-headline {
  font-size: clamp(52px, 5.6vw, 76px);
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.contact-lede {
  margin: 26px 0 0;
  max-width: 560px;
  font-size: 19px;
  line-height: 1.65;
  color: #57524a;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 36px;
  margin-top: 44px;
  font-family: 'Archivo', sans-serif;
  font-size: 13px;
  letter-spacing: .06em;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 8px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.contact-form label > span {
  font-family: 'Archivo', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #7a2a1f;
}
.contact-form input,
.contact-form textarea {
  box-sizing: border-box;
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(28, 26, 23, .45);
  border-radius: 0;
  padding: 10px 2px 11px;
  background: transparent;
  color: #1c1a17;
  font: 17px/1.4 'Newsreader', serif;
  appearance: none;
}
.contact-form textarea {
  min-height: 94px;
  resize: vertical;
}
.contact-form input:focus,
.contact-form textarea:focus {
  outline: 0;
  border-bottom-color: #7a2a1f;
  box-shadow: 0 1px 0 #7a2a1f;
}
.contact-form button {
  display: inline-flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  align-self: flex-start;
  min-width: 230px;
  border: 1px solid #7a2a1f;
  padding: 15px 18px;
  background: #7a2a1f;
  color: #f7f3ec;
  font-family: 'Archivo', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  cursor: pointer;
}
.contact-form button:hover,
.contact-form button:focus-visible {
  background: #1c1a17;
  border-color: #1c1a17;
  outline: 0;
}
.form-note {
  margin: -7px 0 0;
  font-size: 13px;
  font-style: italic;
  color: #98928a;
}

.footer {
  max-width: 1180px;
  margin: 60px auto 0;
  width: 100%;
  padding-top: 20px;
  border-top: 1px solid rgba(28, 26, 23, .18);
  display: flex;
  justify-content: space-between;
  font-family: 'Archivo', sans-serif;
  font-size: 11px;
  letter-spacing: .14em;
  color: #98928a;
}

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

@media (max-width: 900px) {
  html {
    scroll-snap-type: y mandatory;
    scroll-padding-top: 50px;
  }

  html.is-gesture-scrolling {
    scroll-snap-type: y mandatory;
  }

  body {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .topbar {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: max(18px, env(safe-area-inset-right));
    padding-bottom: 8px;
    padding-left: max(18px, env(safe-area-inset-left));
    font-size: 10px;
    letter-spacing: .14em;
    gap: 12px;
  }
  .topbar-place { display: none; }
  .topbar-name { letter-spacing: .18em; }
  .topbar-nav { gap: 14px; }
  .topbar a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* the sticky-stack choreography is desktop-only; stages flow naturally here */
  .hero-track { height: auto; }
  .hero {
    position: static;
    height: auto;
    min-height: calc(100svh - 50px);
    overflow: visible;
  }
  .stage-pattern, .stage-toc, .stage-contact { margin-top: 0; height: auto; }
  .stage-pin {
    position: static;
    min-height: calc(100svh - 50px);
    overflow: visible;
  }

  .hero-track,
  .stage-pattern,
  .stage-toc,
  .stage-contact {
    scroll-snap-align: start;
    scroll-snap-stop: always;
    scroll-margin-top: 50px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 38px;
    padding-top: 38px;
    padding-right: max(24px, env(safe-area-inset-right));
    padding-left: max(24px, env(safe-area-inset-left));
    padding-bottom: 12px;
    align-items: start;
  }
  .hero-grid > * { min-width: 0; }
  .hero-title {
    font-size: clamp(50px, 13.5vw, 68px);
    line-height: .98;
    text-wrap: balance;
  }
  .hero-subtitle {
    font-size: 21px;
    text-wrap: pretty;
  }
  .hero-lede {
    font-size: 17px;
    text-wrap: pretty;
  }
  .terminal { min-width: 0; font-size: 11px; }
  .terminal-type {
    width: 6ch;
    animation: none;
  }
  .terminal-cursor { height: 12px; }
  .profile-row p { font-size: 15.5px; }
  .hero-foot {
    padding-right: max(24px, env(safe-area-inset-right));
    padding-bottom: 32px;
    padding-left: max(24px, env(safe-area-inset-left));
  }

  .stage-in {
    padding-top: 56px;
    padding-right: max(24px, env(safe-area-inset-right));
    padding-bottom: 56px;
    padding-left: max(24px, env(safe-area-inset-left));
  }
  .contact-in {
    padding-top: 64px;
    padding-right: max(24px, env(safe-area-inset-right));
    padding-bottom: max(32px, env(safe-area-inset-bottom));
    padding-left: max(24px, env(safe-area-inset-left));
  }

  .pattern-cols { grid-template-columns: 1fr; gap: 28px; }
  .pattern-headline {
    font-size: clamp(38px, 10vw, 54px);
    text-wrap: balance;
  }
  .pattern-cols p {
    font-size: 17px;
    text-wrap: pretty;
  }

  .toc-row { flex-wrap: wrap; gap: 12px 18px; padding: 22px 4px; }
  .toc-title { font-size: 28px; flex: 1 1 100%; order: 2; }
  .toc-sub { order: 3; flex: 1 1 calc(100% - 40px); line-height: 1.35; }
  .toc-arrow { order: 4; margin-left: auto; }

  .contact-headline {
    font-size: clamp(52px, 14vw, 76px);
  }

  .contact-grid {
    grid-template-columns: 1fr;
    gap: 44px;
  }

  .footer { flex-direction: column; gap: 8px; }
}

@media (max-width: 560px) {
  .topbar {
    gap: 8px;
    font-size: 9px;
  }
  .topbar-name {
    min-width: 72px;
    font-size: 0;
    letter-spacing: 0;
  }
  .topbar-name::after {
    content: "J. R. BRENNAN";
    font-size: 9px;
    letter-spacing: .12em;
    white-space: nowrap;
  }
  .topbar-nav { gap: 9px; }

  .scroll-cue { margin-top: 32px; }
  .scroll-cue-line { width: 28px; }
  .profile-head { align-items: flex-start; }
  .profile-head {
    flex-direction: column;
  }
  .profile-terminal {
    width: 100%;
  }
  .terminal { margin-top: 1px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (pointer: coarse) {
  .toc-row,
  .contact-links a {
    min-height: 44px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .anim-fade, .scroll-cue-arrow, .terminal-type, .terminal-cursor { animation: none !important; }
  .anim-fade, .terminal-type { opacity: 1; }
  .terminal-type { width: 6ch; }
  .sheen { display: none; }
  .stage-in, [data-reveal], .hero-content {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
