:root {
  --bg: #0b0b0f;
  --fg: #f3f0e8;
  --muted: #8d8c97;
  --line: rgb(255 255 255 / 0.08);
  --orange: #ff6a1a;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pad: clamp(12px, 2.4vw, 36px);
  --gap: clamp(8px, 1.1vw, 16px);
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* The whole page is one screen: header, grid, footer. Nothing scrolls. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
em { font-style: normal; }
::selection { background: var(--orange); color: #000; }

.grain {
  position: fixed; inset: -50%; z-index: 90; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1s steps(4) infinite;
}
@keyframes grain {
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-2%, -2%); }
}

/* ---------- centre block ---------- */

.hub {
  grid-column: 3 / span 2; grid-row: 2 / span 2;
  position: relative; z-index: 3; /* windows zooming in from behind pass under the title */
  container-type: size; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  min-width: 0; min-height: 0; padding: 4px;
}
.hub-title {
  margin: 0; font-weight: 800; line-height: 0.9; letter-spacing: -0.04em; white-space: nowrap;
  /* Sized to its cell: as wide as the block allows, but never taller than a third of it. */
  font-size: min(15.5cqw, 34cqh);
}
.hub-title span { color: var(--orange); }
.hub-meta { margin: 1.6cqh 0 0; max-width: 46ch; color: var(--muted); font-size: clamp(11px, min(3.2cqw, 6cqh), 15px); line-height: 1.4; }
.hub-meta a, .hub-links a { color: var(--fg); }
.hub-meta a { border-bottom: 1px solid rgb(255 255 255 / 0.25); transition: border-color 0.3s; }
.hub-meta a:hover { border-color: var(--fg); }
.hub-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin: 1.4cqh 0 0; font-size: clamp(12px, min(3.4cqw, 6cqh), 15px); }
.hub-links a { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.arr { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.4s var(--ease); }
.hub-links a:hover .arr { transform: rotate(45deg); }
@container (max-height: 150px) { .hub-meta { display: none; } }

.js .hub { opacity: 0; transform: scale(0.92); transition: opacity 0.8s var(--ease), transform 1s var(--ease); }
.ready .hub { opacity: 1; transform: none; }

/* ---------- the grid: the whole screen ---------- */
/* 6×4 landscape, 4×6 portrait, 3×8 phones. The centre block is placed explicitly; tiles flow around it. */

.apps {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense; gap: var(--gap); padding: var(--pad) var(--pad) 0;
}
@media (orientation: portrait) {
  .apps { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(6, minmax(0, 1fr)); }
  .hub { grid-column: 2 / span 2; grid-row: 3 / span 2; }
}
@media (orientation: portrait) and (max-width: 600px) {
  .apps { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); }
  .hub { grid-column: 1 / -1; grid-row: 4; }
  .hub-title { font-size: min(13cqw, 48cqh); }
  .app--wide-phone { grid-column: span 2; }
}

.app {
  position: relative; display: block; min-width: 0; min-height: 0;
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--s, 1));
  transition: transform 0.5s var(--ease);
}
.app.tilting { transition: transform 0.12s linear; }
.app--wide { grid-column: span 2; }

/* Hidden until main.js flies it in (or reveals it without motion). */
.js .app { opacity: 0; }
.js .app.landed { opacity: 1; }

.win {
  position: relative; display: flex; flex-direction: column; height: 100%; border-radius: 10px; overflow: hidden;
  background: #1b1b22; border: 1px solid var(--line);
  box-shadow: 0 18px 40px -24px rgb(0 0 0 / 0.9);
  transition: border-color 0.4s, box-shadow 0.4s;
}
.win-bar { flex: none; display: flex; align-items: center; gap: 4px; padding: 6px 8px; }
.win-bar i { width: 7px; height: 7px; border-radius: 50%; background: #3a3a44; flex: none; }
.win-bar i:nth-child(1) { background: #ff5f57; }
.win-bar i:nth-child(2) { background: #febc2e; }
.win-bar i:nth-child(3) { background: #28c840; }
.win-bar span {
  margin: 0 auto; padding: 2px 8px; border-radius: 4px; background: #111116; color: var(--muted);
  font: 500 10px/1.2 var(--mono); max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.win-view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
.win-view img, .win-view video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: left top;
  transition: transform 0.8s var(--ease), opacity 0.4s;
}
.win-view video { opacity: 0; }
.win-view.playing video { opacity: 1; }

/* Name and one-liner sit on the screenshot. */
.app-cap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 8px;
  padding: 28px 10px 8px; background: linear-gradient(transparent, rgb(8 8 12 / 0.92) 55%);
}
.app-cap b { font-size: 15px; line-height: 1.2; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.3s; }
.app-cap em { font: 500 10px/1 var(--mono); color: var(--fg); opacity: 0.75; white-space: nowrap; }
.app-cap > span { grid-column: 1 / -1; color: #b9b7b0; font-size: 12.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Phones: tiles are small, so drop the window chrome and keep only the name. */
@media (orientation: portrait) and (max-width: 600px) {
  .win { border-radius: 8px; }
  .win-bar { display: none; }
  .app-cap { padding: 16px 6px 5px; }
  .app-cap b { font-size: 11.5px; }
  .app-cap > span, .app-cap em { display: none; }
}

.glare {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: 10px; opacity: 0; transition: opacity 0.4s;
  background: radial-gradient(400px circle at var(--gx, 50%) var(--gy, 50%), rgb(255 255 255 / 0.1), transparent 45%);
}

@media (hover: hover) and (pointer: fine) {
  .app:hover { --s: 1.06; z-index: 5; }
  .app--wide:hover { --s: 1.04; }
  .app:hover .win { border-color: rgb(255 255 255 / 0.25); box-shadow: 0 30px 60px -20px rgb(0 0 0 / 0.95); }
  .app:hover .app-cap b { color: var(--orange); }
  .app:hover .glare { opacity: 1; }
}

/* ---------- footer ---------- */

.footer {
  flex: none; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 24px;
  padding: clamp(8px, 1.4vh, 14px) var(--pad); color: var(--muted); font-size: 12.5px;
}
.footer p { margin: 0; }
.footer a { color: var(--fg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
