/* Three worlds, one family each: the page (Inter), source (Geist Mono), Y2K (Silkscreen). */

@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/inter-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Geist Mono';
  src: url('../assets/fonts/geist-mono-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

/* Silkscreen is drawn on an 8px grid: use it at 16px only, or its pixels blur. */
@font-face {
  font-family: 'Silkscreen';
  src: url('../assets/fonts/silkscreen-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Silkscreen';
  src: url('../assets/fonts/silkscreen-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --hover: #f3f4f6;
  --underline: #cbd5e1;
  --select: #2563eb;

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --pixel: 'Silkscreen', 'Geist Mono', ui-monospace, monospace;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.sprite { position: absolute; }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--select);
  outline-offset: 2px;
}

/* ---- The page ---- */

/* The folders come right after the name in the markup, so a phone shows them on the
   first screen. On a wide screen they sit to the right, like icons on a desktop. */
.page {
  display: grid;
  grid-template-columns: minmax(0, 640px) auto;
  grid-template-areas:
    'intro   desktop'
    'facts   desktop'
    'socials desktop';
  justify-content: center;
  align-items: start;
  column-gap: 72px;
  padding: 56px 24px 72px;
}

.intro { grid-area: intro; }
.facts { grid-area: facts; }
.socials { grid-area: socials; }

.avatar {
  display: block;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

h1 {
  margin: 20px 0 28px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.facts {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px 16px;
  margin: 0;
}

.facts dt {
  padding-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.facts dd { margin: 0; }

.facts a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.facts a:hover { text-decoration-color: currentColor; }

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 32px;
  font-size: 14px;
}

.socials a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 24px; /* the X link is an icon only; keep it easy to tap */
  min-height: 24px;
  color: var(--muted);
  text-decoration: none;
}

.socials a:hover { color: var(--text); }

.socials svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ---- Folders ---- */

.desktop {
  grid-area: desktop;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: -10px;
}

.folder {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 128px;
  padding: 10px 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: 500 13px/1.3 var(--sans);
  text-align: center;
  cursor: pointer;
}

.folder:hover { background: var(--hover); }

.folder-art {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 56px;
}

.folder-art > svg:first-child {
  display: block;
  width: 64px;
  height: 52px;
}

.folder-back { fill: #2d2d2f; }
.folder-front { fill: #4a4a50; }

.folder-glyph {
  fill: none;
  stroke: #e4e4e7;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The pixel folder is 16 art pixels wide, shown at four times its size. */
.folder-art img {
  display: block;
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
}

.spark {
  position: absolute;
  top: -6px;
  right: -14px;
  width: 30px;
  height: 30px;
  transform: rotate(14deg);
}

.folder-creator { cursor: url('../assets/y2k/pointer.png') 10 0, pointer; }

.folder .label {
  padding: 1px 6px;
  border-radius: 4px;
}

/* An open folder looks selected, as in a file manager. */
.folder[aria-expanded='true'] .label {
  background: var(--select);
  color: #ffffff;
}

/* ---- Windows, shared ---- */

.window {
  position: fixed;
  z-index: 10;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 16px);
  outline: 0;
  animation: window-open 0.14s ease-out;
}

.window[hidden] { display: none; }

@keyframes window-open {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

.titlebar {
  flex: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- World 1: source ---- */

.source {
  --ink: #e4e4e7;
  --dim: #9a9aa2;
  --line: #3a3a3c;
  --accent: #7cb7ff;

  width: min(720px, calc(100vw - 16px));
  overflow: hidden;
  background: #1e1e1e;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
  font: 400 13px/1.5 var(--mono);
}

.source .titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  background: #2d2d2f;
  border-bottom: 1px solid #19191a;
}

.source .title {
  color: #c4c4cc;
  font: 500 12px/1.2 var(--mono);
}

.light {
  position: relative;
  width: 12px;
  height: 12px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ff5f57;
  color: rgba(0, 0, 0, 0.6);
  font: 700 10px/12px var(--sans);
  cursor: pointer;
}

/* A 12px dot is too small to hit, so the target reaches past it. */
.light::after {
  content: '';
  position: absolute;
  inset: -12px;
}

.light::before {
  content: '×';
  position: absolute;
  inset: 0;
  text-align: center;
  opacity: 0;
}

.light:hover::before,
.light:focus-visible::before { opacity: 1; }

.repos {
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  list-style: none;
}

.repo {
  display: grid;
  grid-template-columns: 28px 21ch minmax(0, 1fr);
  align-items: baseline;
  column-gap: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}

/* The focused row is the cursor row, as in a terminal file manager. */
.repo:hover,
.repo:focus {
  background: #2c2f36;
  outline: 0;
}

.repo:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }

.repo .name {
  color: #ffffff;
  font-weight: 500;
}

.repo .desc { color: var(--dim); }

/* The badge colour is the language; the letters say which. */
.lang {
  border-radius: 4px;
  color: #111111;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.lang.js { background: #f1e05a; }
.lang.py { background: #6da9f7; }
.lang.rs { background: #dea584; }

.hints {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
}

/* ---- World 2: Y2K ---- */

.y2k {
  --face: #c0c0c0;
  --hi: #ffffff;
  --mid: #dfdfdf;
  --lo: #808080;
  --dk: #0a0a0a;
  --navy: #000080;
  --raised: inset -1px -1px var(--dk), inset 1px 1px var(--hi), inset -2px -2px var(--lo), inset 2px 2px var(--mid);
  --sunken: inset 1px 1px var(--lo), inset -1px -1px var(--hi), inset 2px 2px var(--dk), inset -2px -2px var(--mid);
  --arrow: url('../assets/y2k/cursor.png') 0 0, default;
  --hand: url('../assets/y2k/pointer.png') 10 0, pointer;

  width: min(680px, calc(100vw - 16px));
  padding: 4px;
  background: var(--face);
  color: #000000;
  font: 400 16px/1.25 var(--pixel);
  box-shadow: var(--raised), 6px 6px 0 rgba(0, 0, 0, 0.28);
  cursor: var(--arrow);
  -webkit-font-smoothing: none;
}

.y2k .titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 3px 0 6px;
  background: linear-gradient(90deg, var(--navy), #1084d0);
  color: #ffffff;
}

.y2k .title {
  flex: 1;
  font: 700 16px/1 var(--pixel);
}

.title-icon {
  flex: none;
  width: 18px;
  height: 18px;
}

.y2k-button {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 30px;
  padding: 0;
  border: 0;
  background: var(--face);
  box-shadow: var(--raised);
  cursor: var(--hand);
}

.y2k-button svg {
  width: 20px;
  height: 20px;
  fill: #000000;
  shape-rendering: crispEdges;
}

.y2k-button:active,
.y2k-button[aria-pressed='true'] { box-shadow: var(--sunken); }

.y2k-button:active svg,
.y2k-button[aria-pressed='true'] svg { transform: translate(1px, 1px); }

.y2k-button:focus-visible {
  outline: 1px dotted #000000;
  outline-offset: -5px;
}

.y2k-button.close {
  width: 24px;
  height: 22px;
}

.y2k-button.close svg {
  width: 16px;
  height: 14px;
}

.y2k-button.close::after {
  content: '';
  position: absolute;
  inset: -10px;
}

.bliss {
  position: relative;
  display: flex;
  flex: 0 1 auto;
  min-height: 200px;
  margin-top: 4px;
  overflow: hidden;
  box-shadow: var(--sunken);
}

.wallpaper {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
}

.sticker {
  position: absolute;
  right: 28px;
  bottom: 18px;
  width: 136px;
  height: 136px;
  transform: rotate(14deg);
  pointer-events: none;
}

.clips {
  position: relative;
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  min-height: 330px;
  overflow-y: auto;
  align-content: flex-start;
  gap: 12px;
  margin: 0;
  padding: 20px;
  list-style: none;
}

.clip {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 232px;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: #ffffff;
  font: inherit;
  text-align: center;
  text-decoration: none;
  text-shadow: 1px 1px 0 #000000;
  cursor: var(--hand);
}

/* A 96x54 dithered frame, shown at twice its size. */
.clip img {
  display: block;
  width: 192px;
  height: 108px;
  border: 2px solid #ffffff;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
  image-rendering: pixelated;
}

.clip .name {
  max-width: 100%;
  padding: 1px 4px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.clip:hover .name,
.clip:focus-visible .name {
  background: var(--navy);
  outline: 1px dotted #ffffff;
  text-shadow: none;
}

.clip:focus-visible { outline: 0; }

.statusbar {
  display: flex;
  gap: 2px;
  margin-top: 4px;
}

.cell {
  padding: 3px 8px;
  box-shadow: inset 1px 1px var(--lo), inset -1px -1px var(--hi);
}

.cell.grow { flex: 1; }

/* The player is never taller than the screen. 124px is everything in the window
   that is not the picture: title bar, controls, padding and the gap to the edges. */
.player { width: min(720px, calc(100vw - 16px), calc((100dvh - 124px) * 16 / 9 + 12px)); }

.screen {
  margin-top: 4px;
  padding: 2px;
  background: #000000;
  box-shadow: var(--sunken);
}

.screen video {
  display: block;
  width: 100%;
  max-height: calc(100dvh - 124px);
  aspect-ratio: 16 / 9;
  background: #000000;
  cursor: var(--hand);
}

.controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px 2px;
}

[data-action='toggle'] .icon-pause,
[data-action='toggle'][data-state='playing'] .icon-play { display: none; }

[data-action='toggle'][data-state='playing'] .icon-pause { display: block; }

[data-action='mute'][aria-pressed='true'] .waves { display: none; }

.lcd {
  flex: none;
  min-width: 13ch;
  padding: 6px 8px;
  background: var(--dk);
  color: #4dff7c;
  box-shadow: inset 1px 1px var(--lo), inset -1px -1px var(--hi);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.seek {
  flex: 1;
  min-width: 48px;
  height: 30px;
  margin: 0;
  background: none;
  cursor: var(--hand);
  -webkit-appearance: none;
  appearance: none;
}

.seek::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--dk);
  box-shadow: 1px 1px 0 var(--hi), -1px -1px 0 var(--lo);
}

.seek::-webkit-slider-thumb {
  width: 12px;
  height: 24px;
  margin-top: -9px;
  background: var(--face);
  box-shadow: var(--raised);
  -webkit-appearance: none;
}

.seek::-moz-range-track {
  height: 6px;
  background: var(--dk);
  box-shadow: 1px 1px 0 var(--hi), -1px -1px 0 var(--lo);
}

.seek::-moz-range-thumb {
  width: 12px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: var(--face);
  box-shadow: var(--raised);
}

.seek:focus-visible {
  outline: 1px dotted #000000;
  outline-offset: 0;
}

.seek:disabled { opacity: 0.5; }

/* ---- Narrow screens ---- */

@media (max-width: 960px) {
  .page {
    grid-template-columns: minmax(0, 640px);
    grid-template-areas: 'intro' 'desktop' 'facts' 'socials';
  }

  h1 { margin-bottom: 16px; }

  .desktop {
    flex-direction: row;
    margin: 0 0 24px -12px;
  }
}

@media (max-width: 640px) {
  .page { padding: 32px 20px 48px; }

  .facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .facts dd { margin-bottom: 14px; }

  /* A window opens in the middle of the screen: pinned to all four sides, as tall as
     its content, and the auto margins share out the rest. */
  .window {
    top: 8px !important;
    right: 8px;
    bottom: 8px;
    left: 8px !important;
    width: auto;
    height: fit-content;
    margin: auto 0;
  }

  .repo { grid-template-columns: 28px minmax(0, 1fr); }
  .repo .desc { grid-column: 2; }

  .light::after { inset: -16px; }

  .sticker {
    right: 12px;
    bottom: 10px;
    width: 96px;
    height: 96px;
  }

  .controls { gap: 4px; }
  .controls .y2k-button { width: 32px; }

  .lcd {
    min-width: 0;
    padding: 6px 5px;
  }

  .lcd .total { display: none; }
}

/* Key hints are for keyboards. */
@media (pointer: coarse) {
  .keys { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .window { animation: none; }
}
