/* uling19 liquid glass v16 — replaces v9-v15. One layer on top of the base system:
   1 material (clearer pane, lighter cards, no per-card decoration)
   2 layout   (one content width, rows that grow with their text, larger screens used;
               the navigation bar and the AI button live inside the pane)
   3 motion   (spring curves: press and release, hover, page and card entrance, ambient light)
   4 phone    (cards sit on the live background, so they keep their own blur)
   5 dock     (lens states for uling19-dock-v3.js: nav bar and theme switches; the bar is fixed)
   6 change   (cross-fade for page and theme changes)
   Card decoration from v9 (droplet, streak, per-card blur, fixed heights) is gone on purpose. */

/* 1. material --------------------------------------------------------------- */
:root {
  --pane: rgb(9 14 30 / .30);
  --pane-filter: blur(28px) saturate(1.5);
  --pane-shadow: 0 30px 80px rgb(0 4 18 / .46), 0 2px 8px rgb(0 4 18 / .28);

  --card: linear-gradient(180deg, rgb(255 255 255 / .085), rgb(255 255 255 / .032) 56%, rgb(255 255 255 / .018));
  --card-base: rgb(22 34 68 / .14);
  --card-edge-t: rgb(255 255 255 / .34);
  --card-edge-s: rgb(255 255 255 / .13);
  --card-edge-b: rgb(255 255 255 / .05);
  --card-rim: inset 0 1px 0 rgb(255 255 255 / .10);
  --card-shadow: 0 14px 32px rgb(0 3 14 / .26), 0 2px 6px rgb(0 3 14 / .22);
  --card-rim-hi: inset 0 1px 0 rgb(255 255 255 / .16);
  --card-shadow-hi: 0 24px 48px rgb(0 3 14 / .36), 0 4px 10px rgb(0 3 14 / .24);
  --card-edge-hi: rgb(186 236 250 / .62);

  /* controls read as a bead of water: a soft pool of light under the top edge and a
     faint cool bounce along the bottom */
  --ctl-rim: inset 0 1px 0 rgb(255 255 255 / .26), inset 0 -1px 0 rgb(0 0 0 / .22),
    inset 0 12px 20px -14px rgb(255 255 255 / .20), inset 0 -10px 16px -12px rgb(126 204 255 / .12);
  --lens-rim: inset 0 1px 0 rgb(255 255 255 / .44), inset 0 -7px 10px -8px rgb(255 255 255 / .16), 0 2px 8px rgb(0 5 20 / .28);
}
html[data-theme="light"] {
  --pane: rgb(244 248 255 / .26);
  --pane-filter: blur(28px) saturate(1.7);
  --pane-shadow: 0 28px 72px rgb(40 66 116 / .18), 0 2px 8px rgb(40 66 116 / .08);

  --card: linear-gradient(180deg, rgb(255 255 255 / .46), rgb(255 255 255 / .19) 56%, rgb(255 255 255 / .13));
  --card-base: rgb(255 255 255 / .06);
  --card-edge-b: rgb(118 148 200 / .22);
  --card-shadow: 0 14px 30px rgb(40 66 116 / .13), 0 2px 6px rgb(40 66 116 / .09);
  --card-shadow-hi: 0 24px 46px rgb(40 66 116 / .20), 0 4px 9px rgb(40 66 116 / .11);

  --ctl-rim: inset 0 1px 0 rgb(255 255 255 / .98), inset 0 -1px 0 rgb(60 90 140 / .10),
    inset 0 12px 20px -14px rgb(255 255 255 / .75), inset 0 -10px 16px -12px rgb(96 150 230 / .10);
  --lens-rim: inset 0 1px 0 rgb(255 255 255 / 1), inset 0 -7px 10px -8px rgb(120 160 230 / .14), 0 2px 8px rgb(46 72 120 / .16);
}
/* the snapshot block was the one near-opaque surface on the site */
.terminal { background-image: linear-gradient(180deg, rgb(6 12 26 / .26), rgb(6 12 26 / .13)); }
html[data-theme="light"] .terminal { background-image: linear-gradient(180deg, rgb(30 58 104 / .07), rgb(30 58 104 / .035)); }

