/* Design system: shared tokens, components and effects for the home page and the redesigned pages.
   Linked after the page's own base stylesheet (site-subpage.css / portfolio.css / home.css) and before its page
   stylesheet. Behaviour lives in /assets/ds.js (effects) and /assets/ds-field.js (background field).

   The look: deep navy and brand blue with white type, mono labels, Monument headings, glass cards, one shared
   background field with ASCII glyphs and grain. Pages are a dark intro band (.ds-band), light content, and the dark
   footer; the home page is dark all the way down because it tells the story. */

:root {
  --ds-blue: #2d60e2;
  --ds-blue-bright: #3f75f5;
  --ds-blue-deep: #1f49c0;
  --ds-navy: #050e29;
  --ds-ink: #050e29;
  --ds-mist: #bcd0ff;
  --ds-r-card: 24px;
  --ds-r-tile: 16px;
  --ds-r-pill: 999px;
  --ds-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ds-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Roboto Mono", "Liberation Mono", monospace;
  --ds-font-heading: "PP Monument Extended Black", "PP Monument Fallback Black", "PP Monument Fallback Bold", "PP Monument Fallback Roboto Black", "PP Monument Fallback Roboto", "Roboto", system-ui, sans-serif;
}

/* ---------- Labels (eyebrows): mono, tracked, with a short rule */
.ds-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--ds-font-mono);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ds-mist);
}

.ds-eyebrow::before {
  content: "";
  width: 28px;
  border-top: 1px solid currentColor;
}

.ds-eyebrow--ink {
  color: var(--ds-blue);
}

/* ---------- Buttons: solid (white on dark), ghost (outline on dark), ink (navy on light), outline (on light) */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 12px 26px;
  border: 1px solid transparent;
  border-radius: var(--ds-r-pill);
  font-family: var(--font-body, "Roboto", system-ui, sans-serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Two classes outrank a page's blanket `section * { padding: 0 }` reset (only the padding needs it). */
.ds-btn.ds-btn {
  padding: 12px 26px;
}

.ds-btn:hover {
  transform: translateY(-2px);
}

.ds-btn:active {
  transform: translateY(0) scale(0.98);
}

.ds-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.ds-btn--solid {
  background: #fff;
  border-color: #fff;
  color: var(--ds-blue);
}

.ds-btn--ghost {
  background: rgba(5, 14, 41, 0.25);
  border-color: #fff;
  color: #fff;
}

.ds-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ds-btn--ink {
  background: var(--ds-ink);
  border-color: var(--ds-ink);
  color: #fff;
}

.ds-btn--ink:hover {
  background: var(--ds-blue);
  border-color: var(--ds-blue);
}

.ds-btn--outline {
  border-color: var(--ds-ink);
  color: var(--ds-ink);
}

.ds-btn--outline:hover {
  background: var(--ds-ink);
  color: #fff;
}

/* Page-level link resets (body.portfolio-page a { color: inherit }) must not recolour buttons */
a.ds-btn.ds-btn--solid { color: var(--ds-blue); }
a.ds-btn.ds-btn--ghost,
a.ds-btn.ds-btn--ink { color: #fff; }
a.ds-btn.ds-btn--outline { color: var(--ds-ink); }
a.ds-btn.ds-btn--outline:hover { color: #fff; }

/* ---------- Headline: Monument, tight; each word sits in a mask and rises into place (.w > span) */
.ds-title {
  margin: 0;
  font-family: var(--ds-font-heading);
  font-weight: 900;
  font-size: clamp(34px, 4.6vw, 64px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.ds-title .w,
.home-title .w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  /* room for descenders inside the mask, taken back so line spacing is unchanged */
  padding-bottom: 0.14em;
  margin-bottom: -0.14em;
}

.ds-title .w > span,
.home-title .w > span {
  display: inline-block;
}

.ds-lede {
  max-width: 52ch;
  margin: 0;
  font-size: clamp(16px, 1.3vw, 19px);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.92);
}

.ds-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
}

/* ---------- Dark intro band: the shared field (canvas) + grain behind a headline, lede and actions.
   Put data-navbar-on-dark on the section so the navbar turns white over it. */
.ds-band.ds-band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--ds-navy);
  color: #fff;
  padding: calc(var(--site-navbar-height, 78px) + 88px) 0 104px;
}

.ds-band__field {
  position: absolute;
  inset: 0;
  z-index: -2;
  display: block;
  width: 100%;
  height: 100%;
}

/* No WebGL: a static gradient instead of the canvas. */
.ds-band.no-gl {
  background: radial-gradient(90% 90% at 80% 20%, #3f75f5 0, #2d60e2 30%, #091a49 78%);
}

.ds-band.no-gl .ds-band__field {
  display: none;
}

/* Grain over the field, and a navy wash at the top so the navbar text always reads. */
.ds-band::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.2;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1.2 -.1'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.ds-band::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: -1;
  height: 160px;
  background: linear-gradient(to bottom, rgba(5, 14, 41, 0.85), rgba(5, 14, 41, 0));
  pointer-events: none;
}

.ds-band__inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 22px;
  max-width: 760px;
}

