/* =====================================================================
   Krastes: a pixel desktop. Windows-XP style windows, dark azure palette.
   Pixelify Sans (SIL OFL 1.1) is self-hosted in lib/fonts.
   ===================================================================== */

/* One file with Latin + Cyrillic. It is Google's build of Pixelify Sans with a
   single fix: the font draws Cyrillic О and П but never maps them, so U+041E and
   U+041F are pointed at the existing O and Pi outlines (see lib/fonts/README.txt). */
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: block;
  src: url('lib/fonts/pixelify-sans.woff2') format('woff2');
}

:root {
  color-scheme: dark;

  /* ---- Dark azure palette ---- */
  --desk: #040d18;        /* behind the windows */
  --ink: #050e1a;         /* window interior */
  --ink-2: #071727;       /* sunken fields */
  --ink-3: #0c2640;       /* raised bits: tags, buttons */

  --line: #12395f;        /* quiet hairlines */
  --line-2: #1b5384;      /* stronger hairlines */

  /* Window chrome: XP "Luna", pulled down into dark azure */
  --frame: #1d5f98;
  --frame-dark: #0b2c4d;
  --bar-hi: #6bbcf2;
  --bar-1: #2f82c3;
  --bar-2: #2271b2;
  --bar-3: #1c639e;
  --bar-lo: #134a7d;

  --text: #cfe8fb;
  --text-dim: #7cafd8;
  --text-faint: #5a8db8;
  --accent: #7fd0ff;
  --accent-hot: #d2efff;
  --sel: #2b7cbf;         /* XP-style selection blue */

  /* Visualiser colours: read by visualizer.js */
  --viz-low: #1b69aa;
  --viz-high: #8fdcff;
  --viz-cap: #dff5ff;

  --font: 'Pixelify Sans', 'Courier New', monospace;

  --fw: 3px;              /* window frame thickness */
  --bar-h: 1.75rem;       /* title bar height */
  --gap: 0.4rem;          /* space between windows */
  --tray-h: 2.3rem;

  /* Custom cursors. Both keep a keyword fallback, so a missing or broken
     file degrades to the system cursor instead of dropping the rule. */
  --cursor-normal: url('lib/imgs/cursor/normal.cur'), auto;
  --cursor-interact: url('lib/imgs/cursor/interact.cur'), pointer;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* The whole UI is sized in rem, so the mosaic scales with the screen */
  font-size: clamp(14px, 0.6vw + 7px, 26px);
  cursor: var(--cursor-normal);
  background: var(--desk);
  -webkit-text-size-adjust: 100%;
}

/* With three columns the mosaic is meant to fill the screen like a desktop, so on
   a short screen the type scales down with the height as well. 44 is the height
   of the tallest layout in rem (43.6 measured) plus a little air; below ~12px the
   pixel font stops being readable, so there the page scrolls instead. */
@media (min-width: 1001px) {
  html {
    font-size: clamp(12px, min(0.6vw + 7px, (100vh - 4px) / 44), 26px);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
  background-color: var(--desk);
  /* faint pixel dither on the desktop */
  background-image:
    linear-gradient(45deg, rgba(79, 160, 224, 0.06) 25%, transparent 25%, transparent 75%, rgba(79, 160, 224, 0.06) 75%),
    linear-gradient(45deg, rgba(79, 160, 224, 0.06) 25%, transparent 25%, transparent 75%, rgba(79, 160, 224, 0.06) 75%);
  background-size: 4px 4px;
  background-position: 0 0, 2px 2px;
}

button,
input {
  font: inherit;
  color: inherit;
}

svg {
  fill: currentColor;
}

/* The sprite only holds <symbol>s: it never takes space */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

::selection {
  color: #fff;
  background: var(--sel);
}

/* One dotted focus ring everywhere, like XP */
:focus-visible {
  outline: 1px dotted var(--accent-hot);
  outline-offset: 2px;
}

a,
button:not(:disabled),
label.vol,
input[type='range'] {
  cursor: var(--cursor-interact);
}

/* ===== Desktop: the tight mosaic =====
   Same composition as the reference: two tall picture windows (left, right)
   interlocked with a column of small ones, row boundaries shared by all columns. */
.desktop {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--gap);
  padding: var(--gap);
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto minmax(min-content, 1fr) auto;
  grid-template-areas:
    'me      audio  tools'
    'me      about  photo'
    'skills  links  photo';
}

