/* Neurosleek viewport contract.
   4K, 2560, foldables ~10:7 and ~7:10, phones ~9:16, installed web app.
   Beats later inline rules by specificity. Does not restyle brand color or type. */

/* The canvas behind the status bar and rubber-band is the theme, never a stuck white strip. */
html {
  background-color: #0b0b0b;
  color-scheme: dark;
  overflow-anchor: none;
  scroll-snap-type: y proximity !important;
}
html[data-theme="light"] {
  background-color: #f1f5f9;
  color-scheme: light;
}
html[data-theme="dark"] {
  background-color: #0b0b0b;
  color-scheme: dark;
}
body {
  background-color: #0b0b0b;
  overflow-anchor: none;
  max-width: 100%;
}
html[data-theme="light"] body {
  background-color: #f1f5f9;
}
html[data-theme="dark"] body {
  background-color: #0b0b0b;
}

/* Clip horizontal overflow once, on the app shell, so focus rings are not
   trapped by overflow:hidden on every section. */
html body #ns-app {
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
  overflow-anchor: none;
}
html body #ns-app #ns-site-frame,
html body #ns-app :is(#home, #portfolio, #who, #software-engineering, #icon-bench, #process, #testimonials, #blog, #saga, #contact) {
  min-width: 0;
  max-width: 100%;
  overflow-anchor: none;
}

/* Full-viewport routes. 100vw includes the scrollbar and shoves the page sideways. */
html body #ns-app > #ns-portfolio-route:not([hidden]) {
  width: 100% !important;
  max-width: 100% !important;
  height: 100dvh !important;
  min-height: 100svh !important;
  max-height: 100dvh !important;
  inset: 0 !important;
}
html body #ns-app > #ns-portfolio-route > #ns-portfolio-frame {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
}

/* Header stays in the safe area. The dial is not resized. */
html body #ns-app > .ns-topbar > .ns-topbar__inner {
  box-sizing: border-box !important;
  max-width: 100%;
  min-width: 0;
  padding-left: max(20px, 6vw, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(20px, 6vw, env(safe-area-inset-right, 0px)) !important;
  top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
}
html body #ns-app .ns-topbar__brand,
html body #ns-app .ns-topbar__wordmark {
  min-width: 0;
  max-width: 100%;
}
html body #ns-app > .ns-topbar > .ns-floating-menu-trigger {
  top: calc(env(safe-area-inset-top, 0px) + 28px) !important;
  left: max(20px, 6vw, env(safe-area-inset-left, 0px)) !important;
}

/* Installed iOS / Android: paint the theme through the status-bar inset. */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html,
  body {
    min-height: 100svh;
    min-height: 100dvh;
  }
  html body #ns-app > .ns-topbar > .ns-topbar__inner {
    padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
  }
  html body #ns-app > .ns-topbar > .ns-floating-menu-trigger {
    left: max(16px, env(safe-area-inset-left, 0px)) !important;
  }
  html body #ns-app :is(#home, #portfolio, #who, #software-engineering, #icon-bench, #process, #testimonials, #blog, #saga, #contact) {
    scroll-margin-top: env(safe-area-inset-top, 0px);
  }
  html body #ns-app #contact {
    padding-bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px)) !important;
  }
}

/* 4K and 2560: keep the measure centered. Titles grow a little, they do not stretch. */
@media (min-width: 2400px) {
  html body #ns-app :is(#home, #portfolio, #who, #blog, #saga, #contact) {
    padding-inline: max(72px, calc((100% - 2080px) / 2)) !important;
  }
  html body #ns-app .ns-icon-bench-inner,
  html body #ns-app .ns-software .ns-se-inner,
  html body #ns-app #ns-site-frame .screen-content {
    margin-inline: auto;
  }
  html body #ns-app #home h1 {
    font-size: clamp(88px, 3.1vw, 120px) !important;
  }
}

/* Fold landscape, about 10:7, once the desktop two-column snap is active.
   Short viewports must not clip the header or the dock under overflow:clip. */
@media (min-width: 1024px) and (max-height: 1000px) and (min-aspect-ratio: 10/7) and (max-aspect-ratio: 2/1) {
  html body #ns-app :is(#home, #portfolio, #who, #process, #testimonials, #blog, #saga, #contact) {
    padding-block: clamp(16px, 2.4svh, 36px) !important;
    padding-top: max(64px, calc(env(safe-area-inset-top, 0px) + 56px)) !important;
  }
  html body #ns-app #home h1 {
    font-size: clamp(44px, 5.2vw, 76px) !important;
  }
  html body #ns-app #portfolio .pf-copy > h2,
  html body #ns-app :is(#who, #process, #testimonials, #blog, #saga, #contact) h2 {
    font-size: clamp(40px, 5.4vw, 72px) !important;
  }
  html body #ns-app #portfolio .stage {
    width: min(100%, 46svh, 460px) !important;
    height: min(46svh, 460px) !important;
  }
  html body #ns-app #portfolio .rail {
    --u: clamp(40px, 4.2svh, 52px) !important;
  }
  html body #ns-app .ns-icon-bench {
    padding-top: max(64px, calc(env(safe-area-inset-top, 0px) + 52px)) !important;
    padding-bottom: 24px !important;
  }
  html body #ns-app .ns-software {
    padding-top: max(64px, calc(env(safe-area-inset-top, 0px) + 52px)) !important;
    padding-bottom: 28px !important;
  }
  html body #ns-app .ns-icon-bench-inner,
  html body #ns-app .ns-se-inner {
    gap: clamp(20px, 3svh, 40px) !important;
  }
}

