/* EKS Cluster Creation. Opened full screen or in an iframe, which cannot
   see the site's own light/dim switch, so it follows the reader's system
   preference, as the other viewers do (their controls, cards and events
   are copied here, so the series look alike). */
:root {
  --bg: #ffffff;
  --card: #ffffff;
  --border: #dfe3e8;
  --text: #22272e;
  --dim: #5f6b78;
  --accent: #326ce5;
  --btn: #f4f5f7;
  --panel: #0d2436;
  --panel-text: #eaf1f6;
  --raw: #f7f8fa;
  --flash: rgba(255, 196, 0, 0.3);
  --code-bg: #f6f8fa;
  --tf: #7b42bc;
  --aws: #d97706;
  --ok: #1f883d;
  --gone: #cf222e;
  --term-bg: #0d1117;
  --ws: #3d5a80;
  --theirs: #8a5a00;
  --net: #1a7f37;
  --iam: #c2417e;
  --term-text: #d1d7e0;
  --yk: #1b4f9c;
  --ys: #0a6b3d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1d2b;
    --card: #112b40;
    --border: #234862;
    --text: #eaf1f6;
    --dim: #9fb2c2;
    --accent: #6f9bff;
    --btn: #16374f;
    --panel: #081b29;
    --raw: #0d2233;
    --flash: rgba(255, 196, 0, 0.18);
    --code-bg: #0d2233;
    --tf: #b48ae6;
    --aws: #f0a050;
    --ok: #4ac26b;
    --gone: #ff7b72;
    --term-bg: #050c12;
  --ws: #7fa7d6;
  --theirs: #e3b341;
  --net: #4ac26b;
  --iam: #f08cbc;
    --yk: #9cc2ff;
    --ys: #8fe3a8;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.dim { color: var(--dim); font-weight: 400; }
.kv-app { padding: 0.5rem 16px 1rem; max-width: 1700px; margin: 0 auto; }
.kv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.9rem; margin: 0 0 0.45rem; }
.kv-head h1 { font-size: 1.3rem; margin: 0; letter-spacing: -0.01em; }
.kv-head p { margin: 0; color: var(--dim); font-size: 0.92rem; }
.in-viewer .kv-head { display: none; }

/* --- controls */
.kv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.6rem; }
.kv-bar .count { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; color: var(--dim); }
.kv-btn { background: var(--btn); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.35rem 0.9rem; font-size: 0.88rem; cursor: pointer; font-family: inherit; }
.kv-btn:hover:not(:disabled) { border-color: var(--accent); }
.kv-btn:disabled { opacity: 0.45; cursor: default; }
.kv-btn.play { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; min-width: 6rem; }
.kv-btn.go { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.kv-btn.tiny { padding: 0.05rem 0.45rem; font-size: 0.74rem; border-radius: 5px; }
.kv-app select { background: var(--btn); color: var(--text); border: 1px solid var(--border); border-radius: 7px;
  padding: 0.3rem 0.4rem; font-size: 0.86rem; font-family: inherit; min-width: 0; max-width: 100%; }

/* --- the stage: our AWS account (IAM over the VPC) and AWS's own account
   (the control plane) side by side, our workstation under them, the events
   on the right. Every card has a fixed size and scrolls; the stage fills
   the window. */
.ev-stage { position: relative; display: grid; gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 230px) minmax(0, 320px);
  grid-template-rows: minmax(0, 1fr) minmax(0, 160px);
  grid-template-areas: "ours theirs log" "ws ws log";
  height: max(560px, calc(100vh - 6.4rem)); }
/* Framed, the stage fills the frame under the controls, with no page scrolling */
@media (min-width: 1101px) { .in-viewer .ev-stage { height: max(520px, calc(100vh - 4.3rem)); } }
.ev-ours { grid-area: ours; } .ev-theirs { grid-area: theirs; } .ev-ws { grid-area: ws; } .ev-log { grid-area: log; }

/* An AWS account: a dashed frame around what lives in it */
.acct { position: relative; min-height: 0; min-width: 0; display: grid; gap: 10px; padding: 1.75rem 10px 10px;
  border: 3px dashed var(--fc); border-radius: 14px; background: color-mix(in srgb, var(--fc) 6%, transparent); transition: border-color 0.3s; }