.win--me     { grid-area: me; }
.win--audio  { grid-area: audio; }
.win--tools  { grid-area: tools; }
.win--about  { grid-area: about; }
.win--photo  { grid-area: photo; }
.win--skills { grid-area: skills; }
.win--links  { grid-area: links; }

/* ===== Window =====
   XP "Luna" anatomy: gradient title bar, thick blue frame, stair-stepped top
   corners (the pixel version of XP's rounded ones). */
.win {
  --s: 2px; /* one step of the stair-cut corner */
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 var(--fw) var(--fw);
  background: var(--frame);
  box-shadow:
    inset 1px 0 0 rgba(255, 255, 255, 0.16),
    inset -1px 0 0 rgba(0, 0, 0, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45);
  clip-path: polygon(
    0 calc(var(--s) * 3),
    var(--s) calc(var(--s) * 3),
    var(--s) calc(var(--s) * 2),
    calc(var(--s) * 2) calc(var(--s) * 2),
    calc(var(--s) * 2) var(--s),
    calc(var(--s) * 3) var(--s),
    calc(var(--s) * 3) 0,
    calc(100% - var(--s) * 3) 0,
    calc(100% - var(--s) * 3) var(--s),
    calc(100% - var(--s) * 2) var(--s),
    calc(100% - var(--s) * 2) calc(var(--s) * 2),
    calc(100% - var(--s)) calc(var(--s) * 2),
    calc(100% - var(--s)) calc(var(--s) * 3),
    100% calc(var(--s) * 3),
    100% 100%,
    0 100%
  );
}

.win__bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.45rem;
  height: var(--bar-h);
  /* the bar runs over the frame, edge to edge */
  margin: 0 calc(var(--fw) * -1);
  padding: 0 0.3rem 0 0.55rem;
  color: #fff;
  background: linear-gradient(
    180deg,
    var(--bar-hi) 0,
    var(--bar-1) 9%,
    var(--bar-2) 46%,
    var(--bar-3) 88%,
    var(--bar-lo) 100%
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  user-select: none;
}

.win__icon {
  flex: none;
  width: 1rem;
  height: 1rem;
  color: #e6f5ff;
  filter: drop-shadow(1px 1px 0 rgba(4, 28, 56, 0.7));
}

.win__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 1px 1px 0 rgba(4, 28, 56, 0.85);
}

.win__ctl {
  display: flex;
  flex: none;
  gap: 2px;
}

