/*
 * Shared stylesheet for the gallery and clip pages. Served directly by
 * Pages (see `_routes.json`), never through a Function.
 *
 * Layout stays usable down to a 320px-wide viewport and never hides the
 * native <video> controls - see functions/_shared/html.ts, which renders
 * `<video controls playsinline preload="metadata">` with no custom chrome.
 */

:root {
  color-scheme: dark light;
  --background: #0b0d12;
  --surface: #161a22;
  --text: #eef1f6;
  --text-muted: #9aa4b2;
  --accent: #5b8cff;
  --border: #262c38;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--background);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

.site-header {
  padding: 24px 16px 8px;
  max-width: 1100px;
  margin: 0 auto;
}

.site-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.gallery {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.gallery .empty {
  color: var(--text-muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  color: inherit;
}

.card:hover,
.card:focus-visible {
  border-color: var(--accent);
  text-decoration: none;
}

.card-preview {
  width: 100%;
  /* REQUIRED. The markup carries width/height attributes so the browser can
     reserve space before the image loads, but those attributes are
     presentational hints that map to CSS width/height. `width: 100%` overrides
     the width hint; without `height: auto` the height hint survives, both
     dimensions become explicit, and `aspect-ratio` is then ignored entirely --
     which renders a tall portrait box cropping the middle out of the frame. */
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--border);
}

.card-body {
  padding: 12px;
}

.card-title {
  font-size: 1rem;
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta,
.clip-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.clip {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.player {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  background: #000;
  border-radius: 10px;
}

.clip-title {
  font-size: 1.25rem;
  margin: 16px 0 4px;
}

.status {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 16px;
  text-align: center;
}

/* Never below 320px so the player stays usable on the smallest phones. */
@media (max-width: 320px) {
  .gallery,
  .clip,
  .site-header {
    padding-left: 12px;
    padding-right: 12px;
  }
}