.acct.here { border-color: var(--accent); }
.acct-label { position: absolute; left: 10px; top: 0.3rem; font-size: 0.78rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; color: #fff; background: var(--fc); padding: 0.08rem 0.6rem; border-radius: 6px; white-space: nowrap; }
.acct-label span { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.9; }
/* The roles stacked beside the VPC, so the node role's three policies stay in view */
.ev-ours { --fc: var(--ws); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, auto) minmax(0, 1fr);
  grid-template-areas: "rc vpc" "rn vpc"; }
.ev-theirs { --fc: var(--theirs); grid-template-rows: minmax(0, 1fr); }
.role-c { grid-area: rc; } .role-n { grid-area: rn; } .ev-vpc { grid-area: vpc; }

@media (max-width: 1100px) {
  .ev-stage { grid-template-columns: minmax(0, 1fr); height: auto;
    grid-template-rows: auto 440px 380px 440px;
    grid-template-areas: "ours" "theirs" "ws" "log"; }
  .ev-ours { grid-template-rows: auto 300px; }
  /* The cards stand one under another and the page follows the step, so
     the controls stay pinned to the top of the screen */
  .kv-bar { position: sticky; top: 0; z-index: 40; background: var(--bg); margin: 0 -16px 0.6rem; padding: 0.4rem 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
}
@media (max-width: 640px) {
  .kv-bar { gap: 0.35rem 0.5rem; }
  .kv-bar .kv-btn { padding: 0.3rem 0.7rem; }
  .kv-bar select { flex: 1 1 10rem; }
  .ev-ours { grid-template-columns: minmax(0, 1fr); grid-template-rows: 240px 240px 520px; grid-template-areas: "rc" "rn" "vpc"; }
  .ws-body { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: minmax(0, 1fr) auto; }
  .ws-body .art.you { display: none; }
}

.kv-card { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); font-size: 0.84rem;
  transition: box-shadow 0.25s, border-color 0.25s, opacity 0.4s; }
.kv-card.here { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.kv-card > header { flex: none; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.45rem 0.7rem 0.4rem; border-bottom: 1px solid var(--border); }
/* A title keeps its words: beside a button too wide for both, the button wraps under it */
.kv-card > header h2 { font-size: 0.92rem; margin: 0; flex: 1 1 auto; }
.kv-card > header h2 code { font-size: 0.72rem; color: var(--dim); font-weight: 400; margin-left: 0.3rem; }
.kv-card > header .turn { font-size: 0.8rem; padding: 0.2rem 0.6rem; animation: ev-due 1.4s ease-in-out infinite; }
@keyframes ev-due { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); } }
.kv-body { flex: 1; min-height: 0; overflow: auto; padding: 0.5rem 0.7rem; }
h3 { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); margin: 0 0 0.35rem; }
section > p, .box > p { margin: 0; }

