/* =========================================================================
   Learning Tools — nine courses on one dark panel.
   The page stays light; the courses sit on a dark screen set into it, the
   way the AgentTape preview does above. The concept loops were drawn for a
   dark surface, so the panel restores the tokens they were written against.
   BoxArrow, the system design course, sits in the middle. Each component in
   its diagram is something another course teaches: pointing at a course
   sends a light into BoxArrow and that component answers in the course's
   colour.
   ========================================================================= */

/* The section itself is plain page; the panel carries the colour. */
/* overflow-x: clip keeps the panel's perspective, mid-lift, from ever
   widening the page, without making the section a scroll container. */
.learning { background: none; border: 0; overflow: visible; overflow-x: clip; padding: 34px 0 52px; }
.learning-head { margin-bottom: 22px; }

.lt-panel {
  /* The tokens the original concept loops were written against. */
  --surface: #11151e;
  --surface-2: #161b26;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eceef3;
  --text-dim: #a7afc0;
  --text-faint: #7c869a;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  position: relative;
  isolation: isolate;
  padding: 18px;
  border-radius: 26px;
  background:
    radial-gradient(60% 50% at 50% 0%, oklch(0.6 0.12 285 / 0.13), transparent 70%),
    radial-gradient(40% 50% at 0% 100%, oklch(0.75 0.12 212 / 0.06), transparent 70%),
    radial-gradient(40% 50% at 100% 100%, oklch(0.8 0.13 62 / 0.05), transparent 70%),
    #0c0f16;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(18, 24, 38, 0.1), 0 34px 64px -40px rgba(18, 24, 48, 0.55);
}
/* A prism line along the top edge: the nine course colours, in order. */
.lt-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 9%;
  right: 9%;
  height: 1px;
  background: linear-gradient(90deg, transparent,
    oklch(0.7 0.19 27) 12%, oklch(0.8 0.15 62) 22%, oklch(0.84 0.09 92) 32%, oklch(0.87 0.18 128) 42%,
    oklch(0.8 0.15 158) 52%, oklch(0.82 0.12 212) 62%, oklch(0.75 0.14 252) 72%, oklch(0.78 0.15 285) 82%,
    oklch(0.75 0.17 330) 90%, transparent);
  opacity: 0.7;
}

/* ---- Grid ------------------------------------------------------------- */
.lt-grid {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

/* A soft light drifts to whichever card is under the pointer and takes its
   colour, as if the panel were lit by the course you are looking at. */
.lt-grid__amb {
  position: absolute;
  z-index: -1;
  left: 0;
  top: 0;
  width: 440px;
  height: 320px;
  margin: -160px 0 0 -220px;
  border-radius: 50%;
  background: var(--amb, transparent);
  filter: blur(72px);
  opacity: 0;
  transform: translate3d(var(--ax, 0px), var(--ay, 0px), 0);
  transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1), background-color 0.6s ease;
  pointer-events: none;
}
.lt-grid.is-hovering .lt-grid__amb { opacity: 0.22; }

/* ---- Card ------------------------------------------------------------- */
.lt-card {
  --hue: oklch(var(--Ld) var(--c) var(--h));
  --viz: var(--hue);
  --ink: color-mix(in oklab, var(--hue) 84%, white);
  --line: rgba(255, 255, 255, 0.075);
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.85rem 1.1rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  background:
    radial-gradient(420px circle at var(--mx, -400px) var(--my, -400px), color-mix(in oklab, var(--hue) 7%, transparent), transparent 45%),
    radial-gradient(70% 90% at 100% 0%, color-mix(in oklab, var(--hue) 9%, transparent), transparent 62%),
    linear-gradient(180deg, color-mix(in oklab, white 2.2%, var(--surface)), var(--surface) 60%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 18px 40px -30px rgba(0, 0, 0, 0.85);
  color: inherit;
  text-decoration: none;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.35s ease, box-shadow 0.35s ease;
}

/* The lit top edge: a hairline of the card's own colour, fading at both ends. */
.lt-card::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: -1px;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hue) 28%, var(--hue) 72%, transparent);
  opacity: 0.85;
  pointer-events: none;
}

