/* ================================================
   DANIEL AGUILERA — v3
   Braincap tokens × bias-lit frames
   ================================================ */

/* ---------- TOKENS ----------
   Palette lifted verbatim from the Braincap design system (brand package v1.25).
   Light only: the bias lighting is a soft coloured halo on Paper. */
:root {
  /* Braincap primitives */
  --bc-cognitive-iris: #6256a7;
  --bc-deep-mind:      #17152b;
  --bc-ink:            #111114;
  --bc-slate:          #595961;
  --bc-paper:          #ffffff;
  --bc-grey-100:       #e7e5ed;
  --bc-grey-50:        #fafafb;

  /* Roles — light */
  --surface-page:  var(--bc-grey-50);
  --surface-mat:   var(--bc-paper);
  --text-strong:   var(--bc-ink);
  --text-body:     var(--bc-deep-mind);
  --text-muted:    var(--bc-slate);
  --hairline:      var(--bc-grey-100);
  --hairline-soft: rgba(0, 0, 0, 0.051);
  --focus-ring:    rgba(98, 86, 167, 0.32);
  --glow-opacity:  0.6;
  --glow-saturate: 2;
  /* the glass */
  --glass:         rgba(255, 255, 255, 0.72);
  --glass-chrome:  rgba(255, 255, 255, 0.86);
  --glass-top:     rgba(255, 255, 255, 0.95);
  --glass-line:    rgba(255, 255, 255, 0.6);
  --glass-shadow:  rgba(23, 21, 43, 0.28);
  --glass-shadow-hover: rgba(23, 21, 43, 0.34);
  --img-line:      rgba(0, 0, 0, 0.06);
  --scrim:         rgba(250, 250, 251, 0.9);

  /* Type — Outfit, the only family */
  --font: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Rhythm — Braincap's spacing: 20 / 28 / 38 / 96 */
  --space-5:  20px;
  --space-7:  28px;
  --space-9:  38px;
  --space-14: 96px;
  --gutter:   clamp(20px, 5vw, 64px);
  --frame-max: 1040px;

  --radius-xl:  20px;
  --radius-2xl: 28px;

  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --dur-slow:   320ms;
  --dur-reveal: 560ms;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: light;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 24px;
  color: var(--text-body);
  background: var(--surface-page);
  min-height: 100vh;
  padding-inline: var(--gutter);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }

::selection { background: rgba(98, 86, 167, 0.35); color: var(--text-strong); }
body, .card, .pill, .close { transition: background-color 0.4s var(--ease-out), color 0.4s var(--ease-out); }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
  border-radius: 6px;
}

/* ---------- TYPE ----------
   Four tiers, all Outfit. The name is the anchor; nothing else is heavier.
     name   15 / 500   header wordmark — the only Medium on the site
     title  17 / 400   a page's title
     body   15 / 400   running text (24px line)
     small  13 / 400   the hovered card's name; nav and toggle at 14 */
.t-title { font-size: 17px; line-height: 24px; letter-spacing: 0; font-weight: 400; }
.t-body  { font-size: 15px; line-height: 24px; font-weight: 400; }
.t-small { font-size: 13px; line-height: 20px; letter-spacing: 0.02em; font-weight: 400; }
h1, h2 { color: var(--text-strong); text-wrap: balance; }

/* ---------- HEADER ----------
   A floating glass pill, the same material as the cards. At rest it hugs
   the name; on hover it grows to the content width and the nav appears. */
.site-header {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 2000;
  max-width: var(--frame-max);
  margin-inline: auto;
  pointer-events: none;
}
.pill {
  pointer-events: auto;
  width: 100%;
  max-width: var(--collapsed, 166px);   /* just the name; site.js measures it */
  overflow: hidden;
  overflow: clip;
  padding: 9px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-7);
  border-radius: 999px;
  background: var(--glass-chrome);
  box-shadow:
    inset 0 1px 0 var(--glass-top),
    inset 0 0 0 1px var(--glass-line),
    0 1px 2px rgba(23, 21, 43, 0.05),
    0 18px 40px -20px var(--glass-shadow);
  transition: max-width 0.6s var(--ease-out);
}
.pill:hover,
.pill:focus-within,
.pill.is-open { max-width: 100%; }

/* The name, plainly: Outfit Medium, sentence case. */
.wordmark {
  font-weight: 500;
  font-size: 15px;
  line-height: 22px;
  color: var(--text-strong);
  white-space: nowrap;
}

/* The nav, quietly: three words at the right end of the open pill. */
.site-nav {
  display: flex;
  gap: var(--space-7);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.35s var(--ease-out) 0.15s, transform 0.5s var(--ease-out) 0.1s;
}
.pill:hover .site-nav,
.pill:focus-within .site-nav,
.pill.is-open .site-nav { opacity: 1; transform: none; }
.site-nav a {
  font-size: 14px;
  line-height: 22px;
  letter-spacing: 0.01em;
  font-weight: 400;
  color: var(--text-body);
  transition: color var(--dur-fast, 120ms) var(--ease-out);
}
.site-nav a:hover,
.site-nav a:focus-visible { color: var(--text-strong); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
/* Close: back to the cloud from any page. Same glass, same line as the name. */
.close {
  display: none;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: var(--gutter);
  z-index: 2001;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 999px;
  color: var(--text-strong);
  background: var(--glass-chrome);
  box-shadow:
    inset 0 1px 0 var(--glass-top),
    inset 0 0 0 1px var(--glass-line),
    0 1px 2px rgba(23, 21, 43, 0.05),
    0 18px 40px -20px var(--glass-shadow);
  transition: transform var(--dur-slow) var(--ease-out);
}
.close:hover { transform: translateY(-1px); }
.close:focus-visible { outline: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6), 0 0 0 3px var(--focus-ring); }
body.in-project .close,
body[data-state="plain"] .close { display: grid; }
/* the header pill stops short of the close button */
body.in-project .site-header,
body[data-state="plain"] .site-header { right: calc(var(--gutter) + 52px); }

