/* TL;DR card deck (Insight Cards, PRD v2.1), only on posts with a valid cards
   block. Each card is a small CRT screen. Colours are the site's own
   (_layouts/article.html, index.html); see docs/insight-cards-design.md. */
:root{
  --ic-surface:#14100a;       /* .toc, .menu-dropdown */
  --ic-ink:#d4cfc6;           /* body text */
  --ic-ink-soft:#b8b09e;      /* .body pre code */
  --ic-accent:#ffa000;        /* amber, index.html --p */
  --ic-ink-on-accent:#0a0600; /* body background, as text on amber */
  --ic-phosphor:#ffe4a0;      /* index.html --p-text */
  --ic-serif:var(--font-text);   /* card prose and titles; assets/css/type.css */
  --ic-sans:var(--font-text);
  --ic-mono:var(--font-mono);    /* the machine voice: counter, labels, buttons */
  --ic-gutter:24px;           /* article side padding */
  --ic-card:min(80vw,400px);

  /* The screen. Amber values are index.html --p-r1/--p-r2 (255,160,60 / 210,100,0)
     and --p (255,160,0); green values are its body.green theme. */
  --ic-glass:var(--ic-surface);
  --ic-scan:rgba(0,0,0,.3);                 /* scanline, under the text */
  --ic-tube:rgba(0,0,0,.55);                /* edge darkening of the tube */
  --ic-bloom:rgba(255,160,0,.05);           /* centre of the glass */
  --ic-bezel:rgba(210,100,0,.2);            /* index.html .card border */
  --ic-bezel-on:rgba(210,100,0,.5);
  --ic-tube-r:26px / 30px;                  /* CRT face: soft, slightly elliptical corners */
  --ic-housing:#0e0b06;                     /* bezel ring, article.html pre */
  --ic-glare:rgba(255,228,160,.045);        /* reflection on the glass, index.html --p-text */
  --ic-halo:rgba(210,100,0,.3);
  --ic-title-glow:0 0 12px rgba(255,160,60,.22);
  --ic-readout-glow:0 0 6px rgba(255,160,0,.45);
  --ic-row:rgba(210,100,0,.022);            /* index.html .ci */
  --ic-row-edge:rgba(210,100,0,.18);
  --ic-row-on:rgba(210,100,0,.08);          /* index.html .ci:hover */
  --ic-row-edge-on:rgba(210,100,0,.45);
  --ic-row-rule:var(--ic-accent);
  /* The phrase being read aloud: a faint beam over its own ink. */
  --ic-spoken-glow:0 0 .6em rgba(255,160,60,.35);
}
@media(max-width:600px){:root{--ic-gutter:20px}}

.ic-switch[hidden],.ic-deck[hidden]{display:none}

/* Compact masthead. The layout adds .ic-page and leaves out the date, view
   counts and rule on carded posts, so posts without cards are untouched. */
.ic-page{padding-top:28px}
.ic-page header{margin-bottom:28px}
.ic-page header h1{margin:0}

/* The view switch: two labels in the readout type, no box. Each has a lamp:
   lit amber for the view on screen, a dim ring for the other. */
.ic-switch{
  display:flex;gap:26px;margin:0 0 10px;
  font-family:var(--ic-mono);font-size:13px;letter-spacing:.18em;line-height:1.4;text-transform:uppercase;
}
.ic-tab{
  display:flex;align-items:center;gap:9px;margin:0;padding:6px 0;cursor:pointer;white-space:nowrap;
  font:inherit;letter-spacing:inherit;text-transform:inherit;
  color:var(--ic-ink-soft);background:none;border:0;border-radius:2px;
}
.ic-tab::before{content:"";flex:none;width:7px;height:7px;border-radius:50%;box-shadow:inset 0 0 0 1px var(--ic-row-edge-on)}
.ic-tab[aria-selected="true"],.ic-discuss{color:var(--ic-accent);text-shadow:var(--ic-readout-glow)}
.ic-tab[aria-selected="true"]::before{background:var(--ic-accent);box-shadow:var(--ic-readout-glow)}
.ic-tab[aria-selected="false"]:hover{color:var(--ic-ink)}
.ic-tab[aria-selected="false"]:hover::before{box-shadow:inset 0 0 0 1px var(--ic-accent)}
.ic-tab:focus-visible,.ic-discuss:focus-visible{outline:2px solid var(--ic-accent);outline-offset:4px}