/* 2. layout ----------------------------------------------------------------- */
@media (min-width: 901px) {
  /* one design pixel may grow to 1.2 on tall screens: a 1080p window gets the 900p
     composition 20% larger instead of the same one with wider margins */
  :root { --u: clamp(.78px, calc(100vh / 900), 1.2px); }
}
/* The navigation bar sits inside the pane, where the six page marks were, and the AI
   button rests in the pane's lower-right corner (the script places it; it can be dragged).
   The pane no longer leaves a strip free under itself, so it is centred and 50px taller. */
@media (min-width: 901px) {
  :root { --pane-h: min(100dvh - 36px, 880px); }
  .slide { top: 50%; height: var(--pane-h); }
  .slide-inner { padding-bottom: 88px; }
  .footerbar { display: none; }
  .left-rail {
    bottom: calc((100dvh - var(--pane-h)) / 2 + 24px);
    background: color-mix(in srgb, var(--ctl) 70%, transparent);
    box-shadow: var(--ctl-rim), 0 8px 22px rgb(0 5 20 / .22);
  }
  html[data-theme="light"] .left-rail { box-shadow: var(--ctl-rim), 0 8px 22px rgb(46 72 120 / .14); }
  .fab { box-shadow: var(--ctl-rim), 0 8px 22px rgb(0 5 20 / .22); }
  html[data-theme="light"] .fab { box-shadow: var(--ctl-rim), 0 8px 22px rgb(46 72 120 / .14); }
}
@media (min-width: 1181px) {
  :root { --pane-h: min(100dvh - 36px, 1000px); }
  .slide { width: min(100vw - 104px, 1560px); }
}
/* every page body uses the full content width (directory and ability were capped) */
/* width:100% ignored the bleed margins of the page body and left these two grids
   52px short of the header's right edge */
.menu-grid, .ability-grid { width: auto; max-width: none; }
@media (min-width: 1181px) and (min-height: 701px) {
  .menu-grid, .ability-grid { grid-auto-rows: minmax(min-content, calc(250 * var(--u))); }
}
/* awards: both years share one row height, and a row grows with its tallest card
   instead of letting text leave the card */
.awards-board .award-cluster .awards-grid { grid-auto-rows: minmax(calc(192 * var(--u)), auto); align-items: stretch; }
.awards-board .award-cluster .award-card { height: auto; min-height: 0; }
/* narrow columns wrap the long 2025 titles onto a third line: the shared minimum
   follows, so both years stay the same height there too */
@media (min-width: 901px) and (max-width: 1180px) {
  .awards-board .award-cluster .awards-grid { grid-auto-rows: minmax(calc(210 * var(--u)), auto); }
}
@media (min-width: 901px) and (max-height: 700px) {
  .awards-board .award-cluster .awards-grid { grid-auto-rows: minmax(calc(172 * var(--u)), auto); }
}

/* 3. motion ----------------------------------------------------------------- */
/* Two springs, sampled from a damped oscillator. --spring overshoots by a fifth and
   rings once: release of a press, the lens, small marks. --spring-soft overshoots by
   a twentieth: anything large (cards lifting, a page arriving). Browsers without
   linear() get a single-overshoot bezier. */
:root {
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --spring-soft: cubic-bezier(.3, 1.22, .5, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.051, 0.179, 0.353, 0.542, 0.725, 0.886, 1.015, 1.109, 1.167, 1.193, 1.194, 1.176, 1.146, 1.11, 1.073, 1.038, 1.009, 0.987, 0.972, 0.964, 0.961, 0.963, 0.968, 0.975, 0.982, 0.989, 0.995, 1, 1.004, 1.006, 1.007, 1.008, 1.007, 1.006, 1.004, 1);
    --spring-soft: linear(0, 0.018, 0.065, 0.132, 0.214, 0.303, 0.394, 0.485, 0.572, 0.653, 0.727, 0.792, 0.85, 0.899, 0.94, 0.973, 0.999, 1.019, 1.034, 1.044, 1.051, 1.054, 1.054, 1.053, 1.05, 1.046, 1.041, 1.036, 1.032, 1.027, 1.022, 1.018, 1.014, 1.01, 1.007, 1.005, 1);
  }
}