.plain {
  max-width: var(--frame-max);
  margin-inline: auto;
  padding-block: calc(62px + var(--space-9)) var(--space-14);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- ADVENTURE PAGE ---------- */
.adventure {
  max-width: var(--frame-max);
  margin-inline: auto;
  padding-block: calc(62px + var(--space-9)) var(--space-14);
  display: grid;
  gap: var(--space-5);
}
/* ---------- THE CLOUD ----------
   A shallow 3D volume filling the viewport under the name. Cards are glass:
   a frosted white rim, a hairline of light on top, the picture inside, and its
   own bias light bleeding through the rim. cloud.js places and moves them. */
.cloud {
  position: relative;
  touch-action: none;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overflow: clip;
}
/* The card layer: every picture, once, above every view and under the
   chrome. Only the cards take the pointer; the layer itself is transparent
   to it, so the views behind still get background presses and wheels. */
.cards {
  position: fixed;
  inset: 0;
  z-index: 1500;
  pointer-events: none;
  overflow: hidden;
  overflow: clip;
}
.cards__space {
  position: absolute;
  inset: 0;
}
.cards .card { pointer-events: none; }        /* engine.js turns a visible card on */

.card {
  --w: 220px;
  --z: 1;
  --rim: calc(6px * var(--z));
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--w);
  aspect-ratio: var(--card-ar, 4 / 3);
  margin-left: calc(var(--w) * -0.5);
  margin-top: calc(var(--w) * -0.375);
  padding: var(--rim);
  border-radius: calc(20px * var(--z));
  background: var(--glass);
  box-shadow:
    inset 0 1px 0 var(--glass-top),
    inset 0 0 0 1px var(--glass-line),
    0 1px 2px rgba(23, 21, 43, 0.05),
    0 calc(30px * var(--z)) calc(60px * var(--z)) calc(-24px * var(--z)) var(--glass-shadow);
  will-change: transform, opacity;
  color: inherit;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: box-shadow var(--dur-slow) var(--ease-out);
}
.card.is-dragging { cursor: grabbing; }
.card.is-film { aspect-ratio: 16 / 9; margin-top: calc(var(--w) * -0.28125); cursor: default; }
.cloud.is-panning { cursor: grabbing; }
.card:hover {
  box-shadow:
    inset 0 1px 0 var(--glass-top),
    inset 0 0 0 1px var(--glass-line),
    0 2px 4px rgba(23, 21, 43, 0.06),
    0 calc(44px * var(--z)) calc(80px * var(--z)) calc(-28px * var(--z)) var(--glass-shadow-hover);
}
.card:focus-visible {
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.8),
    0 0 0 3px var(--focus-ring),
    0 44px 80px -28px rgba(23, 21, 43, 0.34);
}

/* The picture, and its light bleeding out under the glass rim. */
.card .card__img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(15px * var(--z));
  box-shadow: inset 0 0 0 1px var(--img-line);
  background: transparent;
}
.card .card__glow {
  /* A pre-blurred sample of the picture (bias-lighting.js) that reaches
     past the card: the halo, with no live filter to pay for. */
  position: absolute;
  inset: -40% -34%;
  z-index: 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s var(--ease-out) 0.3s;
}
.card .card__glow img { width: 100%; height: 100%; object-fit: cover; }
.card .card__glow.is-fallback { filter: blur(24px) saturate(2); inset: var(--rim); }
.card[data-lit] .card__glow { opacity: var(--glow-opacity); }
/* On a page you are reading, the halo is held in: at its full reach it washes
   over the line of text above the picture. */
body.in-project .card .card__glow { inset: -12% -9%; }
body.in-project .card[data-lit] .card__glow { opacity: calc(var(--glow-opacity) * 0.55); }

.js .card:not([data-lit]) .card__img { opacity: 0.001; }
.js .card .card__img { transition: opacity var(--dur-reveal) var(--ease-out); }

/* The hovered card's name, bottom left of the screen. */
.cloud__caption {
  position: fixed;
  left: var(--gutter);
  /* same text line as the toggle: its 28px bottom + 7px padding */
  bottom: calc(env(safe-area-inset-bottom, 0px) + 35px);
  z-index: 2000;
  margin: 0;
  font-size: 13px;
  line-height: 20px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-body);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  pointer-events: none;
}
.cloud__caption.is-on { opacity: 1; transform: none; }

@media (max-width: 720px) {
  .pill { padding-inline: 16px; gap: 16px; }
  .site-nav { gap: 14px; }
  .card { --rim: calc(5px * var(--z)); border-radius: calc(17px * var(--z)); }
  .card .card__img, .card .card__glow { border-radius: calc(12px * var(--z)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation: none !important; }
  .js .card:not([data-lit]) .card__img { opacity: 1; transform: none; }
}
