/*
 * StumpFox Mobile: the phone apps, live in the browser.
 *
 * The look follows the studio site (stumpfox_official/project, globals.css): editorial dark,
 * warm near-black, warm white, one orange signal, square-edged buttons, borderless cards held
 * together by hairlines, Archivo for display, Inter for text, JetBrains Mono for labels. Each
 * game brings its own colour as `--accent`.
 */

@font-face {
  font-family: 'Archivo';
  src: url('/fonts/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --void: #08080a;
  --canvas: #0c0c0f;
  --surface: #141417;
  --elevated: #1c1c21;
  --line: #2a2a31;
  --line-soft: #1c1c23;
  --ink: #f6f4f0;
  --muted: #a5a3ac;
  --faint: #6b6974;
  --brand: #ff6220;
  --accent: var(--brand);

  --display: 'Archivo', system-ui, sans-serif;
  --text: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --gutter: clamp(1rem, 4vw, 4rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font: 400 1rem/1.6 var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--brand);
  color: var(--void);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 20;
  padding: 0.75rem 1rem;
  background: var(--brand);
  color: var(--void);
  font-weight: 600;
  text-decoration: none;
}
.skip:focus {
  top: 1rem;
}

/* ------------------------------------------------------------------ type */

.kicker {
  margin: 0;
  font: 500 0.6875rem/1.4 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

.display {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.lede {
  margin: 0;
  max-width: 38rem;
  font-size: clamp(1.0625rem, 1.4vw, 1.25rem);
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}

.rule {
  height: 1px;
  border: 0;
  margin: 0;
  background: var(--line);
}

/* ------------------------------------------------------------------ header */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4.5rem;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}
.brand img {
  width: auto;
  height: 2.25rem;
}
.brand-name {
  font: 800 0.9375rem/1 var(--display);
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
.brand-name span {
  color: var(--brand);
}

.bar-link {
  font: 500 0.6875rem/1 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 0.75rem 0;
  transition: color 0.2s;
}
.bar-link:hover {
  color: var(--ink);
}

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.75rem;
  padding: 0 1.25rem;
  border: 1px solid transparent;
  border-radius: 0;
  font: 600 0.9375rem/1 var(--text);
  text-decoration: none;
  cursor: pointer;
  transition:
    filter 0.2s,
    border-color 0.2s,
    color 0.2s,
    background-color 0.2s;
}
.btn-outline {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn svg {
  width: 1rem;
  height: 1rem;
}

/* ------------------------------------------------------------------ front page */

.intro {
  padding: clamp(3rem, 9vw, 7.5rem) var(--gutter) clamp(2.5rem, 6vw, 4.5rem);
  display: grid;
  gap: 1.5rem;
}
.intro .display {
  font-size: clamp(2.75rem, 8.5vw, 7.5rem);
  max-width: 14ch;
}
.intro .display em {
  font-style: normal;
  color: var(--brand);
}

.shelf {
  padding: 0 var(--gutter) clamp(4rem, 8vw, 7rem);
}
.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0 2.5rem;
  border-top: 1px solid var(--line);
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
  gap: clamp(2rem, 3.5vw, 3.5rem) clamp(1.25rem, 2.5vw, 2.5rem);
}

.card {
  --lift: 0px;
  display: grid;
  gap: 1.25rem;
  text-decoration: none;
}

.card-screen {
  position: relative;
  aspect-ratio: 390 / 844;
  border-radius: 1.75rem;
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.08),
    0 30px 60px -30px color-mix(in srgb, var(--accent) 0%, transparent);
  transform: translateY(var(--lift));
  transition:
    transform 0.45s var(--ease),
    box-shadow 0.45s var(--ease);
}
.card-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-screen::after {
  /* A light rim over the picture, so a dark screenshot still has an edge. */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1);
  pointer-events: none;
}
.card:hover .card-screen,
.card:focus-visible .card-screen {
  --lift: -6px;
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.08),
    0 36px 70px -26px color-mix(in srgb, var(--accent) 55%, transparent);
}
.card:focus-visible {
  outline: none;
}
.card:focus-visible .card-screen {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.card-meta {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  gap: 0.25rem 0.875rem;
  align-items: center;
}
.app-icon {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 22%;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1);
  overflow: hidden;
  background: var(--elevated);
}
.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-title {
  margin: 0;
  font: 800 1.375rem/1.1 var(--display);
  letter-spacing: -0.03em;
  transition: color 0.2s;
}
.card:hover .card-title {
  color: var(--accent);
}
.card-tagline {
  grid-column: 1 / -1;
  margin: 0.375rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* Phones: two games a row, so the whole list fits in a few screens. */
@media (max-width: 40rem) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem 0.875rem;
  }
  .card {
    gap: 0.875rem;
  }
  .card-screen {
    border-radius: 1.125rem;
  }
  .card-meta {
    grid-template-columns: 2.25rem minmax(0, 1fr);
    gap: 0.125rem 0.625rem;
  }
  .card-meta .app-icon {
    width: 2.25rem;
    height: 2.25rem;
  }
  .card-meta .kicker {
    display: none;
  }
  .card-title {
    font-size: 1.0625rem;
  }
  .card-tagline {
    font-size: 0.8125rem;
    margin-top: 0.25rem;
  }
}

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