.slide { transition: background-color .45s ease, border-color .45s ease, box-shadow .45s ease; }

/* cards: lift on hover, give under the finger, spring back on release. The press uses
   the scale property, so it composes with the lift (transform) and the entrance
   (translate) instead of replacing them. */
.menu-card, .project-card, .award-card, .paper-card, .ability-card, .ulh-card, .ulh-svc, .stat, .terminal {
  transition:
    transform .7s var(--spring-soft),
    scale .62s var(--spring),
    box-shadow .6s cubic-bezier(.22, .61, .36, 1),
    border-color .5s cubic-bezier(.22, .61, .36, 1),
    background-color .5s cubic-bezier(.22, .61, .36, 1);
}
.menu-card:active, .project-card:active, .award-card:active, .paper-card:active, .ability-card:active, .ulh-svc:active {
  scale: .972;
  transition-duration: .16s;
  transition-timing-function: cubic-bezier(.3, .7, .4, 1);
}
@media (hover: hover) and (min-width: 901px) {
  .menu-card:hover, .project-card:hover, .award-card:hover, .paper-card:hover, .ability-card:hover { scale: 1.012; }
  .menu-card:active, .project-card:active, .award-card:active, .paper-card:active, .ability-card:active { scale: .978; }
}

/* buttons and tabs: the same give and spring, smaller (their own :active transform
   already shrinks them a little; this adds the rebound). The AI button is left out:
   the script measures it while it is dragged, and a scale would skew that. */
.rail-btn, .top-theme button, .mini-btn, .ulh-btn, .close {
  transition:
    scale .56s var(--spring),
    transform .56s var(--spring),
    color .32s ease, background-color .36s ease, border-color .36s ease, box-shadow .36s ease;
}
.rail-btn:active, .top-theme button:active, .mini-btn:active, .ulh-btn:active, .close:active {
  scale: .96;
  transition-duration: .14s;
  transition-timing-function: cubic-bezier(.3, .7, .4, 1);
}
/* page marks stretch into the active pill and ring once */
.dot-nav button::before { transition: width .6s var(--spring), opacity .2s ease, background-color .2s ease; }