.ds-band .ds-title {
  text-shadow: 0 2px 24px rgba(5, 14, 41, 0.35);
}

/* ---------- Reveal on scroll (ds.js adds .rv, then .is-in when the element enters the screen).
   html.ds-js is set by an inline head snippet; html.ds-fail shows everything if ds.js never ran. */
@keyframes ds-rise {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}

@keyframes ds-word {
  from { transform: translateY(112%); }
  to { transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  /* Band entrance: plays on load, no script needed. */
  .ds-band .ds-eyebrow,
  .ds-band .ds-lede,
  .ds-band .ds-actions {
    animation: ds-rise 0.7s var(--ds-ease) both;
  }

  .ds-band .ds-eyebrow { animation-delay: 0.05s; }
  .ds-band .ds-lede { animation-delay: 0.3s; }
  .ds-band .ds-actions { animation-delay: 0.4s; }

  .ds-band .ds-title .w > span {
    animation: ds-word 0.8s var(--ds-ease) both;
    animation-delay: calc(0.05s + var(--i, 0) * 0.05s);
  }

  .ds-js:not(.ds-fail) .rv:not(.rv--words) {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.9s var(--ds-ease) var(--d, 0s), transform 0.9s var(--ds-ease) var(--d, 0s), translate 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .ds-js:not(.ds-fail) .rv.ds-pop {
    transform: translateY(40px) scale(0.96);
  }

  .ds-js:not(.ds-fail) .rv.is-in:not(.rv--words) {
    opacity: 1;
    transform: none;
  }

  .ds-js:not(.ds-fail) .rv--words .w > span {
    transform: translateY(112%);
    transition: transform 1s var(--ds-ease) calc(var(--d, 0s) + var(--i, 0) * 0.07s);
  }

  .ds-js:not(.ds-fail) .rv--words.is-in .w > span {
    transform: none;
  }
}

/* ---------- Hover lift for light cards (uses `translate` so it composes with a reveal's transform) */
.ds-lift {
  transition: translate 0.35s var(--ds-ease), box-shadow 0.35s ease;
}

.ds-lift:hover {
  translate: 0 -6px;
  box-shadow: 0 24px 48px rgba(5, 14, 41, 0.16);
}

/* ---------- Fill sweep (links): brand blue slides in from the side the pointer came from and leaves towards the
   side it exits (ds.js sets --fx/--fy and toggles .is-hot; keyboard focus fills from the left). */
.ds-sweep {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.ds-sweep::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--ds-sweep-bg, var(--ds-blue));
  transform: translate(var(--fx, -101%), var(--fy, 0%));
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.ds-sweep.is-hot::before,
.ds-sweep:focus-visible::before {
  transform: translate(0, 0);
}

.ds-sweep.no-t::before {
  transition: none;
}

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

/* ---------- ASCII reveal: the page's glyph texture shows through the card around the pointer, behind the text
   (ds.js draws the texture into --ds-ascii and sets --mx / --my). The card needs its own stacking context
   (backdrop-filter, isolation or a background). */
.ds-ascii {
  --mx: -400px;
  --my: -400px;
  position: relative;
  isolation: isolate;
}

.ds-ascii::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background-image: var(--ds-ascii, none);
  background-size: 208px 208px;
  -webkit-mask-image: radial-gradient(150px circle at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.5) 45%, rgba(0, 0, 0, 0) 75%);
  mask-image: radial-gradient(150px circle at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.5) 45%, rgba(0, 0, 0, 0) 75%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.ds-ascii:hover::after {
  opacity: 0.4;
}

@keyframes ds-ascii-shift {
  to { background-position: 104px 78px; }
}

@media (prefers-reduced-motion: no-preference) {
  /* The glyphs shimmer while the pointer is on the card. */
  .ds-ascii:hover::after {
    animation: ds-ascii-shift 2.4s steps(6) infinite;
  }
}

/* ---------- Progressive blur: a band along an edge whose blur grows towards the edge, instead of a flat fade.
   Put <span class="ds-pblur ds-pblur--l" aria-hidden="true"></span> (and --r) inside a position:relative box. */
.ds-pblur {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: clamp(48px, 9vw, 120px);
  pointer-events: none;
}

.ds-pblur--l { left: 0; --dir: to right; }
.ds-pblur--r { right: 0; --dir: to left; }

.ds-pblur,
.ds-pblur::before,
.ds-pblur::after {
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  -webkit-mask-image: linear-gradient(var(--dir), #000 0%, transparent 100%);
  mask-image: linear-gradient(var(--dir), #000 0%, transparent 100%);
}

.ds-pblur::before,
.ds-pblur::after {
  content: "";
  position: absolute;
  inset: 0;
}

.ds-pblur::before {
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  -webkit-mask-image: linear-gradient(var(--dir), #000 0%, transparent 68%);
  mask-image: linear-gradient(var(--dir), #000 0%, transparent 68%);
}

.ds-pblur::after {
  -webkit-backdrop-filter: blur(11px);
  backdrop-filter: blur(11px);
  -webkit-mask-image: linear-gradient(var(--dir), #000 0%, transparent 36%);
  mask-image: linear-gradient(var(--dir), #000 0%, transparent 36%);
}

@media (prefers-reduced-transparency: reduce) {
  .ds-pblur,
  .ds-pblur::before,
  .ds-pblur::after {
    display: none;
  }
}

/* ---------- Magic text: words go from mist to white as the sentence scrolls through (ds.js splits it) */
[data-ds-magic] {
  --mw-dim: var(--ds-mist);
  --mw-lit: #fff;
}

[data-ds-magic] .mw {
  color: var(--mw-dim);
  transition: color 0.35s ease;
}

[data-ds-magic] .mw.is-lit {
  color: var(--mw-lit);
}

/* ---------- Unfold: tilted back and a little smaller, settling flat as it scrolls to the middle of the screen.
   Uses the individual rotate/scale properties so it composes with a reveal's transform; ds.js sets --r / --s and
   the parent's perspective. */
[data-ds-unfold] {
  rotate: 1 0 0 var(--r, 0deg);
  scale: var(--s, 1);
  transform-origin: 50% 100%;
  will-change: rotate, scale;
}

/* ---------- Redesigned light pages (body.ds-page): the shared accent and section titles */
body.ds-page {
  --brand-blue: var(--ds-blue);
  --brand-blue-text: var(--ds-blue);
}

body.ds-page .section-title,
body.portfolio-page.ds-page .section-title {
  font-family: var(--ds-font-heading);
  font-weight: 900;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-transform: none;
}

/* Filters, search and links on redesigned light pages: the brand blue replaces black for the active state */
body.ds-page .tag-btn:hover {
  border-color: var(--ds-blue);
  color: var(--ds-blue);
}

body.ds-page .tag-btn.is-active,
body.ds-page .tag-toggle.has-active {
  background: var(--ds-blue);
  border-color: var(--ds-blue);
  color: #fff;
}

body.ds-page .search-box input:focus {
  box-shadow: 0 0 0 3px rgba(45, 96, 226, 0.14);
}

/* The dark band runs under the fixed navbar, so the page needs no top offset (portfolio.css adds 78px). */
body.ds-page,
body.portfolio-page.ds-page {
  padding-top: 0;
}

/* ---------- Redesigned pages: dark surfaces use the landing page's navy-blue glass instead of neutral black/grey.
   (AI cards, About stats, the shared CTA card.) Same specificity as the page rules; ds.css loads last. */

body.portfolio-page.ds-page .about-impact__stats {
  background: linear-gradient(160deg, #1f49c0 0%, #050e29 80%);
}

body.portfolio-page.ds-page .cta-card {
  background: radial-gradient(90% 120% at 85% 0%, #3f75f5 0%, rgba(63, 117, 245, 0) 60%), linear-gradient(180deg, #2d60e2 0%, #050e29 100%);
}

/* Mixed-case Monument headings on redesigned pages (CTA card, AI hub, card titles) */
body.portfolio-page.ds-page .cta-heading {
  text-transform: none;
}

/* The IMPOSSIBUILD mark is blue: on the blue card it needs a white mark on a lighter tile */

/* ---------- Calm dark section (.ds-fieldwrap): deep navy with a few large, soft blue glows, no animation. The glass
   cards below sit on it like on the landing page, without the moving field competing with the content. Plain CSS, so
   a tall section simply gets a longer gradient and nothing can end in a hard edge. */
.ds-fieldwrap {
  position: relative;
  isolation: isolate;
  color: #fff;
  background:
    radial-gradient(60% 520px at 88% 0%, rgba(45, 96, 226, 0.34), rgba(45, 96, 226, 0) 100%),
    radial-gradient(55% 640px at 6% 38%, rgba(31, 73, 192, 0.3), rgba(31, 73, 192, 0) 100%),
    radial-gradient(60% 560px at 92% 72%, rgba(45, 96, 226, 0.26), rgba(45, 96, 226, 0) 100%),
    #050b40;
}

/* The landing glass card (translucent navy, blur, hairline border) on redesigned pages */
.ds-card,
body.portfolio-page.about-page.ds-page .about-impact__stats,
body.curated-page.ds-page .cur-live__card,
body.curated-page.ds-page .cur-track,
body.curated-page.ds-page .cur-app__card {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 14, 41, 0.55);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  backdrop-filter: blur(14px) saturate(130%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 24px 60px rgba(3, 9, 28, 0.28);
}

/* Copy that sits on a field section */
.ds-fieldwrap .pill-outline {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}

/* ---------- Smooth first render: late-arriving background layers fade in rather than pop in.
   (html.ds-ready is set by ds.js; html.ds-fail by the head snippet if it never ran, so nothing stays hidden.) */
.ds-band__field { opacity: 0; transition: opacity 0.7s ease; }
html.ds-ready .ds-band__field, html.ds-fail .ds-band__field, html:not(.ds-js) .ds-band__field { opacity: 1; }
@keyframes ds-art-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .ds-hero-art { animation: ds-art-in 0.9s ease 0.2s both; }
}
@media (prefers-reduced-motion: reduce) { .ds-band__field { transition: none; } }
