/* term.css: a macOS (Sonoma/Sequoia) Terminal.app window in dark mode, with an asciinema player inside.
   Markup and behaviour: see the top of term.js. Load after assets/player/asciinema-player.css. */

.term {
  /* window */
  --term-bar-h: 28px;
  --term-bar-bg: #353535;
  --term-bar-line: #121212;
  --term-title: rgba(255, 255, 255, 0.85);
  --term-radius: 10px;
  /* screen: Terminal's "Basic" profile in dark mode */
  --term-bg: #1e1e1e;
  --term-fg: #f2f2f2;
  --term-pad-x: 10px;
  --term-pad-y: 8px;
  --term-line: 1.2;      /* line height, the same number term.js passes to the player */
  --term-advance: 0.6;   /* a monospace cell is 0.6em wide in SF Mono, Menlo and Geist Mono */
  --term-font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Geist Mono", monospace;
  --cols: 100;
  --rows: 50;

  position: relative;
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding-top: var(--term-bar-h);
  border-radius: var(--term-radius);
  background: var(--term-bg);
  overflow: hidden;
  isolation: isolate;
  /* the 1px black outline and the deep soft shadow macOS draws under a window */
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.85),
    0 22px 70px 4px rgba(0, 0, 0, 0.56),
    0 10px 24px rgba(0, 0, 0, 0.35);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: left;
}

/* the light 1px inner border of a dark-mode window, drawn over everything */
.term::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.13);
  pointer-events: none;
  z-index: 3;
}

/* sizes the site uses, so the window has its final size before any script runs */
.term[data-cols="100"] { --cols: 100; }
.term[data-cols="136"] { --cols: 136; }
.term[data-rows="18"] { --rows: 18; }
.term[data-rows="20"] { --rows: 20; }
.term[data-rows="22"] { --rows: 22; }
.term[data-rows="28"] { --rows: 28; }
.term[data-rows="50"] { --rows: 50; }

/* title bar */
.term__bar {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--term-bar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 72px;
  background: var(--term-bar-bg);
  border-bottom: 1px solid var(--term-bar-line);
  box-sizing: border-box;
  font: 600 13px/1 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Geist", system-ui, sans-serif;
  letter-spacing: -0.003em;
  color: var(--term-title);
  user-select: none;
  z-index: 2;
}

.term__title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

/* traffic lights: 12px, 8px apart, 8px from the left edge, each with its darker rim */
.term__lights {
  position: absolute;
  left: 8px;
  top: 50%;
  display: flex;
  gap: 8px;
  transform: translateY(-50%);
}
.term__lights i {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-sizing: border-box;
  background: var(--l);
  box-shadow: inset 0 0 0 0.5px var(--rim);
}
.term__lights i:nth-child(1) { --l: #ff5f57; --rim: #e0443e; }
.term__lights i:nth-child(2) { --l: #febc2e; --rim: #dea123; }
.term__lights i:nth-child(3) { --l: #28c840; --rim: #1aab29; }

/* pause control, for recordings that loop (WCAG 2.2.2) */
.term__pause {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 22px;
  height: 18px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: rgba(255, 255, 255, 0.42);
  cursor: pointer;
  transform: translateY(-50%);
}
.term__pause:hover { color: rgba(255, 255, 255, 0.8); background: rgba(255, 255, 255, 0.08); }
.term__pause:focus-visible { outline: 2px solid #346bf1; outline-offset: 1px; color: #fff; }
.term__pause svg { width: 10px; height: 10px; fill: currentColor; }
.term__pause .term__icon-play { display: none; }
.term__pause[aria-pressed="true"] .term__icon-play { display: block; }
.term__pause[aria-pressed="true"] .term__icon-pause { display: none; }

/* screen: its aspect comes from cols and rows, so the window never changes size when the player mounts */
.term__body {
  position: relative;
  padding: var(--term-pad-y) var(--term-pad-x);
  background: var(--term-bg);
}
.term__screen {
  position: relative;
  width: 100%;
  aspect-ratio: calc(var(--cols) * var(--term-advance)) / calc(var(--rows) * var(--term-line));
  overflow: hidden;
  background: var(--term-bg);
}

/* the player, made to fill the screen without chrome. The font size comes from the screen's own size
   (container units), so it is right before the player mounts and on every resize; the player's own fit is
   off. --term-fit-advance is a little wider than the font's 0.6em so that whole-pixel glyph advances
   (Linux and Windows hinting) never push the last column out of view. */
.term__screen { container-type: size; }
.term .ap-wrapper {
  width: 100%;
  height: 100%;
  justify-content: flex-start;
  align-items: flex-start;
}
.term .ap-wrapper div.ap-player {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
  background: var(--term-bg);
}
.term pre.ap-terminal {
  --term-fit-advance: 0.62;
  font-size: min(
    calc(100cqw / (var(--cols) * var(--term-fit-advance))),
    calc(100cqh / (var(--rows) * var(--term-line)))
  ) !important;
  border-width: 0;
  font-family: var(--term-font) !important;
  cursor: default;
}
.term .ap-overlay-start,
.term .ap-overlay-loading { display: none !important; }
.term div.ap-player div.ap-control-bar {
  background: rgba(30, 30, 30, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
}
.term span.ap-progressbar span.ap-bar { background-color: rgba(255, 255, 255, 0.16); }
.term span.ap-progressbar span.ap-bar span.ap-gutter-full { background-color: #346bf1; }
.term span.ap-marker-container { display: none; }
.term .ap-wrapper:focus-visible { outline: 2px solid #346bf1; outline-offset: 2px; }

/* macOS Terminal.app's ANSI palette; colours 16 to 255 are the standard xterm cube the player computes */
.asciinema-player-theme-macos {
  --term-color-foreground: #f2f2f2;
  --term-color-background: #1e1e1e;
  --term-color-0: #000000;
  --term-color-1: #c23621;
  --term-color-2: #25bc24;
  --term-color-3: #adad27;
  --term-color-4: #492ee1;
  --term-color-5: #d338d3;
  --term-color-6: #33bbc8;
  --term-color-7: #cbcccd;
  --term-color-8: #818383;
  --term-color-9: #fc391f;
  --term-color-10: #31e722;
  --term-color-11: #eaec23;
  --term-color-12: #5833ff;
  --term-color-13: #f935f8;
  --term-color-14: #14f0f0;
  --term-color-15: #e9ebeb;
}

@media (max-width: 600px) {
  .term { --term-pad-x: 6px; --term-pad-y: 5px; --term-radius: 9px; }
  .term__bar { padding: 0 56px; font-size: 12px; }
}