@media (min-width: 901px) and (prefers-reduced-motion: no-preference) {
  /* entrance: cards settle in one after another when a page opens. It animates
     translate and opacity only, so the hover lift (transform) is untouched, and
     the fill is backwards so nothing is held once it has finished. It starts from
     a readable opacity: on a machine that paints slowly the text is there at once. */
  @keyframes ul19-rise { from { opacity: .5; translate: 0 calc(16 * var(--u)); } to { opacity: 1; translate: 0 0; } }
  /* The pane itself stays still when a page opens. The script blurs the whole pane in
     (a filter over a sheet that already blurs its backdrop, repainted every frame), and
     v13 scaled it as well: the two heaviest things on the page, at the moment it most
     needs to be smooth. Both are off; the change is carried by the cross-fade (section 6)
     and by the cards settling in. */
  .slide.active { filter: none !important; }
  .slide.active :is(.menu-card, .project-card, .award-card, .ability-card, .ulh-card, .paper-card, .terminal, .stat, .cluster-head) {
    animation: ul19-rise .9s var(--spring-soft) backwards;
    animation-delay: calc(40ms + var(--ul19-i, 0) * 30ms);
  }
  .slide.active :is(.menu-card, .project-card, .award-card, .ability-card, .ulh-card, .stat):nth-child(2) { --ul19-i: 1; }
  .slide.active :is(.menu-card, .project-card, .award-card, .ability-card, .stat):nth-child(3) { --ul19-i: 2; }
  .slide.active :is(.menu-card, .project-card, .award-card, .ability-card, .stat):nth-child(4) { --ul19-i: 3; }
  .slide.active :is(.menu-card, .project-card, .ability-card):nth-child(5) { --ul19-i: 4; }
  .slide.active :is(.menu-card, .project-card, .ability-card):nth-child(6) { --ul19-i: 5; }
  .slide.active .project-card:nth-child(7) { --ul19-i: 6; }
  .slide.active .project-card:nth-child(8) { --ul19-i: 7; }
  .slide.active .project-card:nth-child(9) { --ul19-i: 8; }
  .slide.active .project-card:nth-child(10) { --ul19-i: 9; }
  .slide.active .project-card:nth-child(11) { --ul19-i: 10; }
  .slide.active .project-card:nth-child(12) { --ul19-i: 11; }
  /* second awards row follows the first; the right paper column follows the article */
  .slide.active .award-cluster:not(.award-cluster-main) .cluster-head { --ul19-i: 4; }
  .slide.active .award-cluster:not(.award-cluster-main) .award-card:nth-child(1) { --ul19-i: 4; }
  .slide.active .award-cluster:not(.award-cluster-main) .award-card:nth-child(2) { --ul19-i: 5; }
  .slide.active .award-cluster:not(.award-cluster-main) .award-card:nth-child(3) { --ul19-i: 6; }
  .slide.active .award-cluster:not(.award-cluster-main) .award-card:nth-child(4) { --ul19-i: 7; }
  .slide.active .terminal { --ul19-i: 1; }
  .slide.active .signal-grid .stat:nth-child(1) { --ul19-i: 2; }
  .slide.active .signal-grid .stat:nth-child(2) { --ul19-i: 3; }
  .slide.active .signal-grid .stat:nth-child(3) { --ul19-i: 4; }
  .slide.active .signal-grid .stat:nth-child(4) { --ul19-i: 5; }

  /* ambient light: two very soft pools drifting inside the pane. Only the layer's
     transform moves, so it is composited and costs no repaint. */
  @keyframes ul19-drift { from { transform: translate3d(-4%, -3%, 0); } to { transform: translate3d(5%, 4%, 0); } }
  .slide::after {
    content: "";
    position: absolute;
    inset: -18%;
    z-index: 0;
    pointer-events: none;
    background:
      radial-gradient(38% 34% at 24% 22%, rgb(134 220 242 / .075), transparent 72%),
      radial-gradient(42% 38% at 78% 76%, rgb(138 116 255 / .07), transparent 74%);
    animation: ul19-drift 26s ease-in-out infinite alternate;
  }
  html[data-theme="light"] .slide::after {
    background:
      radial-gradient(38% 34% at 24% 22%, rgb(255 255 255 / .34), transparent 72%),
      radial-gradient(42% 38% at 78% 76%, rgb(150 132 255 / .09), transparent 74%);
  }
}

/* 4. phone ------------------------------------------------------------------ */
@media (max-width: 900px) {
  /* no pane here: cards lie on the animated background and need their own blur */
  .menu-card, .project-card, .award-card, .paper-card, .ability-card, .ulh-card, .terminal {
    -webkit-backdrop-filter: blur(18px) saturate(1.45);
    backdrop-filter: blur(18px) saturate(1.45);
  }
  .awards-board .award-cluster .awards-grid { grid-auto-rows: minmax(132px, auto); }
  .awards-board .award-cluster .award-card { padding: 13px; gap: 7px; }
  .awards-board .award-card h3 { font-size: .92rem; line-height: 1.25; }
  .awards-board .award-card p { font-size: .76rem; line-height: 1.4; }

  /* 60px nav + 10px breathing room */
  html body #welcome ~ .deck .slide-inner { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); scroll-padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  html body .mobile-nav { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  html body .dot-nav button[data-slide] { touch-action: manipulation; }
  /* sideways drags on the tab bar belong to the lens; vertical ones still scroll */
  html body .mobile-nav .rail-btn[data-slide] { touch-action: pan-y; }
}