/* The border catches the pointer: a ring of the card's colour under the
   cursor, masked to the 1px border, so neighbours light at their near edge. */
.lt-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 2;
  padding: 1px;
  border-radius: inherit;
  background: radial-gradient(240px circle at var(--mx, -400px) var(--my, -400px), color-mix(in oklab, var(--hue) 85%, transparent), transparent 62%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

/* The loops are drawn inside 58px boxes with air above and below, so the
   row is 50px and the stage overflows it invisibly. */
.lt-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: 50px;
}
.lt-card__title {
  margin: 0;
  color: var(--ink);
  font: 500 1.14rem/1.2 'Space Grotesk', sans-serif;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* Each loop plays on its own small stage, lit from behind. The loops are the
   originals at their original size; only the light is new. */
.lt-card__stage {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 196px;
  height: 58px;
}
.lt-card__stage::before {
  content: "";
  position: absolute;
  inset: -10px -18px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in oklab, var(--hue) 13%, transparent), transparent);
  pointer-events: none;
}
.lt-card__stage > .viz { margin: 0; width: 100%; }
.lt-card__stage > .viz--array { width: auto; }

.lt-card__desc {
  margin: 0;
  align-self: start;
  color: var(--text-dim);
  font: 400 0.875rem/1.55 'DM Sans', sans-serif;
}

.lt-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding-top: 0.55rem;
  border-top: 1px solid color-mix(in oklab, var(--hue) 13%, var(--line));
  color: color-mix(in oklab, var(--hue) 72%, var(--text-dim));
  font: 0.72rem/1.3 var(--mono);
  letter-spacing: 0.02em;
}
.lt-card__meta { transition: color 0.3s ease, opacity 0.25s ease; }
.lt-card__go {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin-block: -4px;
  border: 1px solid color-mix(in oklab, var(--hue) 30%, var(--line));
  border-radius: 50%;
  color: var(--ink);
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.lt-card__go svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s ease; }

@media (hover: hover) {
  .lt-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in oklab, var(--hue) 30%, var(--line));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 26px 50px -30px color-mix(in oklab, var(--hue) 45%, rgba(0, 0, 0, 0.9));
  }
  .lt-card:hover .lt-card__go { background: var(--hue); border-color: var(--hue); color: #0c0f16; }
  .lt-card:hover .lt-card__go svg { transform: translate(1px, -1px); }
}
.lt-card:focus-visible { outline: 2px solid var(--hue); outline-offset: 3px; }

/* ---- The hub ----------------------------------------------------------- */
/* BoxArrow's top edge carries every course's colour, and it sits a shade
   lighter, lit from above: the system is made of the other eight. */