.foot {
  padding: 2.5rem var(--gutter) 3rem;
  border-top: 1px solid var(--line-soft);
  background: var(--void);
  display: grid;
  gap: 1rem;
  color: var(--faint);
  font-size: 0.875rem;
}
.foot p {
  margin: 0;
  max-width: 60rem;
}
.foot a {
  color: var(--muted);
}
.foot a:hover {
  color: var(--ink);
}

/* ------------------------------------------------------------------ viewer */

.viewer-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.viewer-page .foot {
  display: none;
}

.viewer {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(18rem, 30rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: 0 var(--gutter);
  background:
    radial-gradient(60rem 40rem at 72% 55%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    var(--canvas);
}

.about {
  align-self: center;
  display: grid;
  gap: 1.25rem;
  padding: 2rem 0;
  max-height: 100%;
  overflow: auto;
}
.about-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.about-head .app-icon {
  width: 4.5rem;
  height: 4.5rem;
  flex: none;
}
.about .display {
  font-size: clamp(2.5rem, 4.5vw, 4.25rem);
}
.tagline {
  margin: 0;
  font: 600 1.0625rem/1.45 var(--text);
  color: var(--accent);
}
.summary {
  margin: 0;
  color: var(--muted);
  max-width: 34rem;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.25rem;
}
.notice {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.8125rem;
  line-height: 1.5;
  max-width: 34rem;
}

.others {
  display: grid;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.others ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}
.others a {
  display: block;
  border-radius: 22%;
  transition: transform 0.3s var(--ease);
}
.others a:hover {
  transform: translateY(-3px);
}
.others .app-icon {
  width: 2.75rem;
  height: 2.75rem;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The phone: the app's own 390 x 844 viewport, scaled to fit (viewer.js sets --scale). */
.phone {
  --scale: 1;
  position: relative;
  width: calc(390px * var(--scale));
  height: calc(844px * var(--scale));
  flex: none;
}
.phone-screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 390px;
  height: 844px;
  transform: scale(var(--scale));
  transform-origin: 0 0;
  border-radius: 46px;
  overflow: hidden;
  background: var(--void);
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 0.14),
    0 50px 110px -30px color-mix(in srgb, var(--accent) 45%, transparent),
    0 30px 60px -20px rgb(0 0 0 / 0.6);
}
.phone-screen iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--void);
}
.phone-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  background: var(--void);
  transition: opacity 0.35s;
  pointer-events: none;
}
.phone-loading.is-done {
  opacity: 0;
}
.phone-loading img {
  width: 6rem;
  height: 6rem;
  border-radius: 22%;
}
.spinner {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

/* The compact bar a phone gets above the app instead of the side panel. */
.mini-bar {
  display: none;
}

/* Tablets in portrait and narrow windows: panel above, phone below, both centred. */
@media (max-width: 62rem) {
  .viewer {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 1rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  .about {
    align-self: start;
    padding: 0;
    gap: 0.75rem;
  }
  .about .summary,
  .about .others,
  .about .notice {
    display: none;
  }
  .about .display {
    font-size: clamp(2rem, 6vw, 3rem);
  }
}

/* Phones: the app takes the whole screen under a slim bar. */
@media (max-width: 40rem) {
  .viewer-page > .bar,
  .viewer .about {
    display: none;
  }
  .viewer {
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    background: var(--void);
  }
  .mini-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 3rem;
    padding: 0 0.75rem 0 0.25rem;
    background: var(--void);
    border-bottom: 1px solid var(--line-soft);
    flex: none;
  }
  .mini-bar a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    height: 2.75rem;
    color: var(--muted);
    text-decoration: none;
  }
  .mini-bar a:hover {
    color: var(--ink);
  }
  .mini-bar svg {
    width: 1.25rem;
    height: 1.25rem;
  }
  .mini-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font: 700 1rem/1 var(--display);
    letter-spacing: -0.02em;
  }
  .mini-title .app-icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 24%;
  }
  .mini-title span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .stage {
    flex: 1;
  }
  .phone {
    width: 100%;
    height: 100%;
  }
  .phone-screen {
    position: static;
    width: 100%;
    height: 100%;
    transform: none;
    border-radius: 0;
    box-shadow: none;
  }
}

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