/* Minimise / maximise / close. Maximise is disabled, as on any fixed-size XP window. */
.ctl {
  display: grid;
  place-items: center;
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  color: #fff;
  background: linear-gradient(135deg, #8ccaf5 0%, #4a98d6 38%, #2c78b8 70%, #3a89c8 100%);
  border: 1px solid #dff1ff;
  border-radius: 3px;
  box-shadow: inset -1px -1px 0 rgba(6, 40, 86, 0.55);
}

.ctl svg {
  width: 0.5rem;
  height: 0.5rem;
  filter: drop-shadow(1px 1px 0 rgba(6, 40, 86, 0.65));
}

.ctl:hover {
  filter: brightness(1.2);
}

.ctl:active {
  filter: brightness(0.82);
}

.ctl:disabled {
  opacity: 0.45;
  filter: saturate(0.4);
}

.ctl--close:hover,
.ctl--close:focus-visible {
  filter: none;
  background: linear-gradient(135deg, #f6b49a 0%, #de6a43 45%, #c04a22 100%);
  border-color: #ffe8de;
}

.win__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.75rem 0.85rem;
  overflow: auto;
  color: var(--text);
  background: var(--ink);
  border: 1px solid var(--frame-dark);
}

/* Picture windows: the image runs right to the frame */
.win__body--flush {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* Minimised: only the title bar stays, the desktop shows through below it */
.win.is-collapsed {
  align-self: start;
}

.win.is-collapsed .win__body {
  display: none;
}

/* Closed: the hole stays where the window was, until the tray brings it back */
.win.is-closed {
  visibility: hidden;
}

/* While script.js rolls a window up or down, or sends it to the tray, the body
   is cropped instead of squeezed, so no scroll bars flicker in the middle of a move */
.win.is-animating,
.win.is-animating .win__body {
  overflow: hidden;
}

/* ===== Picture placeholders =====
   A checkerboard with a label. To use a real picture, put an <img> inside the
   .shot (see the comments in index.html); it covers the placeholder. */
.shot {
  --cell: 8px;
  position: relative;
  display: grid;
  flex: 1 1 auto;
  place-content: center;
  justify-items: center;
  gap: 0.55rem;
  min-height: 10rem;
  overflow: hidden;
  color: var(--text-dim);
  background-color: #061425;
  background-image:
    linear-gradient(45deg, #0a2038 25%, transparent 25%, transparent 75%, #0a2038 75%),
    linear-gradient(45deg, #0a2038 25%, transparent 25%, transparent 75%, #0a2038 75%);
  background-size: calc(var(--cell) * 2) calc(var(--cell) * 2);
  background-position: 0 0, var(--cell) var(--cell);
}

.shot::before {
  content: '';
  width: 2.4rem;
  height: 2.4rem;
  background: currentColor;
  opacity: 0.8;
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2012%2012%22%20shape-rendering=%22crispEdges%22%3E%3Cpath%20d=%22M1%201h10v1h-10zM1%202h1v1h-1zM10%202h1v1h-1zM1%203h1v1h-1zM3%203h2v1h-2zM10%203h1v1h-1zM1%204h1v1h-1zM3%204h2v1h-2zM10%204h1v1h-1zM1%205h1v1h-1zM6%205h1v1h-1zM10%205h1v1h-1zM1%206h1v1h-1zM5%206h3v1h-3zM9%206h2v1h-2zM1%207h1v1h-1zM4%207h5v1h-5zM10%207h1v1h-1zM1%208h1v1h-1zM3%208h8v1h-8zM1%209h10v1h-10z%22/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2012%2012%22%20shape-rendering=%22crispEdges%22%3E%3Cpath%20d=%22M1%201h10v1h-10zM1%202h1v1h-1zM10%202h1v1h-1zM1%203h1v1h-1zM3%203h2v1h-2zM10%203h1v1h-1zM1%204h1v1h-1zM3%204h2v1h-2zM10%204h1v1h-1zM1%205h1v1h-1zM6%205h1v1h-1zM10%205h1v1h-1zM1%206h1v1h-1zM5%206h3v1h-3zM9%206h2v1h-2zM1%207h1v1h-1zM4%207h5v1h-5zM10%207h1v1h-1zM1%208h1v1h-1zM3%208h8v1h-8zM1%209h10v1h-10z%22/%3E%3C/svg%3E") center / contain no-repeat;
}

.shot::after {
  content: attr(data-label);
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  background: var(--ink);
  border: 1px solid var(--line-2);
}

.shot > img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Krastes window caption ===== */
.caption {
  flex: none;
  padding: 0.55rem 0.75rem 0.6rem;
  text-align: center;
  background: var(--ink);
  border-top: 1px solid var(--line-2);
}

.caption__quote {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
  text-wrap: balance;
}

.caption__copy {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

/* ===== Audio window ===== */
.player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(2.4rem, 1fr) auto;
  grid-template-areas:
    'cover info'
    'cover screen'
    'bar   bar';
  gap: 0.5rem 0.75rem;
  height: 100%;
}

.player__cover {
  grid-area: cover;
  align-self: start;
  width: 6.25rem;
  height: 6.25rem;
  min-height: 0;
  gap: 0.35rem;
  border: 1px solid var(--line-2);
}

.player__cover::before {
  width: 1.6rem;
  height: 1.6rem;
}

.player__cover::after {
  padding: 0.05rem 0.35rem;
  font-size: 0.625rem;
}

.player__info {
  display: flex;
  grid-area: info;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.player__label {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Song name: the loudest line */
.player__title {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--accent-hot);
}

/* Artist: deliberately quieter */
.player__artist {
  font-size: 0.8125rem;
  color: var(--text-dim);
}

/* Spectrum screen: a sunken LCD with faint scan lines */
.player__screen {
  position: relative;
  grid-area: screen;
  min-height: 2.4rem;
  background-color: var(--ink-2);
  background-image: linear-gradient(rgba(127, 208, 255, 0.07) 1px, transparent 1px);
  background-size: 100% 4px;
  border: 1px solid var(--line-2);
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.7);
}

.player__viz {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.player__bar {
  display: flex;
  grid-area: bar;
  align-items: center;
  gap: 0.6rem;
}

.player__status {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* a little square LED in front of the status */
.player__status::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.45rem;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--frame-dark);
}

/* ===== Marquee: a fixed box; a line that does not fit runs instead of being cut ===== */
.marquee {
  --marquee-gap: 3rem;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.marquee__track {
  display: flex;
  width: max-content;
}

.marquee__text {
  flex: none;
  white-space: nowrap;
}

/* Line too long: fade the right edge and run the text.
   `#000` here is an alpha mask, not a visible colour: leave it as is. */
.marquee.is-overflowing {
  -webkit-mask-image: linear-gradient(to right, #000 85%, transparent 100%);
  mask-image: linear-gradient(to right, #000 85%, transparent 100%);
}

.marquee.is-overflowing .marquee__text {
  margin-right: var(--marquee-gap);
}

.marquee.is-overflowing .marquee__track {
  animation: marquee var(--marquee-duration, 12s) linear infinite;
}

/* One full period = one copy of the text plus the gap, which makes the
   loop seamless: the second copy lands exactly where the first started. */
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(-1 * var(--marquee-distance, 50%))); }
}

/* ===== Volume: a segmented XP-style trackbar ===== */
.vol {
  display: flex;
  flex: 0 1 9.5rem;
  align-items: center;
  gap: 0.45rem;
  min-width: 6rem;
}

.vol__icon {
  position: relative;
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--accent);
}

.vol__glyph {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
}

.vol__icon[data-level='high'] .vol__glyph--high,
.vol__icon[data-level='low'] .vol__glyph--low,
.vol__icon[data-level='mute'] .vol__glyph--mute {
  display: block;
}

.vol__slider {
  --fill: 30%; /* kept in sync by script.js */
  --seg-off: #0a2540;
  --seg-gap: #050f1d;
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 1.3rem;
  margin: 0;
  padding: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.vol__slider:focus {
  outline: none;
}

.vol__slider:focus-visible {
  outline: 1px dotted var(--accent-hot);
  outline-offset: 2px;
}

/* WebKit / Blink: the lit part is a gradient cut at --fill, chopped into blocks */
.vol__slider::-webkit-slider-runnable-track {
  height: 0.8rem;
  background:
    repeating-linear-gradient(90deg, transparent 0, transparent 4px, var(--seg-gap) 4px, var(--seg-gap) 6px),
    linear-gradient(90deg, var(--accent) 0, var(--accent) var(--fill), var(--seg-off) var(--fill), var(--seg-off) 100%);
  border: 1px solid var(--line-2);
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.7), 1px 1px 0 rgba(120, 190, 240, 0.12);
}

.vol__slider::-webkit-slider-thumb {
  width: 0.55rem;
  height: 1.15rem;
  margin-top: calc((0.8rem - 2px - 1.15rem) / 2);
  background: linear-gradient(90deg, #c9ecff 0, #7fcaf3 45%, #4a9fd8 100%);
  border: 1px solid #07203a;
  border-radius: 1px;
  box-shadow: inset 1px 1px 0 #e8f6ff, inset -1px -1px 0 #2a6fa6;
  -webkit-appearance: none;
  appearance: none;
}

/* Firefox: has a real "progress" part, so the blocks are painted twice */
.vol__slider::-moz-range-track {
  height: 0.8rem;
  background: repeating-linear-gradient(90deg, var(--seg-off) 0, var(--seg-off) 4px, var(--seg-gap) 4px, var(--seg-gap) 6px);
  border: 1px solid var(--line-2);
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.7), 1px 1px 0 rgba(120, 190, 240, 0.12);
}

.vol__slider::-moz-range-progress {
  height: 0.8rem;
  background: repeating-linear-gradient(90deg, var(--accent) 0, var(--accent) 4px, var(--seg-gap) 4px, var(--seg-gap) 6px);
}

.vol__slider::-moz-range-thumb {
  width: 0.55rem;
  height: 1.15rem;
  background: linear-gradient(90deg, #c9ecff 0, #7fcaf3 45%, #4a9fd8 100%);
  border: 1px solid #07203a;
  border-radius: 1px;
  box-shadow: inset 1px 1px 0 #e8f6ff, inset -1px -1px 0 #2a6fa6;
}

/* ===== Buttons: XP bevel, in azure ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 1.9rem;
  padding: 0.25rem 0.85rem;
  color: var(--text);
  background: linear-gradient(180deg, #23578a 0%, #174270 50%, #112f52 100%);
  border: 1px solid #07203a;
  border-radius: 3px;
  box-shadow: inset 1px 1px 0 rgba(140, 205, 255, 0.38), inset -1px -1px 0 rgba(0, 0, 0, 0.4);
}

.btn svg {
  flex: none;
  width: 1rem;
  height: 1rem;
}

.btn--icon {
  flex: none;
  padding: 0.25rem 0.6rem;
}

.btn:hover {
  box-shadow:
    inset 1px 1px 0 rgba(140, 205, 255, 0.38),
    inset -1px -1px 0 rgba(0, 0, 0, 0.4),
    inset 0 0 0 2px var(--accent);
}

.btn:active {
  background: linear-gradient(180deg, #0d2a47 0%, #12385e 100%);
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.6);
  padding: calc(0.25rem + 1px) calc(0.85rem - 1px) calc(0.25rem - 1px) calc(0.85rem + 1px);
}

/* the Memes button rests for a second after each click */
.btn.is-cooling {
  opacity: 0.5;
  pointer-events: none;
}

/* "Next" nudges its arrow forward: three hard steps, like everything else here */
.btn--icon.is-spinning svg {
  animation: nudge 0.3s steps(3) both;
}

@keyframes nudge {
  40% { transform: translateX(3px); }
}

/* ===== About: notepad ===== */
.win--about .win__body {
  padding: 0.85rem 1rem;
  font-size: 1.0625rem;
  line-height: 1.4;
}

.about__lead {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-hot);
}

.about__list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
}

.about__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.6rem;
}

.about__row dt {
  margin: 0;
  color: var(--text-dim);
}

.about__row dd {
  margin: 0;
  color: var(--text);
}

.about__row a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.about__row a:hover {
  color: #fff;
  background: var(--sel);
  text-decoration: none;
}

/* text cursor at the end of the note */
.caret {
  display: inline-block;
  width: 0.55rem;
  height: 1em;
  margin-left: 0.35rem;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: caret-blink 1.1s steps(1) infinite;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

/* ===== Skills ===== */
.group-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.5rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* the etched rule after the label */
.group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line-2);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.tags + .group-title {
  margin-top: 1rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.875rem;
  background: var(--ink-3);
  border: 1px solid var(--line-2);
  box-shadow: inset 1px 1px 0 rgba(140, 205, 255, 0.16), inset -1px -1px 0 rgba(0, 0, 0, 0.4);
}

.flag {
  flex: none;
  width: 1.4rem;
  height: 0.74rem;
  /* a hairline in the frame colour: keeps the black stripe of the German flag
     from melting into the dark window */
  box-shadow: 0 0 0 1px var(--line-2);
}

/* ===== Links: rows that light up like selected XP icons ===== */
.links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.3rem 0.5rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
}