@media(max-width:600px){
  /* Tighter on phones so the first card fits on a 375x667 screen. */
  .ic-page{padding-top:16px}
  .ic-page header{margin-bottom:20px}
  .ic-switch{gap:22px;margin-bottom:8px;letter-spacing:.14em}
}

/* The comment link: the lit TL;DR tab, as far below the cards as the switch
   is above them (the rail's 30px shadow room is taken back). */
.ic-discuss{
  display:flex;align-items:center;gap:9px;width:fit-content;margin-top:-14px;padding:6px 0;
  font-family:var(--ic-mono);font-size:13px;letter-spacing:.18em;line-height:1.4;text-transform:uppercase;text-decoration:none;
}
.ic-deck[hidden]+.ic-discuss{display:none}
/* The card view has no subscribe block. */
body:has(.ic-deck:not([hidden])) #subscribe{display:none}
@media(max-width:600px){.ic-discuss{margin-top:-16px;letter-spacing:.08em}} /* one line at 375 */

/* Deck: a native scroller spanning the column plus its gutters. The current
   card snaps to the text column and the next card shows to its right. */
.ic-deck{position:relative;margin:0 calc(-1 * var(--ic-gutter))}
.ic-rail{
  --ic-in-l:max(var(--ic-gutter),env(safe-area-inset-left));
  --ic-in-r:max(var(--ic-gutter),env(safe-area-inset-right));
  display:flex;gap:18px;
  overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;
  scroll-snap-type:x mandatory;scrollbar-width:none;
  padding:6px var(--ic-in-r) 30px var(--ic-in-l); /* room for the shadow */
  scroll-padding-left:var(--ic-in-l);scroll-padding-right:var(--ic-in-r);
}
.ic-rail::-webkit-scrollbar{display:none}
.ic-deck :focus-visible{outline:2px solid var(--ic-accent);outline-offset:3px}
.ic-rail:focus-visible{outline-offset:-2px}

/* Cards: a picture tube in its bezel. The glass has the soft, slightly
   elliptical corners of a CRT face, darkens towards its edges, and carries
   scanlines and a centre bloom, all as background under the text. The bezel is
   a dark ring drawn with shadows, so it takes no layout space. The rail
   stretches every card to the tallest card's height. */
.ic-card{
  --ic-pad-top:20px;--ic-pad-x:20px;
  flex:0 0 var(--ic-card);scroll-snap-align:start;scroll-snap-stop:always;
  position:relative;display:flex;flex-direction:column;gap:10px;
  padding:var(--ic-pad-top) var(--ic-pad-x) 24px;
  background:
    radial-gradient(ellipse 70% 45% at 22% 8%,var(--ic-glare),transparent 70%), /* curved glass reflection */
    repeating-linear-gradient(to bottom,transparent 0 2px,var(--ic-scan) 2px 3px),
    radial-gradient(ellipse 110% 80% at 50% 40%,var(--ic-bloom),transparent 70%),
    var(--ic-glass);
  border:1px solid var(--ic-bezel);border-radius:var(--ic-tube-r);
  box-shadow:inset 0 0 56px var(--ic-tube),inset 0 0 14px var(--ic-tube),
    0 0 0 5px var(--ic-housing),0 0 0 6px var(--ic-bezel),0 14px 30px -8px rgba(0,0,0,.9);
  color:var(--ic-ink);font-family:var(--ic-serif);font-size:15.5px;line-height:1.65;
}
/* The lit bezel: the current card's glowing border, ring and halo, on a layer
   of its own so it can flicker by opacity alone. Shadows on a layer at inset 0
   cover the border exactly and never count as overflow. */
.ic-card::before{
  content:"";position:absolute;inset:0;pointer-events:none;border-radius:inherit;opacity:0;
  box-shadow:0 0 0 1px var(--ic-bezel-on),0 0 0 5px var(--ic-housing),0 0 0 6px var(--ic-bezel-on),0 0 30px -4px var(--ic-halo);
}
.ic-card.is-current::before{opacity:1}
/* .72 keeps every text colour, the amber counter included, above AA. The
   button is never dimmed. */