/* Below the desktop snap: sections may grow. Portfolio was re-locked to 100svh
   and clipped the dock on short folds and tall portrait folds. */
@media (max-width: 1023px) {
  html body #ns-app #portfolio {
    height: auto !important;
    min-height: 100svh !important;
    max-height: none !important;
    overflow: visible !important;
  }
  html body #ns-app :is(#who, #process, #blog, #testimonials, #saga) {
    padding-top: max(72px, calc(env(safe-area-inset-top, 0px) + 60px)) !important;
  }
  html body #ns-app #contact {
    height: auto !important;
    min-height: 100svh !important;
    max-height: none !important;
    overflow: visible !important;
    padding-bottom: max(36px, calc(env(safe-area-inset-bottom, 0px) + 20px)) !important;
  }
}

/* Fold portrait, about 7:10 — between a phone and a tablet. */
@media (min-width: 520px) and (max-width: 980px) and (min-aspect-ratio: 6/10) and (max-aspect-ratio: 4/5) {
  html body #ns-app .ns-icon-bench-inner,
  html body #ns-app .ns-software .ns-se-inner,
  html body #ns-app .ns-se-inner {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  html body #ns-app .ns-icon-bench,
  html body #ns-app .ns-software {
    padding-inline: max(24px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)) !important;
  }
  html body #ns-app #home h1 {
    font-size: clamp(44px, 6.4vw, 68px) !important;
  }
  html body #ns-app :is(#home, #portfolio, #who, #blog, #saga, #contact) {
    padding-inline: max(28px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)) !important;
  }
  html body #ns-app #portfolio .stage {
    width: min(86vw, 46svh, 520px) !important;
    height: min(86vw, 46svh, 520px) !important;
  }
}

/* Short fold landscape that is still a single column (about 1000×700). */
@media (min-width: 840px) and (max-width: 1023px) and (max-height: 780px) and (min-aspect-ratio: 10/7) {
  html body #ns-app :is(#home, #portfolio, #who, #process, #testimonials, #blog, #saga, #contact) {
    padding-top: max(60px, calc(env(safe-area-inset-top, 0px) + 52px)) !important;
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px)) !important;
  }
  html body #ns-app #home h1 {
    font-size: clamp(40px, 6vw, 64px) !important;
  }
  html body #ns-app #portfolio .pf-copy > h2 {
    font-size: clamp(40px, 6.4vw, 60px) !important;
  }
  html body #ns-app #portfolio .stage {
    width: min(42svh, 70vw, 300px) !important;
    height: min(42svh, 70vw, 300px) !important;
  }
  html body #ns-app .ns-software,
  html body #ns-app .ns-icon-bench {
    padding-top: max(60px, calc(env(safe-area-inset-top, 0px) + 48px)) !important;
    min-height: 100svh !important;
  }
  html body #ns-app .ns-se-copy h2,
  html body #ns-app .ns-icon-bench-copy h2 {
    font-size: clamp(40px, 6vw, 60px) !important;
  }
}

/* Traditional phones, about 9:16. */
@media (max-width: 480px) {
  html body #ns-app > .ns-topbar > .ns-topbar__inner {
    gap: 8px !important;
    padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
  }
  html body #ns-app .ns-topbar__wordmark {
    width: clamp(96px, 34vw, 132px) !important;
    max-width: min(46vw, 148px);
    max-height: 26px;
  }
  html body #ns-app .ns-topbar__wordmark svg {
    width: 100% !important;
    height: auto !important;
  }
  html body #ns-app .ns-icon-bench-inner,
  html body #ns-app .ns-se-inner {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 20px !important;
  }
  html body #ns-app .ns-icon-bench,
  html body #ns-app .ns-software {
    padding-inline: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)) !important;
    padding-top: max(72px, calc(env(safe-area-inset-top, 0px) + 64px)) !important;
  }
  html body #ns-app .ns-icon-bench-copy h2,
  html body #ns-app .ns-se-copy h2 {
    font-size: clamp(36px, 11vw, 52px) !important;
  }
  html body #ns-app #home h1,
  html body #ns-app #contact h2 {
    font-size: clamp(34px, 9.6vw, 48px) !important;
  }
  html body #ns-app #portfolio .portfolio-action-row {
    align-items: flex-start;
    max-width: 100%;
  }
  html body #ns-app #portfolio .portfolio-view-cta {
    max-width: 100%;
  }
  html body #ns-app #contact .ns-footer-primary,
  html body #ns-app #contact .ns-footer-legal,
  html body #ns-app #contact .ns-footer-copyright {
    white-space: normal !important;
    flex-wrap: wrap !important;
    max-width: 100%;
  }
}

/* The word "light"/"dark" collides with the wordmark. Hide the label, not the dial. */
@media (max-width: 390px) {
  html body #ns-app .ns-theme-label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
  }
  html body #ns-app .ns-theme-dial {
    width: 36px !important;
    height: 22px !important;
  }
}
