/* Aperintelligence AI Academy, homepage only: what is inside each example card
   in the hero stack (partials/example-cards.html). The stack, its controls and
   the window frame are in card-stack.css, which is loaded first and whose
   colours and type sizes (--app-*) these rules use.

   Two cards are drawn in HTML and play a short sequence while they are in
   front: the build session and the builds in progress. Their finished state is
   the plain style, and every animation sits inside a no-preference media query,
   so a visitor who asks for reduced motion (site.css switches all animation
   off) sees the finished work, never an empty window. The animations hang on
   [data-depth="0"], the front card, so they start again each time a card comes
   forward, with no script. */

:root{
  /* Colours of the drawn cards: an editor's dark ground and its syntax colours. */
  --code-ground: #0B0807;
  --code-text:   #E9DED4;
  /* Light enough to pass 4.5:1 on the lit row of the rail as well as on the ground. */
  --code-dim:    #A3968C;
  --code-key:    #E4BBA3;
  --code-name:   #7FB2FF;
  --code-good:   #9CC5A6;
}

/* The cards lay themselves out by their own width, not the screen's: the card
   is half the hero on a laptop and the full width of a phone. */
.stream-card .win{container:card / inline-size;}

/* ---------- build session: a rail of five steps beside an editor ---------- */
.session{display:grid;grid-template-columns:132px minmax(0,1fr);background:var(--code-ground);color:var(--code-text);font-size:var(--app-sm);line-height:1.5;}

/* When each step starts and how long it holds the editor. A step's rail entry
   and its scene share the class, so they move together. The last one ends at
   16.2s; the card's data-dwell is a little longer than that. */
.session .beat-brief{--at:0s;--for:3s;}
.session .beat-plan{--at:3s;--for:3s;}
.session .beat-story{--at:6s;--for:3.6s;}
.session .beat-code{--at:9.6s;--for:3.6s;}
.session .beat-test{--at:13.2s;--for:3s;}