.link svg {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
}

.link:hover,
.link:focus-visible {
  color: #fff;
  background: var(--sel);
  border-color: var(--accent);
}

.note-box {
  margin: 0.8rem 0 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.8125rem;
  color: var(--text-dim);
  background: var(--ink-2);
  border: 1px dashed var(--line-2);
}

.note-box::before {
  content: '> ';
  color: var(--accent);
}

/* ===== Tools: XP group boxes ===== */
.group {
  min-width: 0;
  margin: 0;
  padding: 0.55rem 0.7rem 0.7rem;
  border: 1px solid var(--line-2);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.55), inset 1px 1px 0 rgba(140, 205, 255, 0.07);
}

.group + .group {
  margin-top: 0.7rem;
}

.group > legend {
  padding: 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.lang-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  container-type: inline-size; /* lets the buttons react to the width of this row, see below */
}

/* Radio-style language buttons */
.lang {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.45rem;
  background: var(--ink-3);
  border: 1px solid var(--line-2);
  box-shadow: inset 1px 1px 0 rgba(140, 205, 255, 0.14), inset -1px -1px 0 rgba(0, 0, 0, 0.4);
}

.lang:hover {
  border-color: var(--accent);
}

.lang[aria-pressed='true'] {
  color: #fff;
  background: #123a63;
  border-color: var(--accent);
}

