/* Phase 8: shared spatial, motion, navigation and identity system. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: v4-page-out var(--motion-page) var(--ease-standard) both; }
::view-transition-new(root) { animation: v4-page-in var(--motion-page) var(--ease-out) both; }
.header-logo { view-transition-name: site-wordmark; }
.site-monogram { display: grid; place-items: center; flex: 0 0 auto; width: 2.15rem; height: 2.15rem; }
.brand-mark { display: block; width: 100%; height: 100%; object-fit: contain; }
[data-theme="dark"] .brand-mark { filter: brightness(1.75) saturate(1.08); }
.footer-logo .site-monogram { width: 2.65rem; height: 2.65rem; }
::view-transition-group(site-wordmark) { animation-duration: var(--motion-page); }
@keyframes v4-page-out { to { opacity: 0; transform: translateY(-0.25rem); } }
@keyframes v4-page-in { from { opacity: 0; transform: translateY(0.5rem); } }

:where(.container,.content-shell,.header-inner) { box-sizing: border-box; }
:where(.container,.content-shell) { padding-inline: var(--gutter-section); }
.header-inner,.site-footer > .content-shell { padding-inline: var(--gutter-chrome); }
.container { width: min(100%, var(--container-wide)); max-width: none; }
.content-shell { width: min(100%, var(--container-content)); }
.content-shell--wide { width: min(100%, var(--container-wide)); }
.content-shell--reading { width: min(100%, var(--container-reading)); }
.header-inner { width: min(100%, var(--container-wide)); max-width: none; }
.header-sentinel { position: absolute; top: 0; width: 1px; height: 1px; pointer-events: none; }

.site-header { background: color-mix(in srgb, var(--header-surface) 88%, transparent); transition: min-height var(--motion-ui) var(--ease-standard), background-color var(--motion-ui) var(--ease-standard), box-shadow var(--motion-ui) var(--ease-standard); }
.site-header[data-scrolled="true"] { background: color-mix(in srgb, var(--header-surface) 82%, transparent); backdrop-filter: blur(14px) saturate(118%); -webkit-backdrop-filter: blur(14px) saturate(118%); box-shadow: 0 0.3rem 1.25rem color-mix(in srgb, var(--surface-canvas) 78%, transparent); }
.header-inner { min-height: 4.75rem; height: auto; transition: min-height var(--motion-ui) var(--ease-standard); }
.site-header[data-scrolled="true"] .header-inner { min-height: 4.35rem; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .site-header,.site-header[data-scrolled="true"] { background: var(--header-surface); } }

:where(.nav-link,.footer-links-list a,.tool-card,.project-row,.article-row,.btn) { transition-duration: var(--motion-ui); transition-timing-function: var(--ease-standard); }
:where(.btn,.tool-card,.project-row,.article-row):hover { transform: translateY(-2px); }
:where(textarea,input,select,pre,code) { transform: none !important; }

.reveal-item { opacity: 0; transform: translateY(var(--reveal-distance)); }
.reveal-item.is-revealed { opacity: 1; transform: translateY(0); transition: opacity var(--motion-reveal) var(--ease-out), transform var(--motion-reveal) var(--ease-out); transition-delay: calc(var(--reveal-order, 0) * 55ms); }
.v3-section-heading::after, .work-section > .content-shell > h2::after, .writing-archive-title::after { content: ""; display: block; width: clamp(2.5rem, 6vw, 4.5rem); height: 1px; margin-top: 1.25rem; background: var(--accent); transform-origin: left; transition: transform var(--motion-reveal) var(--ease-out); }
.reveal-item:not(.is-revealed)::after { transform: scaleX(0.18); }

.home-hero { min-height: min(51rem, calc(100svh - 4.75rem)); padding-block: var(--section-space-major); }
.home-hero::before { width: min(65rem, 82vw); top: -52%; right: -18%; border-radius: 0; background: linear-gradient(135deg, transparent 20%, var(--ambient-primary) 62%, transparent 82%); transform: rotate(-8deg); }
.home-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .24; pointer-events: none; background-image: linear-gradient(var(--border-subtle) 1px,transparent 1px),linear-gradient(90deg,var(--border-subtle) 1px,transparent 1px); background-size: 4.5rem 4.5rem; mask-image: linear-gradient(105deg,transparent 14%,#000 68%,transparent 96%); }
.home-eyebrow { animation-delay: 20ms; }
.home-hero h1 { font-size: clamp(4.25rem, 9vw, 8.7rem); }
.home-hero__content { position: relative; }
.home-hero__content::before { content: ""; position: absolute; left: -1.5rem; top: 3.8rem; width: 1px; height: clamp(5rem,10vw,9rem); background: linear-gradient(var(--accent),transparent); }
.home-hero :where(.home-eyebrow,h1,.home-hero__statement,.home-hero__intro,.home-hero__actions,.home-hero__links) { animation-duration: 320ms; filter: none; }
@keyframes home-enter { from { opacity: 1; transform: translateY(.35rem); filter: none; } to { opacity: 1; transform: translateY(0); filter: none; } }

:where(.work-hero,.writing-hero,.tools-hero,.resume-hero,.about-hero,.contact-hero,.project-hero,.article-hero) { padding-block: clamp(4.5rem, 9vw, 8rem); }
:where(.work-hero,.writing-hero,.tools-hero,.about-hero,.contact-hero) h1 { max-width: 16ch; font-size: clamp(3.1rem, 7vw, 6.6rem); line-height: .96; letter-spacing: -.065em; text-wrap: balance; }
.writing-hero h1,.about-hero h1 { max-width: 18ch; }
.contact-hero h1 { max-width: 15ch; }
.tools-hero { min-height: auto; }

.site-footer { position: relative; overflow: hidden; padding-block: clamp(4.5rem, 8vw, 7rem) 2rem; }
.site-footer::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .28; background: linear-gradient(120deg,transparent 48%,var(--ambient-primary)); }
.site-footer > .content-shell { position: relative; }
.footer-grid { grid-template-columns: minmax(0,1.8fr) repeat(2,minmax(8rem,.6fr)); gap: clamp(2.5rem,7vw,7rem); margin-bottom: clamp(3rem,6vw,5rem); }
.footer-brand { max-width: 37rem; }
.footer-logo { font-size: clamp(1.5rem,3vw,2.35rem); }
.footer-description { margin-top: 1.35rem; max-width: 24ch; font-size: clamp(1.35rem,2.6vw,2.15rem); line-height: 1.25; letter-spacing: -.035em; color: var(--text-primary); }
.footer-links-list a { display: inline-flex; min-height: 2.4rem; align-items: center; gap: .35rem; }

.mobile-dock,.mobile-more,.no-js-mobile-nav { display: none; }
.pointer-accent { position: fixed; left: 0; top: 0; z-index: calc(var(--z-toast) + 1); width: .85rem; height: .85rem; border: 1px solid color-mix(in srgb,var(--accent) 72%,transparent); border-radius: 50%; opacity: .62; pointer-events: none; transition: opacity var(--motion-fast), width var(--motion-fast), height var(--motion-fast); }
.pointer-accent[data-quiet="true"],.pointer-accent[data-hidden="true"] { opacity: 0; }

@media (max-width: 1023px) {
  :root { --gutter-section: clamp(1rem,3.5vw,1.5rem); --gutter-chrome: clamp(.9rem,2.5vw,1.25rem); --section-space: clamp(3.5rem,14vw,5rem); }
  .has-js body { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .header-logo > span:last-child { display: inline; font-size: clamp(.82rem,2.5vw,1rem); white-space: nowrap; }
  .header-inner { min-height: 4.5rem; }
  .site-header[data-scrolled="true"] .header-inner { min-height: 4.2rem; }
  .has-js .mobile-dock { position: fixed; z-index: var(--z-sticky); left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5,1fr); padding: .35rem .35rem max(.35rem, env(safe-area-inset-bottom)); border: 1px solid var(--border-standard); border-width: 1px 0 0; border-radius: 0; color: var(--text-primary); background: var(--surface-1); box-shadow: 0 -.35rem 1.4rem rgba(0,0,0,.14); backdrop-filter: blur(12px) saturate(115%); -webkit-backdrop-filter: blur(12px) saturate(115%); }
  .mobile-dock a,.mobile-dock button { display: grid; justify-items: center; align-content: center; gap: .18rem; min-width: 0; min-height: 3.65rem; padding: .3rem .1rem; border: 0; border-radius: .75rem; color: inherit; background: transparent; font: 650 .65rem/1 var(--font-sans); text-decoration: none; }
  .mobile-dock svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-dock :where(a,button)[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
  .mobile-dock :where(a,button):focus-visible { outline: 2px solid var(--color-focus); outline-offset: -1px; }
  .mobile-more[open] { display: block; box-sizing: border-box; width: 100%; max-width: none; margin: auto 0 0; padding: .65rem 1rem calc(1rem + env(safe-area-inset-bottom)); border: 1px solid var(--border-standard); border-width: 1px 0 0; border-radius: 1.25rem 1.25rem 0 0; color: var(--text-primary); background: var(--surface-1); }
  .mobile-more::backdrop { background: rgba(3,9,18,.62); backdrop-filter: blur(3px); }
  .mobile-more__handle { width: 2.5rem; height: .22rem; margin: 0 auto .8rem; border-radius: 1rem; background: var(--border-standard); }
  .mobile-more__header { display: flex; justify-content: space-between; align-items: start; gap: 1rem; padding: .35rem .25rem 1rem; }
  .mobile-more__header p { margin: 0 0 .25rem; color: var(--text-muted); font: .68rem/1.3 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
  .mobile-more__header h2 { margin: 0; font-size: 1.35rem; }
  .mobile-more__header button { width: 2.75rem; height: 2.75rem; border: 1px solid var(--border-standard); border-radius: 50%; color: inherit; background: transparent; font-size: 1.5rem; }
  .mobile-more nav { display: grid; gap: .45rem; }
  .mobile-more nav a { display: grid; gap: .2rem; padding: .9rem; border: 1px solid var(--border-subtle); border-radius: .8rem; color: var(--text-primary); text-decoration: none; }
  .mobile-more nav a[aria-current="page"] { border-color: var(--accent); }
  .mobile-more nav span { font-weight: 700; }
  .mobile-more nav small { color: var(--text-secondary); }
  .no-js-mobile-nav { display: flex; flex-wrap: wrap; gap: .25rem .8rem; padding: .6rem var(--gutter-inline); border-bottom: 1px solid var(--border-subtle); font-size: .78rem; }
  .home-hero { min-height: auto; }
  .home-hero::after { background-size: 3rem 3rem; }
  .home-hero__content::before { display: none; }
  :where(.work-hero,.writing-hero,.tools-hero,.resume-hero,.about-hero,.contact-hero,.project-hero,.article-hero) { padding-block: clamp(3.5rem,14vw,5rem); }
  :where(.work-hero,.writing-hero,.tools-hero,.about-hero,.contact-hero) h1 { font-size: clamp(2.7rem,13.2vw,4.35rem); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
  .site-footer { padding-bottom: calc(7rem + env(safe-area-inset-bottom)); }
}

[data-theme="light"] .contact-page .form-status--error { color: #a61b1b; }

@media (min-width: 1024px) {
  .header-nav { display: flex; }
}

@media (forced-colors: active) {
  .site-header,.mobile-dock,.mobile-more { border-color: CanvasText; background: Canvas; }
  .mobile-dock :where(a,button)[aria-current="page"] { outline: 2px solid Highlight; }
  .pointer-accent,.home-hero::before,.home-hero::after,.site-footer::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  ::view-transition-old(root),::view-transition-new(root) { animation: none; }
  .reveal-item,.reveal-item.is-revealed { opacity: 1; transform: none; transition: none; }
  .pointer-accent { display: none; }
  .home-hero::before,.home-hero::after { transform: none; animation: none; }
  *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print { .mobile-dock,.mobile-more,.pointer-accent { display: none !important; } body { padding-bottom: 0 !important; } }