.ic-card:not(.is-current)>:not(.ic-go){opacity:.72}

/* Power-on: when a card becomes current, a dim amber line opens across the
   glass and fades (index.html crt-off, reversed). It is a layer over the
   text that ends fully transparent; the text is there from the first frame. */
.ic-card::after{
  content:"";position:absolute;inset:0;pointer-events:none;opacity:0;border-radius:inherit;
  background:linear-gradient(to bottom,transparent,var(--ic-power) 50%,transparent);
  --ic-power:rgba(255,160,60,.16);
}

/* The opening question is the same screen in the home page's green theme:
   green bezel, glass and options. Its title keeps the cards' amber phosphor. */
.ic-situation{
  --ic-bloom:rgba(0,200,0,.05);
  --ic-bezel:rgba(0,160,0,.2);
  --ic-bezel-on:rgba(0,160,0,.5);
  --ic-glare:rgba(160,232,160,.04);
  --ic-halo:rgba(0,160,0,.3);
  --ic-row:rgba(0,200,0,.022);
  --ic-row-edge:rgba(0,200,0,.18);
  --ic-row-on:rgba(0,200,0,.08);
  --ic-row-edge-on:rgba(0,200,0,.45);
  --ic-row-rule:#00c800;
  --ic-row-ink:#a0e8a0;       /* index.html body.green --p-text */
}
.ic-situation::after{--ic-power:rgba(100,255,100,.12)}

/* Counter: a terminal readout, top-right, level with the title, so every
   title starts at the same height whether or not its card has a counter. */
.ic-n{
  position:absolute;top:calc(var(--ic-pad-top) + 5px);right:var(--ic-pad-x);
  font-family:var(--ic-mono);font-size:13px;letter-spacing:.16em;line-height:1.4;
  color:var(--ic-accent);font-variant-numeric:tabular-nums;text-shadow:var(--ic-readout-glow);
}
.ic-n + .ic-title,.ic-n + .ic-knows{padding-right:44px}
.ic-title,.ic-knows{
  font-family:var(--ic-serif);font-size:20px;font-weight:700;line-height:1.3;text-wrap:balance;
  color:var(--ic-phosphor);text-shadow:var(--ic-title-glow);
}
.ic-resolves{color:var(--ic-ink-soft)}

/* Card art: an etched sketch at the foot of the glass, decorative. It takes
   the room the rail leaves under a short card (margin-top:auto), reaches into
   the side padding, and fades out at its edges so it reads as part of the
   screen rather than a picture placed on it. A background, not an <img>: an
   empty box has no intrinsic width, so it can never widen the card (iOS
   Safari sized the card to a loaded image's natural width). */
.ic-art{
  flex:none;margin:auto calc(-.5 * var(--ic-pad-x)) -6px;aspect-ratio:3/1;
  background:center bottom/contain no-repeat;
  opacity:.78;pointer-events:none;
  -webkit-mask-image:linear-gradient(90deg,transparent,black 14%,black 86%,transparent);
  mask-image:linear-gradient(90deg,transparent,black 14%,black 86%,transparent);
}

@media(min-width:601px){
  /* Fade the clipped neighbours into the page instead of cutting them off. */
  .ic-rail{
    -webkit-mask-image:linear-gradient(90deg,transparent,black var(--ic-gutter),black calc(100% - var(--ic-gutter)),transparent);
    mask-image:linear-gradient(90deg,transparent,black var(--ic-gutter),black calc(100% - var(--ic-gutter)),transparent);
  }
  .ic-card{--ic-pad-top:24px;--ic-pad-x:26px;padding-bottom:28px;gap:12px;font-size:16.5px;line-height:1.7}
  .ic-title,.ic-knows{font-size:22px}
}

/* Situation options: the home page's link rows (.ci). The selected one keeps
   the lit left rule. */