.lang__dot {
  position: relative;
  flex: none;
  width: 0.8rem;
  height: 0.8rem;
  background: var(--ink);
  border: 1px solid var(--accent);
  border-radius: 50%;
}

.lang[aria-pressed='true'] .lang__dot::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--accent);
  border-radius: 50%;
}

/* Three radio buttons need a fairly wide window. In a narrow one the dots go
   (the pressed button is still lit), so the row stays on one line and the
   Tools window does not grow taller than its neighbours. */
@container (max-width: 25rem) {
  .lang__dot {
    display: none;
  }
}

/* ===== Tray: only while a window is closed ===== */
/* The mosaic makes room for the tray by easing up, instead of jumping */
.desktop {
  transition: padding-bottom 0.3s ease;
}

body.has-tray .desktop {
  padding-bottom: calc(var(--gap) + var(--tray-h));
}

.tray:not([hidden]) {
  animation: tray-in 0.25s ease-out;
}

@keyframes tray-in {
  from { transform: translateY(100%); }
}

.tray {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 45;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--tray-h);
  padding: 0.22rem 0.4rem;
  background: linear-gradient(180deg, #3f95d6 0, #2273b4 12%, #1c639f 55%, #1a5c96 90%, #12426c 100%);
  border-top: 1px solid #0b2c4d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.tray[hidden],
.tray__btn[hidden] {
  display: none;
}

.tray__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 1.7rem;
  padding: 0.15rem 0.7rem 0.15rem 0.5rem;
  font-size: 0.8125rem;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(4, 28, 56, 0.7);
  background: linear-gradient(180deg, #5eaee8, #3584c6 15%, #2874b5 85%, #206aa8);
  border: 1px solid #0b3a66;
  border-radius: 3px;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.28);
}