/* --- our workstation: the picture, the terminal, our own permissions */
.ws-body { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 260px); grid-template-rows: minmax(0, 1fr); gap: 0.6rem; padding: 0.5rem; overflow: hidden; }
.art.you { display: block; align-self: end; height: min(120px, 100%); }
.art.you img { display: block; height: 100%; width: auto; }
pre.term { margin: 0; min-height: 0; overflow: auto; background: var(--term-bg); color: var(--term-text); border-radius: 8px;
  padding: 0.45rem 0.6rem; font: 0.72rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.term .cmd { color: #8fe3a8; font-weight: 700; }
pre.term .ok { color: #7ee787; font-weight: 700; }
pre.term .dimt { color: #8b949e; }
pre.term .new { background: rgba(255, 196, 0, 0.16); }
.me { min-height: 0; overflow: auto; border: 1px solid var(--border); border-left: 4px solid var(--iam); border-radius: 8px; padding: 0.35rem 0.55rem;
  background: var(--raw); font-size: 0.78rem; }
.me.empty { border-style: dashed; background: none; color: var(--dim); }
.me ul { margin: 0.2rem 0 0; padding-left: 1rem; }
.me li { margin: 0 0 0.1rem; }
.me code { font-size: 0.74rem; }
.me .key { background: color-mix(in srgb, var(--flash) 75%, transparent); border-radius: 3px; }

/* --- IAM: the two roles, each with its trust and its policies */
.role > header { border-top: 4px solid var(--iam); }
.role > header h2 { color: var(--iam); }
.role.none { border-style: dashed; }
.role.none > header { border-top-style: dashed; }
.trust, .pol { border: 1px solid var(--border); border-radius: 6px; padding: 0.2rem 0.45rem; background: var(--raw); margin-bottom: 0.25rem; font-size: 0.75rem; line-height: 1.3; }
.trust b, .pol b { display: block; font: 700 0.76rem ui-monospace, Menlo, monospace; }
.trust { border-left: 3px solid var(--dim); }
.pol { border-left: 3px solid var(--iam); }
.pol span, .trust span { color: var(--dim); }

/* A card's tooltip: a large box beside it, fixed to the window */
.role[data-tip] { cursor: help; }
.role[data-tip]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.info { color: var(--iam); font-size: 0.85rem; margin-left: 0.25rem; }
.tip { position: fixed; z-index: 70; width: min(580px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow: auto;
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-top: 4px solid var(--iam); border-radius: 10px;
  padding: 0.6rem 0.85rem; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3); font-size: 0.84rem; line-height: 1.45; pointer-events: none; }
.tip[hidden] { display: none; }
.tip h2 { margin: 0 0 0.35rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--iam); }
.tip p { margin: 0 0 0.4rem; }
.tip .main { font-weight: 600; font-size: 0.95rem; }
.tip ul.steps { margin: 0 0 0.3rem; padding-left: 1.1rem; }
.tip ul.steps ul.steps { margin: 0.1rem 0; list-style: circle; }
.tip li { margin: 0 0 0.15rem; }
.tip code { font-size: 0.92em; background: var(--code-bg); padding: 0 0.2em; border-radius: 3px; }

/* --- the VPC: two zones, a public and a private subnet in each */
.ev-vpc > header { border-top: 4px solid var(--net); }
.ev-vpc > header h2 { color: var(--net); }
.vpc-body { display: flex; flex-direction: column; gap: 0.4rem; }
.igw { align-self: center; font: 700 0.74rem ui-monospace, Menlo, monospace; padding: 0.1rem 0.6rem; border-radius: 10px; border: 2px solid var(--net);
  background: var(--card); color: var(--net); }
.zones { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem; }
.zone { border: 1px dashed var(--border); border-radius: 8px; padding: 0.3rem; display: flex; flex-direction: column; gap: 0.35rem; }
.zone > h3 { margin: 0 0 0 0.2rem; }
.sn { border: 1px solid var(--net); border-radius: 7px; padding: 0.25rem 0.4rem; background: color-mix(in srgb, var(--net) 5%, var(--card)); font-size: 0.76rem; }
.sn.priv { border-color: color-mix(in srgb, var(--net) 50%, var(--border)); background: var(--card); }
.sn > b { font-size: 0.78rem; }
.sn > b code { font-size: 0.72rem; color: var(--dim); font-weight: 400; margin-left: 0.25rem; }
.rt { display: block; font: 0.7rem ui-monospace, Menlo, monospace; color: var(--dim); }
.things { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.2rem; }
.thing { font-size: 0.72rem; padding: 0.08rem 0.4rem; border-radius: 6px; border: 1px solid var(--border); background: var(--raw); }
.thing.nat { border-color: var(--net); color: var(--net); font-weight: 700; }
.thing.eni { border-color: var(--theirs); color: var(--theirs); font-weight: 700; border-style: dashed; }
.thing.node { border: 2px solid var(--accent); font-weight: 700; }
.thing.node.ready { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.thing.node i { font-style: normal; font-weight: 400; color: var(--dim); }
.vpc-none { color: var(--dim); text-align: center; padding: 1.5rem 0.5rem; border: 2px dashed var(--border); border-radius: 8px; }

/* --- the control plane, in AWS's account */
.cp-body { display: flex; flex-direction: column; gap: 0.4rem; }
.cpbox { border: 1px solid var(--border); border-left: 4px solid var(--theirs); border-radius: 7px; padding: 0.3rem 0.5rem; background: var(--raw); font-size: 0.76rem; }
.cpbox b { display: block; font-size: 0.8rem; }
.cpbox code { font-size: 0.7rem; overflow-wrap: anywhere; }
.cpbox ul { margin: 0.15rem 0 0; padding-left: 1rem; }
.st { font-size: 0.7rem; font-weight: 700; padding: 0.02rem 0.4rem; border-radius: 9px; border: 1px solid; color: var(--ok); margin-left: 0.3rem; }
.cp-none { color: var(--dim); text-align: center; padding: 1.5rem 0.5rem; border: 2px dashed var(--border); border-radius: 8px; font-size: 0.8rem; }

/* --- the events */
.log { list-style: none; margin: 0; padding: 0; }
.log-intro { font-size: 0.84rem; line-height: 1.45; }
.log-intro p { margin: 0 0 0.4rem; }
.log-intro .main { font-weight: 600; }
.log li { border-bottom: 1px dashed var(--border); }
.log-head { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; gap: 0.4rem; align-items: baseline; padding: 0.15rem 0.3rem; cursor: pointer; }
.log-head::after { content: '▸'; color: var(--dim); font-size: 0.7rem; }
.log li.open .log-head::after { content: '▾'; }
.log-head:focus-visible { outline: 2px solid var(--accent); }
.log li:hover .log-head { background: color-mix(in srgb, var(--flash) 40%, transparent); }
.log li.now .log-head { background: color-mix(in srgb, var(--flash) 75%, transparent); }
.log li.now.open .log-body { background: color-mix(in srgb, var(--flash) 30%, transparent); }
.log-body { padding: 0.2rem 0.5rem 0.5rem 2.1rem; font-size: 0.8rem; line-height: 1.42; }
.log-body p { margin: 0 0 0.3rem; }
.log-body .main { font-weight: 600; font-size: 0.9rem; }
.log .n { color: var(--dim); font-family: ui-monospace, Menlo, monospace; font-size: 0.72rem; }
.log .scene { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); padding: 0.5rem 0.3rem 0.15rem; border-bottom: none; }
.log-body ul.steps, .log-intro ul.steps { margin: 0 0 0.35rem; padding-left: 1.05rem; list-style: disc; }
.log-body ul.steps li, .log-intro ul.steps li { border: 0; margin: 0 0 0.15rem; }
.log-body ul.steps ul.steps, .log-intro ul.steps ul.steps { margin: 0.1rem 0; list-style: circle; }
.log code, .log-intro code { font-size: 0.92em; background: var(--code-bg); padding: 0 0.2em; border-radius: 3px; }

/* --- a tour step's spotlight: what it names pulses, the rest dims */
.ev-stage.spotlight .kv-card:not(.here):not(.ev-log) { opacity: 0.35; }
.ev-stage .act { animation: ev-pulse 1.1s ease-in-out 3; outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
@keyframes ev-pulse { 50% { filter: brightness(1.12); } }

/* --- what is in the air: a message flying along its arrow */
#ev-fly { position: absolute; left: 0; top: 0; width: 0; height: 0; overflow: visible; pointer-events: none; z-index: 50; }
#ev-fly .trail { position: absolute; left: 0; top: 0; overflow: visible; }
#ev-fly .trail polyline { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 3 7; }
#ev-fly .trail path { fill: var(--accent); }
#ev-fly .msg { position: absolute; transform: translate(-50%, -50%); background: var(--panel); color: var(--panel-text);
  border-radius: 6px; padding: 0.12rem 0.5rem; font-size: 0.74rem; font-weight: 600; white-space: nowrap;
  font-family: ui-monospace, Menlo, Consolas, monospace; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); }
#ev-fly .msg.doc { background: #fffdf4; color: #22272e; border: 1px solid #c9b98a; border-radius: 3px 10px 3px 3px; font-size: 0.78rem; }