@media (max-width: 900px) and (prefers-reduced-motion: no-preference) {
  /* pages switch instantly here; the content settles in from just below */
  @keyframes ul19-in { from { opacity: .45; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
  .slide.active .slide-inner { animation: ul19-in .6s var(--spring-soft) backwards; }
}

/* 5. dock ------------------------------------------------------------------- */
/* The script adds .ul19-dock-on once the lens is placed; until then (and without
   the script) the active tab keeps its own pill. */
.ul19-lens {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  border-radius: 999px;
  pointer-events: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--lens) 100%, white 0%), color-mix(in srgb, var(--lens) 72%, transparent)), radial-gradient(120% 90% at 30% 0%, rgb(255 255 255 / .16), transparent 60%);
  box-shadow: var(--lens-rim);
  will-change: transform;
  transition: background-color .3s ease, box-shadow .3s ease;
}
/* the light the lens gathers while it is held */
.ul19-lens::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(90% 70% at 50% 0%, rgb(255 255 255 / .30), rgb(255 255 255 / .04) 70%);
  opacity: 0;
  transition: opacity .3s ease;
}
.ul19-dock-on .ul19-tab, .ul19-dock-on .rail-brand { position: relative; z-index: 1; }
.ul19-dock-on .ul19-tab.active { background: none; box-shadow: none; }
.top-theme.ul19-dock-on { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.ul19-dragging-lens .ul19-lens { box-shadow: var(--lens-rim), 0 10px 26px rgb(0 5 20 / .34), 0 0 0 1px rgb(255 255 255 / .10); }
.ul19-dragging-lens .ul19-lens::after { opacity: 1; }
.ul19-dragging-lens .ul19-tab { transform: none; scale: none; }
.ul19-dragging-lens .ul19-tab:not(.active):hover { background: none; }
.ul19-dragging-lens .ul19-tab.active:not(.ul19-over) { color: var(--ink-2); }
.ul19-dragging-lens .ul19-tab.ul19-over { color: var(--ink); }
/* a touch screen keeps :hover on the last tab touched, which left a second, faint pill
   behind it once the lens had moved on */
@media (hover: none) {
  .ul19-dock-on .ul19-tab:not(.active):hover { background: none; color: var(--ink-2); }
}

/* the bar is fixed in place: only the lens moves. Sideways drags belong to the lens. */
.left-rail.ul19-dock-on { touch-action: pan-y; user-select: none; -webkit-user-select: none; }

/* 6. change ----------------------------------------------------------------- */
/* uling19-dock-v3.js replays a page or theme change inside a view transition: the old
   page is held as an image and dissolves into the new one. */
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: .34s;
  animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* 7. phone: theme switch and the bottom edge ---------------------------------- */
@media (max-width: 900px) {
  /* The switch belongs in the top-right corner, beside the page label. Section 5 made it
     position:relative for the lens, which also dropped it into the text flow as a
     full-width strip with three buttons at its left end. The lens only needs a positioned
     parent, and absolute is one. */
  html body .top-theme.ul19-dock-on {
    position: absolute;
    top: 2px;
    right: 2px;
    grid-template-columns: repeat(3, minmax(46px, auto));
  }
  html body .top-theme.ul19-dock-on .ul19-tab { padding: 0 10px; }

  /* The bar sits just above the home indicator instead of a full inset plus a margin
     above it. The page ends 8px above the bar, the same gap the bar keeps from the screen
     edge, and the veil below is only as tall as the space that is left. */
  html body .mobile-nav { bottom: max(8px, calc(env(safe-area-inset-bottom, 0px) - 14px)); }
  html body #welcome ~ .deck .slide-inner {
    padding-bottom: calc(76px + max(0px, env(safe-area-inset-bottom, 0px) - 22px));
    scroll-padding-bottom: calc(76px + max(0px, env(safe-area-inset-bottom, 0px) - 22px));
  }
  html body .deck::after {
    height: calc(38px + max(0px, env(safe-area-inset-bottom, 0px) - 22px));
    background: linear-gradient(0deg, var(--base) 0, transparent);
    opacity: .7;
  }
}