.tray__btn svg {
  width: 1rem;
  height: 1rem;
}

.tray__btn:hover {
  filter: brightness(1.15);
}

.tray__btn:active {
  filter: brightness(0.85);
}

/* ===== Autoplay-blocked dialog ===== */
.dialog {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  z-index: 50;
  width: min(22rem, calc(100vw - 1.5rem));
  transform: translateX(-50%);
  cursor: var(--cursor-interact);
}

.dialog[hidden] {
  display: none;
}

/* the title bar flashes, like a taskbar button asking for attention */
.dialog .win__bar {
  animation: bar-flash 1.2s steps(1) infinite;
}

@keyframes bar-flash {
  50% { filter: brightness(1.45); }
}

.dialog__body {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.7rem 0.9rem;
  padding: 0.9rem;
}

.dialog__icon {
  width: 2.4rem;
  height: 2.4rem;
  color: var(--accent);
}

.dialog__text {
  margin: 0;
}

.dialog__body .btn {
  grid-column: 1 / -1;
  justify-self: center;
  min-width: 5rem;
}

/* ===== Meme windows: they fly out of the Memes button and stay until their × is pressed =====
   They are moved by the title bar or the frame (script.js), so their place is plain
   left/top and transforms are only used for the fly-in and fly-out. script.js gives
   every new window a higher z-index than the one before, so they stack on each other. */
.meme-pop {
  --fly-x: 0px; /* from where the window flies in / to where it flies out, set by script.js */
  --fly-y: 0px;
  position: fixed;
  z-index: 60;
  width: min(21rem, calc(100vw - 1.5rem));
  touch-action: none; /* a finger on the frame drags the window instead of scrolling the page */
  cursor: grab;
  visibility: hidden; /* until script.js has measured and placed it, then adds .is-ready */
}

.meme-pop.is-ready {
  visibility: visible;
  animation: pop-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.meme-pop.is-leaving {
  pointer-events: none;
  animation: pop-out 0.45s cubic-bezier(0.55, 0, 0.8, 0.3) forwards;
}

/* Only the frame is a handle: the picture keeps the normal cursor */
.meme-pop .win__body {
  padding: 0;
  overflow: hidden;
  cursor: var(--cursor-normal);
}

/* While it is being moved */
.meme-pop.is-dragging,
.meme-pop.is-dragging * {
  cursor: grabbing;
  user-select: none;
}

.meme-pop .shot {
  min-height: 0;
  aspect-ratio: 4 / 3;
}

.pop__img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(60vh, 26rem);
  object-fit: contain;
  background: #000;
}

/* Only one end is spelled out: the other is the window as it sits on screen */
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translate(var(--fly-x), var(--fly-y)) scale(0.12);
  }
}

@keyframes pop-out {
  to {
    opacity: 0;
    transform: translate(var(--fly-x), var(--fly-y)) scale(0.05);
  }
}

/* ===== Rain: pure CSS pixel streaks over the desktop =====
   Two tiled layers fall at different speeds. Each loop moves a layer by a whole
   tile along the streak's own slope, so the join is invisible.
   Want your own GIF instead? Delete the two ::before/::after layers and put
   `background: url('lib/imgs/rain.gif') center / cover;` on .rain. */