.lt-card--hub {
  --line: color-mix(in oklab, var(--hue) 24%, rgba(255, 255, 255, 0.09));
  background:
    radial-gradient(420px circle at var(--mx, -400px) var(--my, -400px), color-mix(in oklab, var(--hue) 8%, transparent), transparent 45%),
    radial-gradient(90% 70% at 50% 0%, color-mix(in oklab, var(--hue) 14%, transparent), transparent 70%),
    linear-gradient(180deg, #171c28, #121620 70%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 0 0 1px color-mix(in oklab, var(--hue) 8%, transparent), 0 30px 60px -34px color-mix(in oklab, var(--hue) 55%, rgba(0, 0, 0, 0.9));
}
.lt-card--hub::before {
  left: 8%;
  right: 8%;
  background: linear-gradient(90deg, transparent,
    oklch(0.82 0.12 212) 12%, oklch(0.8 0.15 62) 23%, oklch(0.87 0.18 128) 34%, oklch(0.8 0.15 158) 45%,
    oklch(0.7 0.19 27) 56%, oklch(0.76 0.14 252) 67%, oklch(0.75 0.17 330) 78%, oklch(0.84 0.09 92) 88%, transparent);
  opacity: 1;
}
.lt-card__stage--system { width: auto; flex: 1 1 auto; max-width: 240px; min-width: 0; height: 62px; margin-block: -6px; }
.lt-card__stage--system::before { inset: -14px -10px; }

/* ---- BoxArrow's diagram: a small live system --------------------------- */
.sysmap { width: 100%; max-width: 240px; height: 62px; overflow: visible; }
.sysmap .sys-edges path { stroke: color-mix(in oklab, var(--hue) 40%, var(--line)); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
.sysmap .sys-edges .sys-edge--async { stroke-dasharray: 1.6 2.6; }

.sys-node { --k: var(--hue); transition: filter 0.45s ease; }
.sys-node .sys-box {
  fill: color-mix(in oklab, var(--k) 7%, var(--surface));
  stroke: color-mix(in oklab, var(--k) 52%, var(--line));
  stroke-width: 1;
  transition: fill 0.45s ease, stroke 0.45s ease;
}
.sys-node .sys-glyph { stroke: color-mix(in oklab, var(--k) 80%, white); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.45s ease; }
.sys-node .sys-glyph--soft { stroke: color-mix(in oklab, var(--k) 45%, var(--line)); }
.sys-node--client .sys-glyph:first-of-type { fill: color-mix(in oklab, var(--k) 80%, white); stroke: none; transition: fill 0.45s ease; }
.sys-node .sys-dot { fill: color-mix(in oklab, var(--k) 80%, white); }
.sysmap .sys-div { stroke: color-mix(in oklab, var(--k) 30%, var(--line)); stroke-width: 1; }
.sysmap .sys-key { fill: color-mix(in oklab, var(--k) 45%, transparent); transition: fill 0.45s ease; }

.sys-track { fill: color-mix(in oklab, var(--k) 16%, transparent); }
.sys-load { fill: var(--k); }
.sys-x { stroke: oklch(0.7 0.19 25); stroke-width: 1.4; stroke-linecap: round; opacity: 0; transition: opacity 0.2s ease; }

/* A course answers: its component takes the course's colour and glows. */
.sys-node.is-linked { --k: var(--link); filter: drop-shadow(0 0 4px color-mix(in oklab, var(--link) 70%, transparent)); }
.sys-node.is-linked .sys-box { fill: color-mix(in oklab, var(--link) 20%, var(--surface)); stroke: var(--link); }

.sys-node.is-down .sys-box { fill: color-mix(in oklab, oklch(0.66 0.2 25) 16%, var(--surface)); stroke: oklch(0.7 0.19 25); }
.sys-node.is-down .sys-track, .sys-node.is-down .sys-load { opacity: 0; }
.sys-node.is-down .sys-x { opacity: 1; }
.sys-node.is-down .sys-glyph { stroke: oklch(0.7 0.19 25); }
.sys-node.is-back .sys-box { animation: sysBack 1s ease-out; }
.sys-node.is-fixed .sys-box { animation: sysFixed 1.2s ease-out; }
@keyframes sysBack { 0% { fill: color-mix(in oklab, var(--k) 45%, var(--surface)); stroke: white; } }
@keyframes sysFixed { 0%, 30% { fill: color-mix(in oklab, oklch(0.78 0.13 166) 40%, var(--surface)); stroke: oklch(0.82 0.13 166); } }

.sys-shard { fill: transparent; transition: fill 0.5s ease; }
.sys-shard.is-hit { fill: color-mix(in oklab, var(--k) 42%, transparent); transition: none; }
.sys-node.is-hit .sys-box { fill: color-mix(in oklab, var(--k) 30%, var(--surface)); transition: none; }
.sys-slot { fill: color-mix(in oklab, var(--k) 12%, transparent); transition: fill 0.25s ease; }
.sys-slot.is-full { fill: color-mix(in oklab, var(--k) 75%, white); }
.sys-spin { stroke: color-mix(in oklab, var(--k) 30%, var(--line)); stroke-width: 1.3; stroke-dasharray: 4 15; transform-box: fill-box; transform-origin: center; }
.sys-node.is-busy .sys-spin { stroke: color-mix(in oklab, var(--k) 85%, white); animation: sysSpin 0.7s linear infinite; }
@keyframes sysSpin { to { transform: rotate(360deg); } }

.sys-packet { fill: #f4f2ff; filter: drop-shadow(0 0 2px color-mix(in oklab, var(--hue) 90%, transparent)); }
.sys-packet--async { fill: color-mix(in oklab, var(--hue) 60%, white); }
.sys-packet--drop { fill: oklch(0.7 0.19 25); filter: none; }

/* The flight layer: lights travelling from a course into BoxArrow. Fixed to
   the viewport so it follows the cards through scroll and the panel's lift. */
.lt-flight { position: fixed; inset: 0; z-index: 30; width: 100vw; height: 100vh; pointer-events: none; }

/* ---- Entrance: the screen lifts to face you ---------------------------- */
/* The panel lies tilted back like a laptop lid and rises flat while you
   scroll toward it; scroll back and it lies down again. Once it is up, the
   top edges light in a diagonal wave and every course sends its light into
   BoxArrow. Browsers without scroll-driven animation play the lift once. */
@keyframes ltLift {
  from { transform: perspective(1700px) rotateX(24deg) translate3d(0, 70px, 0) scale(0.93); }
  to { transform: none; }
}
@media (min-width: 1240px) {
  @supports (animation-timeline: view()) {
    .lt-motion .lt-panel {
      transform-origin: 50% 0%;
      animation: ltLift linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 32%;
    }
  }
  @supports not (animation-timeline: view()) {
    .lt-motion .lt-panel { transform-origin: 50% 0%; transition: transform 1.3s cubic-bezier(0.16, 1, 0.3, 1); }
    .lt-motion .lt-panel:not(.is-up) { transform: perspective(1700px) rotateX(18deg) translate3d(0, 48px, 0) scale(0.955); }
  }
}
.lt-motion .lt-card::before { transition: transform 1s cubic-bezier(0.2, 0.8, 0.2, 1) calc(var(--d, 0) * 80ms + 120ms); }
.lt-motion .lt-grid:not(.is-in) .lt-card::before { transform: scaleX(0); }
.lt-motion .lt-card__stage { transition: opacity 0.7s ease calc(var(--d, 0) * 80ms + 240ms), filter 0.7s ease calc(var(--d, 0) * 80ms + 240ms); }
.lt-motion .lt-grid:not(.is-in) .lt-card__stage { opacity: 0; filter: blur(3px); }
.lt-grid > .lt-card:nth-of-type(2), .lt-grid > .lt-card:nth-of-type(4) { --d: 1; }
.lt-grid > .lt-card:nth-of-type(3), .lt-grid > .lt-card:nth-of-type(5), .lt-grid > .lt-card:nth-of-type(7) { --d: 2; }
.lt-grid > .lt-card:nth-of-type(6), .lt-grid > .lt-card:nth-of-type(8) { --d: 3; }
.lt-grid > .lt-card:nth-of-type(9) { --d: 4; }

/* The page's own "Motion off" switch, and the system setting, both win. */
html[data-motion="paused"] .lt-panel { animation: none !important; transform: none !important; }
html[data-motion="paused"] .lt-card::before,
html[data-motion="paused"] .lt-card__stage { transform: none !important; opacity: 1 !important; filter: none !important; }
html[data-motion="paused"] .lt-grid__amb { display: none; }
@media (prefers-reduced-motion: reduce) {
  .lt-grid__amb { display: none; }
  .sys-node.is-busy .sys-spin { animation: none; }
}

/* ---- Fitting a laptop screen -------------------------------------------- */
/* From the "Learning Tools" link, the heading and all nine cards fit one
   screen at 100% zoom: 1512×830 (14-inch MacBook), 1440×780 and 1280×720. */
@media (min-width: 1240px) and (max-height: 800px) {
  .learning { padding-top: 22px; }
  .learning-head { margin-bottom: 16px; }
  .learning-head h2 { font-size: 44px; }
  .lt-panel { padding: 14px; border-radius: 22px; }
  .lt-grid { gap: 12px; }
  .lt-card { padding: 0.72rem 1.05rem 0.7rem; gap: 0.42rem; }
  .lt-card__desc { line-height: 1.5; }
}
@media (min-width: 1240px) and (max-height: 730px) {
  .learning { padding-top: 14px; }
  .learning-head { margin-bottom: 12px; align-items: flex-end; }
  .learning-head h2 { font-size: 38px; }
  .learning-head > div:last-child p { font-size: 11.5px; }
  .lt-panel { padding: 12px; }
  .lt-card { padding: 0.66rem 1rem 0.66rem; }
  .lt-card__desc { font-size: 0.86rem; line-height: 1.46; }
}

/* ---- Narrower screens: BoxArrow leads ----------------------------------- */
/* Three columns need about 1240px for a title and its loop to sit side by
   side; below that the grid goes to two columns with BoxArrow across the
   top, then to one. */
@media (max-width: 1239px) {
  .lt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lt-card--hub { order: -1; grid-column: 1 / -1; }
  .lt-card--hub .lt-card__head { height: auto; }
  .lt-card--hub .lt-card__stage--system { max-width: 320px; height: 82px; margin-block: 0; }
  .lt-card--hub .sysmap { max-width: 320px; height: 82px; }
}
@media (max-width: 900px) {
  .lt-card__stage { width: 164px; }
}
@media (max-width: 760px) {
  .lt-panel { padding: 10px; border-radius: 20px; }
  .lt-grid { grid-template-columns: 1fr; gap: 10px; }
  .lt-card { padding: 1rem 1.05rem 0.9rem; gap: 0.6rem; }
  .lt-card__head { height: auto; flex-wrap: wrap; row-gap: 0.6rem; }
  .lt-card__stage { width: 100%; }
  .lt-card__stage > .viz { max-width: 220px; }
  .lt-card--hub .lt-card__stage--system { flex-basis: 100%; height: auto; max-width: none; }
  .lt-card--hub .sysmap { max-width: none; height: auto; aspect-ratio: 240 / 62; }
}
@media not all and (hover: hover) and (min-width: 1081px) { .lt-grid__amb { display: none; } }

/* ---- About: what I'm working on now ------------------------------------ */
/* Jelly already appears in the PetNote preview; this spot says what I am
   building at the moment instead. */
.now-note { display: flex; gap: 12px; max-width: 31ch; margin-top: 30px; color: #4f554e; font-size: 14px; line-height: 1.6; }
.now-note small { display: block; margin-bottom: 4px; color: var(--muted); font: 500 10px/1.5 'Space Grotesk', sans-serif; letter-spacing: 0.09em; }
.now-note a { color: var(--blue); border-bottom: 1px solid #294ce240; transition: border-color 0.2s ease; }
.now-note a:hover { border-color: var(--blue); }
.now-dot { position: relative; flex: none; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--blue); }
.now-dot::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--blue); animation: nowPing 2.6s cubic-bezier(0, 0, 0.2, 1) infinite; }
@keyframes nowPing { 0% { transform: scale(1); opacity: 0.5; } 75%, 100% { transform: scale(2.8); opacity: 0; } }
@media (max-width: 760px) { .now-note { margin-top: 20px; font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .now-dot::after { animation: none; } }