.session-rail{list-style:none;margin:0;padding:10px 8px;display:flex;flex-direction:column;gap:2px;border-right:1px solid var(--line);background:rgba(243,236,230,.03);}
.session-rail li{display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:9px;align-items:center;padding:7px 8px;border-radius:9px;}
/* The dot: filled once the step is done. */
.session-rail li::before{content:"";grid-row:1 / span 2;width:9px;height:9px;box-sizing:border-box;border-radius:50%;border:1.5px solid var(--code-good);background:var(--code-good);}
.session-rail b{font-weight:600;color:#F3ECE6;white-space:nowrap;}
.session-rail em{font-style:normal;}
.session-rail span{grid-column:2;font-size:var(--app-xs);color:var(--code-dim);}

/* The scenes share one box; the plain style shows the last one, the finished work. */
.session-editor{position:relative;min-width:0;}
.session-scene{position:absolute;inset:0;display:flex;flex-direction:column;opacity:0;}
.session-scene.beat-test{opacity:1;}
.session-tab{margin:0;padding:8px 14px;border-bottom:1px solid var(--line);font-family:var(--mono);font-size:var(--app-xs);color:var(--text-soft);}
.session-tab i{margin-left:8px;font-style:normal;color:var(--code-good);}
.session-file{flex:1;min-height:0;overflow:hidden;padding:12px 14px;}
.session-file p{margin:0;}
.session-file.code{font-family:var(--mono);font-size:var(--app-xs);line-height:1.75;white-space:nowrap;}
.session-file .indent-1{padding-left:2ch;}
.session-file .indent-2{padding-left:4ch;}
.session-note{color:var(--code-dim);}
.session-file .session-note:not(:first-child){margin-top:10px;}
.tok-key{color:var(--code-key);}
.tok-name{color:var(--code-name);}
.tok-text{color:var(--code-good);}
.tok-dim{color:var(--code-dim);}

/* A ticket: its number, its name, who has it. */
.ticket{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:10px;align-items:baseline;padding:7px 0;border-top:1px solid var(--line);}
.session-file .ticket:first-of-type{margin-top:10px;}
.ticket b{font-family:var(--mono);font-size:var(--app-xs);font-weight:500;color:var(--code-name);}
.ticket i{font-style:normal;font-size:var(--app-xs);color:var(--code-dim);}
/* An acceptance criterion: the keyword in its own column, as a feature file lines them up. */
.criterion{display:grid;grid-template-columns:6ch minmax(0,1fr);font-family:var(--mono);font-size:var(--app-xs);line-height:1.75;}
.criterion b{font-weight:500;color:var(--code-key);}
/* A passed test: a small tick drawn from two borders, then its name. */
.passed{padding-left:2ch;position:relative;color:var(--code-text);}
.passed::before{content:"";position:absolute;left:.3ch;top:.42em;width:.38em;height:.7em;border:solid var(--code-good);border-width:0 1.5px 1.5px 0;transform:rotate(40deg);}

/* The message each step hands on with, typed at the end of its scene. */
.session-prompt{margin:0 10px 10px;display:flex;align-items:center;gap:8px;padding:7px 9px;border-radius:10px;border:1px solid var(--line-strong);background:rgba(243,236,230,.04);}
.session-prompt b{flex:none;padding:2px 8px;border-radius:999px;background:rgba(228,187,163,.14);color:var(--code-key);font-size:var(--app-xs);font-weight:600;}
.session-prompt span{min-width:0;white-space:nowrap;overflow:hidden;}

/* ---------- builds in progress: a list of builds over one run of an agent workflow ---------- */
.builds{display:flex;flex-direction:column;background:var(--code-ground);color:var(--code-text);font-size:var(--app-sm);line-height:1.4;}
.builds-list{list-style:none;margin:0;padding:6px 8px 0;}
/* A build: its name and what is happening to it, a bar of the five stages, and the stage it is at. */
.builds-list li{display:grid;grid-template-columns:minmax(0,1fr) 84px 46px;column-gap:14px;align-items:center;padding:7px 8px;border-radius:9px;}
.builds-list li + li{border-top:1px solid var(--line);border-top-left-radius:0;border-top-right-radius:0;}
.builds-list .is-open{background:rgba(127,178,255,.08);}
.builds-list b{grid-column:1;font-weight:600;color:#F3ECE6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.builds-list span{grid-column:1;font-size:var(--app-xs);color:var(--code-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.builds-list i{grid-column:3;grid-row:1 / span 2;font-style:normal;font-size:var(--app-xs);color:var(--text-soft);}
/* The bar is one gradient, filled as far as --stage, cut into five by a mask. */
.builds-list li::after{content:"";grid-column:2;grid-row:1 / span 2;height:4px;border-radius:2px;
  background:linear-gradient(90deg, var(--code-good) calc(var(--stage) * 20%), var(--line-strong) 0);
  -webkit-mask:repeating-linear-gradient(90deg, #000 0 calc(20% - 3px), transparent 0 20%);
  mask:repeating-linear-gradient(90deg, #000 0 calc(20% - 3px), transparent 0 20%);}
.builds-list .stage-2{--stage:2;}
.builds-list .stage-3{--stage:3;}
.builds-list .stage-4{--stage:4;}
.builds-list .stage-5{--stage:5;}

.builds-run{margin-top:auto;padding:10px 16px 14px;border-top:1px solid var(--line);background:rgba(243,236,230,.03);}
.builds-run-head{margin:0 0 10px;display:flex;justify-content:space-between;align-items:baseline;}
.builds-run-head b{font-weight:600;color:#F3ECE6;}
.builds-run-head span{font-family:var(--mono);font-size:var(--app-xs);color:var(--code-dim);}
/* Six steps in a row, joined by a line through their dots. */
.builds-run ol{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(6, minmax(0,1fr));}
.builds-run li{position:relative;display:flex;flex-direction:column;gap:1px;padding:16px 6px 6px 0;border-radius:8px;}
.builds-run li::before{content:"";position:absolute;left:0;right:0;top:5px;height:1px;background:var(--line-strong);}
.builds-run li:last-child::before{right:auto;width:0;}
.builds-run li::after{content:"";position:absolute;left:0;top:1px;width:9px;height:9px;box-sizing:border-box;border-radius:50%;border:1.5px solid var(--code-good);background:var(--code-good);}
.builds-run i{font-style:normal;font-size:var(--app-xs);color:var(--code-dim);}
.builds-run b{font-weight:600;color:#F3ECE6;}
.builds-run span{font-size:var(--app-xs);color:var(--text-soft);}
/* --step is each step's place in the run; the animation below lights them in turn. */
.builds-run li:nth-child(2){--step:1;}
.builds-run li:nth-child(3){--step:2;}
.builds-run li:nth-child(4){--step:3;}
.builds-run li:nth-child(5){--step:4;}
.builds-run li:nth-child(6){--step:5;}

/* ---------- the sequences ---------- */
@media (prefers-reduced-motion:no-preference){
  /* Build session. Each scene holds the editor for its beat; the last one arrives and stays. */
  [data-depth="0"] .session-scene{animation:scene-hold var(--for) linear var(--at) backwards;}
  [data-depth="0"] .session-scene.beat-test{animation:scene-arrive .3s linear var(--at) backwards;}
  /* A step on the rail is quiet until its beat (a dimmer name, an open dot), lit during it, and done after. */
  [data-depth="0"] .session-rail li{animation:step-working var(--for) linear var(--at);}
  [data-depth="0"] .session-rail b{animation:step-waiting var(--at) linear backwards;}
  [data-depth="0"] .session-rail li::before{animation:step-dot-open calc(var(--at) + var(--for)) linear backwards;}
  /* Inside a scene the lines arrive one after another, then the hand-on message is typed. */
  [data-depth="0"] .session-file > *{animation:line-arrive .3s var(--ease-out) calc(var(--at) + var(--for) * (.05 + var(--line, 0) * .075)) backwards;}
  [data-depth="0"] .session-file.typed > *{animation:type-out .34s steps(24) calc(var(--at) + var(--for) * (.05 + var(--line, 0) * .075)) backwards;}
  [data-depth="0"] .session-prompt span{animation:type-out calc(var(--for) * .26) steps(28) calc(var(--at) + var(--for) * .64) backwards;}
  .session-file > :nth-child(2){--line:1;}
  .session-file > :nth-child(3){--line:2;}
  .session-file > :nth-child(4){--line:3;}
  .session-file > :nth-child(5){--line:4;}
  .session-file > :nth-child(6){--line:5;}
  .session-file > :nth-child(7){--line:6;}

  /* Builds in progress. A run passes along the six steps, over and over. Each step waits its turn in
     the plain style, so these two carry no backwards fill. */
  [data-depth="0"] .builds-run li::after{animation:step-running 7.2s linear calc(var(--step, 0) * 1.2s) infinite;}
  [data-depth="0"] .builds-run li b{animation:step-named 7.2s linear calc(var(--step, 0) * 1.2s) infinite;}
}
@keyframes scene-hold{0%,100%{opacity:0;} 6%,94%{opacity:1;}}
@keyframes scene-arrive{from{opacity:0;}}
@keyframes step-waiting{from,to{color:var(--code-dim);}}
@keyframes step-working{0%,100%{background-color:transparent;} 6%,94%{background-color:rgba(228,187,163,.13);}}
@keyframes step-dot-open{from,to{background-color:transparent;border-color:var(--code-key);}}
@keyframes line-arrive{from{opacity:0;transform:translateY(4px);}}
@keyframes type-out{from{clip-path:inset(0 100% 0 0);}}
/* One sixth of the loop each: the dot fills blue and the step's name with it, then both rest. */
@keyframes step-running{0%,15%{background-color:var(--code-name);border-color:var(--code-name);box-shadow:0 0 0 4px rgba(127,178,255,.2);} 17%,100%{background-color:var(--code-good);border-color:var(--code-good);box-shadow:none;}}
@keyframes step-named{0%,15%{color:var(--code-name);} 17%,100%{color:#F3ECE6;}}

/* ---------- the cards made from a photograph ---------- */
/* Text set over the photograph, with a wash under it on the side the text sits. */
.stream-card .page-over{position:absolute;inset:0;display:flex;flex-direction:column;align-items:flex-start;padding:14px 16px;color:#fff;}
.stream-card .wash-top{background:linear-gradient(180deg, rgba(11,8,7,.5) 0%, rgba(11,8,7,0) 55%);}
.stream-card .wash-left{justify-content:center;background:linear-gradient(90deg, rgba(11,8,7,.86) 0%, rgba(11,8,7,.6) 38%, rgba(11,8,7,0) 68%);}
.stream-card .wash-bottom{justify-content:flex-end;background:linear-gradient(0deg, rgba(11,8,7,.88) 0%, rgba(11,8,7,.5) 34%, rgba(11,8,7,0) 60%);}
.stream-card .page-brand{font-size:var(--app-sm);font-weight:600;letter-spacing:.02em;}
.stream-card .page-headline{margin-top:14px;max-width:11ch;font-size:clamp(16px, 1.12vw + 6.5px, 22.5px);font-weight:200;line-height:1.08;letter-spacing:-0.02em;}
.stream-card .page-price{font-size:clamp(20px, 1.3vw + 9px, 27px);font-weight:300;line-height:1;letter-spacing:-0.02em;}
.stream-card .page-detail{margin-top:8px;font-size:var(--app-sm);color:rgba(255,255,255,.86);}
.stream-card .page-button{margin-top:14px;padding:7px 14px;border-radius:999px;background:#fff;color:#16110E;font-size:var(--app-sm);font-weight:600;}
/* A row of choices with one picked: appointment times, party sizes. */
.stream-card .slots{display:flex;gap:6px;margin-top:12px;}
.stream-card .slots i{padding:4px 10px;border-radius:999px;border:1px solid rgba(255,255,255,.45);font-style:normal;font-size:var(--app-sm);}
.stream-card .slots i.on{background:#fff;border-color:#fff;color:#16110E;font-weight:600;}
.stream-card .swatches{position:absolute;display:flex;gap:8px;padding:7px 9px;border-radius:999px;background:rgba(11,8,7,.72);backdrop-filter:blur(6px);}
.stream-card .swatches i{width:16px;height:16px;border-radius:50%;background:#16181B;border:2px solid #F3ECE6;}
.stream-card .swatches i:nth-child(2){background:#B5452F;border-color:transparent;}
.stream-card .swatches i:nth-child(3){background:#D9D4CC;border-color:transparent;}

/* One prompt, one landing page: the prompt on the left, the page it produced on the right. */
.stream-card .prompt-result{display:grid;grid-template-columns:minmax(0,.62fr) minmax(0,1fr);}
.stream-card .prompt-pane{padding:16px 14px;background:var(--code-ground);color:var(--code-text);font-family:var(--mono);font-size:var(--app-sm);line-height:1.6;border-right:1px solid var(--line);}
.stream-card .prompt-pane b{display:block;margin-bottom:8px;font-size:var(--app-xs);font-weight:500;color:var(--highlight);}
.stream-card .prompt-pane p{margin:0;}

/* A shop: the photograph on the left, its buy panel on the right. */
.stream-card .shop{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,.6fr);background:var(--app-paper);color:var(--app-ink);}
.stream-card .shop-panel{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;padding:16px 14px;border-left:1px solid var(--app-rule);}
.stream-card .shop-name{font-size:16px;font-weight:300;letter-spacing:-0.01em;}
.stream-card .shop-price{margin-top:4px;font-size:var(--app-md);color:var(--app-quiet);}
.stream-card .shop-sizes{display:flex;gap:6px;margin-top:14px;}
.stream-card .shop-sizes i{display:grid;place-items:center;width:28px;height:28px;border-radius:8px;border:1px solid var(--app-rule);font-style:normal;font-size:var(--app-sm);}
.stream-card .shop-sizes i.on{background:var(--app-ink);border-color:var(--app-ink);color:var(--app-paper);}
.stream-card .shop .page-button{background:var(--app-ink);color:var(--app-paper);}
/* A short list in the buy panel: each line a title and its price. */
.stream-card .picks{align-self:stretch;display:flex;flex-direction:column;margin-top:10px;}
.stream-card .picks > span{display:flex;justify-content:space-between;gap:8px;padding:6px 0;border-top:1px solid var(--app-rule);font-size:var(--app-sm);}
.stream-card .picks b{font-weight:600;}
.stream-card .picks i{font-style:normal;color:var(--app-quiet);}

/* ---------- a narrow card (a phone, or a small laptop) ---------- */
@container card (max-width:430px){
  /* The rail becomes a row of five short names over the editor. */
  .session{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);}
  .session-rail{flex-direction:row;justify-content:space-between;gap:0;padding:6px;border-right:0;border-bottom:1px solid var(--line);}
  .session-rail li{column-gap:5px;padding:4px 5px;}
  .session-rail em,.session-rail span{display:none;}
  .session-file{padding:10px 12px;}
  .session-file.code,.criterion{font-size:9.5px;}
  /* Three builds, each on one line, and the six steps in two rows of three. */
  .builds-list li{grid-template-columns:minmax(0,1fr) 60px 42px;column-gap:10px;padding:6px;}
  .builds-list span,.builds-list li:nth-child(4){display:none;}
  .builds-run{padding:10px 12px 12px;}
  .builds-run ol{grid-template-columns:repeat(3, minmax(0,1fr));row-gap:8px;}
  .builds-run li:nth-child(3)::before{right:auto;width:0;}
  .stream-card .prompt-pane{font-size:var(--app-xs);padding:12px 10px;}
}