.rain {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.rain.is-on {
  opacity: 1;
}

.rain::before,
.rain::after {
  content: '';
  position: absolute;
  top: -384px;
  right: -96px;
  bottom: 0;
  left: 0;
}

.rain::before {
  background: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2296%22%20height=%2296%22%20shape-rendering=%22crispEdges%22%3E%3Cpath%20fill=%22%23a9dcff%22%20d=%22M60%2052h1v4h-1zM59%2056h1v4h-1zM29%2025h1v4h-1zM28%2029h1v4h-1zM15%2014h1v4h-1zM14%2018h1v4h-1zM8%2024h1v4h-1zM7%2028h1v4h-1zM67%2026h1v4h-1zM66%2030h1v4h-1zM28%201h1v4h-1zM27%205h1v4h-1zM33%2055h1v4h-1zM32%2059h1v4h-1z%22/%3E%3C/svg%3E") 0 0 / 96px 96px;
  opacity: 0.6;
  animation: rain-a 0.55s linear infinite;
}

.rain::after {
  top: -640px;
  right: -160px;
  background: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22160%22%20height=%22160%22%20shape-rendering=%22crispEdges%22%3E%3Cpath%20fill=%22%2362b0ea%22%20d=%22M83%20148h1v4h-1zM82%20152h1v4h-1zM154%2013h1v4h-1zM153%2017h1v4h-1zM14%2033h1v4h-1zM13%2037h1v4h-1zM41%2097h1v4h-1zM40%20101h1v4h-1zM53%2011h1v4h-1zM52%2015h1v4h-1zM56%2037h1v4h-1zM55%2041h1v4h-1zM118%20134h1v4h-1zM117%20138h1v4h-1zM90%2011h1v4h-1zM89%2015h1v4h-1zM117%2075h1v4h-1zM116%2079h1v4h-1zM149%2041h1v4h-1zM148%2045h1v4h-1z%22/%3E%3C/svg%3E") 0 0 / 160px 160px;
  opacity: 0.35;
  animation: rain-b 0.9s linear infinite;
}

@keyframes rain-a {
  to { transform: translate(-96px, 384px); }
}

@keyframes rain-b {
  to { transform: translate(-160px, 640px); }
}

/* ===== Scrollbars: chunky and blue ===== */
@supports selector(::-webkit-scrollbar) {
  ::-webkit-scrollbar {
    width: 0.75rem;
    height: 0.75rem;
  }

  ::-webkit-scrollbar-track {
    background: var(--ink-2);
    box-shadow: inset 1px 0 0 var(--line);
  }

  ::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #4a9ad6, #2b78b4);
    border: 1px solid var(--frame-dark);
  }

  ::-webkit-scrollbar-corner {
    background: var(--ink-2);
  }
}

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: #2b78b4 var(--ink-2);
  }
}

/* ===== Respect the OS "reduce motion" setting ===== */
@media (prefers-reduced-motion: reduce) {
  .marquee.is-overflowing .marquee__track,
  .btn--icon.is-spinning svg,
  .caret,
  .dialog .win__bar,
  .rain::before,
  .rain::after,
  .tray:not([hidden]),
  .meme-pop.is-ready,
  .meme-pop.is-leaving {
    animation: none;
  }

  .rain,
  .desktop,
  .meme-pop {
    transition: none;
  }

  /* no flight to wait for: a closed meme is simply gone */
  .meme-pop.is-leaving {
    opacity: 0;
  }

  .caret {
    opacity: 1;
  }
}

/* ===== Two columns ===== */
@media (max-width: 1000px) {
  .desktop {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-template-areas:
      'me     audio'
      'me     tools'
      'about  skills'
      'links  photo';
  }

  .win--photo .shot {
    min-height: 16rem;
  }
}

/* ===== One column: windows stack in reading order ===== */
@media (max-width: 640px) {
  .desktop {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'me'
      'audio'
      'tools'
      'about'
      'skills'
      'links'
      'photo';
  }

  .win--me .shot {
    min-height: 22rem;
  }

  .win--photo .shot {
    min-height: 18rem;
  }

  .vol {
    flex-basis: 8rem;
  }

  .dialog {
    bottom: 1rem;
  }
}

@media (max-width: 420px) {
  .player__cover {
    width: 4.75rem;
    height: 4.75rem;
  }
}