.ic-options{display:flex;flex-direction:column;gap:8px}
.ic-opt{
  position:relative;overflow:hidden;
  display:block;width:100%;text-align:left;cursor:pointer;
  padding:10px 12px 10px 14px;font:inherit;line-height:1.4;
  color:var(--ic-ink);background:var(--ic-row);
  border:1px solid var(--ic-row-edge);border-radius:0;
}
.ic-opt::before{
  content:"";position:absolute;left:0;top:0;bottom:0;width:2px;
  background:var(--ic-row-rule);transform:scaleY(0);
}
.ic-opt[aria-checked="true"]{color:var(--ic-row-ink,var(--ic-phosphor));background:var(--ic-row-on);border-color:var(--ic-row-edge-on)}
.ic-opt[aria-checked="true"]::before{transform:scaleY(1)}
@media(hover:hover){
  .ic-opt:hover{background:var(--ic-row-on);border-color:var(--ic-row-edge-on)}
  .ic-opt:hover::before{transform:scaleY(1)}
}

/* Terminal control: amber, in the readout type. */
.ic-go{
  align-self:flex-start;margin-top:4px;cursor:pointer;white-space:nowrap;
  padding:9px 20px;border:1px solid var(--ic-accent);border-radius:2px;
  font-family:var(--ic-mono);font-size:14px;letter-spacing:.14em;line-height:1.85;text-transform:uppercase;
  color:var(--ic-ink-on-accent);background:var(--ic-accent);
}
.ic-go:hover{background:transparent;color:var(--ic-accent);text-shadow:var(--ic-readout-glow)}

/* Chevrons: small square terminal keys, pointer devices only, hidden until
   the deck is hovered or a chevron has keyboard focus. */
.ic-chev{
  position:absolute;top:calc(50% - 12px);transform:translateY(-50%);z-index:1;
  display:none;align-items:center;justify-content:center;
  width:36px;height:36px;padding:0 0 2px;cursor:pointer;opacity:0;
  font-family:var(--ic-mono);font-size:22px;line-height:1;
  color:var(--ic-ink);background:var(--ic-glass);
  border:1px solid var(--ic-row-edge-on);border-radius:2px;
  box-shadow:0 2px 8px rgba(0,0,0,.6);
}
.ic-chev:hover{color:var(--ic-accent);border-color:var(--ic-accent);text-shadow:var(--ic-readout-glow)}
.ic-prev{left:4px}.ic-next{right:4px}
.ic-chev:disabled{visibility:hidden}
@media(hover:hover) and (pointer:fine){
  .ic-chev{display:flex}
  .ic-deck:hover .ic-chev,.ic-chev:focus-visible{opacity:1}
}

/* Motion: only when the reader allows it. Without it, the design above is
   the whole design: cards are lit or dimmed, with no change in between. */
@media(prefers-reduced-motion:no-preference){
  .ic-card::before{transition:opacity .25s ease}
  .ic-card.is-current::after{animation:ic-power-on .45s ease-out}
  /* The lit bezel flickers like the nav brand: brief dips on a slow step
     cycle, never more than one dip a second. */
  .ic-card.is-current::before{animation:ic-bezel-flicker 7s step-end infinite}
  .ic-opt{transition:background .2s,border-color .2s,color .2s,transform .2s}
  .ic-tab,.ic-tab::before{transition:color .2s,text-shadow .2s,background .2s,box-shadow .2s}
  .ic-opt::before{transition:transform .2s}
  @media(hover:hover){.ic-opt:hover{transform:translateX(3px)}}
}
@keyframes ic-power-on{
  0%  {opacity:1;transform:scaleY(.02)}
  45% {opacity:1;transform:scaleY(1)}
  100%{opacity:0;transform:scaleY(1)}
}
@keyframes ic-bezel-flicker{   /* _layouts/article.html brand-flicker, retimed */
  0%,100%{opacity:1}
  22%{opacity:.55}
  22.6%{opacity:1}
  58%{opacity:.8}
  58.5%{opacity:.4}
  59.2%{opacity:1}
  86%{opacity:.7}
  86.5%{opacity:1}
}

/* The article: the Full article view. The script hides it (until-found) and
   animates the switch between views. */
.ic-article{margin-top:24px}
.ic-article:focus,.ic-deck:focus{outline:none}
.ic-article [id]{scroll-margin-top:16px}
.ic-article :is(h1,h2,h3):focus{outline:none}
.ic-article :is(h1,h2,h3):focus-visible{outline:2px solid var(--ic-accent);outline-offset:4px}

.ic-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
