/* Shared foundation for all three demos: tokens, iOS-Photos structure, viewer.
   Each demo's style.css only adds its own look on top of this. */
:root {
  color-scheme: dark;
  --bg: #000;
  --fg: #f5f5f7;
  --muted: #a1a1a6; /* 8:1 on black */
  --line: rgb(255 255 255 / .14);
  --card: #1c1c1e;
  --chrome: rgb(10 10 10 / .78);
  --font: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --pad: 16px;
  --tabbar: 50px;
  --cols: 3;
  --gap: 2px;
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
html.viewing, html.viewing body { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:where(ul[role="list"]) { list-style: none; margin: 0; padding: 0; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 4px; }
#view:focus { outline: none; }
[hidden] { display: none !important; }

/* ── frame ─────────────────────────────────────────────────────────────── */
#app { position: relative; min-height: 100dvh; }
#view { min-height: 100dvh; padding: 0 var(--sar) calc(var(--tabbar) + var(--sab) + 32px) var(--sal); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; padding: 0 var(--sar) var(--sab) var(--sal);
  background: var(--chrome); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
  view-transition-name: tabbar;
}
.tabbar a {
  flex: 1; min-height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .01em;
}
.tabbar a[aria-current] { color: var(--fg); }
.tabbar a[aria-current] svg { stroke-width: 2; }

/* ── bars ──────────────────────────────────────────────────────────────── */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center; gap: 8px;
  min-height: calc(44px + var(--sat)); padding: var(--sat) 8px 0;
  background: var(--chrome); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.bar h1 { grid-column: 2; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .back { grid-column: 1; justify-self: start; display: inline-flex; align-items: center; min-height: 44px; padding-right: 8px; font-size: 17px; }
.bar .back svg { width: 26px; height: 26px; stroke-width: 2.2; margin-left: -4px; }
.bar .actions { grid-column: 3; justify-self: end; display: flex; align-items: center; }
.bar.large { position: relative; display: block; min-height: 0; padding: calc(var(--sat) + 18px) var(--pad) 14px; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.bar.large h1 { font-size: 34px; font-weight: 700; letter-spacing: -.022em; text-align: left; line-height: 1.1; }
.bar.large .actions { position: absolute; top: calc(var(--sat) + 8px); right: calc(var(--pad) - 10px); }
.wordmark { font-size: 11px; font-weight: 500; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.lang, .icon-btn { min-width: 44px; min-height: 44px; display: grid; place-items: center; border-radius: 22px; font-size: 13px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.lang:hover, .icon-btn:hover, .icon-btn[aria-pressed="true"] { color: var(--fg); }

/* ── media ─────────────────────────────────────────────────────────────── */
.media { position: relative; display: block; overflow: hidden; background: #111 center / cover no-repeat; }
.media img, .media video { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; user-select: none; }
.media picture { display: contents; }
.media.missing > * { visibility: hidden; }
.media.missing::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 34%; aspect-ratio: 3 / 2; border: 1px solid #3a3a3c; border-radius: 3px;
  background: linear-gradient(to top right, transparent calc(50% - .5px), #3a3a3c 50%, transparent calc(50% + .5px));
}
.is-video::before {
  content: ""; position: absolute; top: 6px; right: 6px; z-index: 1; width: 18px; height: 18px; border-radius: 50%;
  background: rgb(0 0 0 / .45) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M7 5.5v7l5.5-3.5z' fill='%23fff'/%3E%3C/svg%3E") center / 100%;
}
.v-media.is-video::before { display: none; }

/* ── albums ────────────────────────────────────────────────────────────── */
.reel-tile { display: block; margin: 0 var(--pad) 28px; border-radius: 12px; height: min(56svh, calc((100cqw - 2 * var(--pad)) / var(--ar))); }
.reel-tile .reel-label {
  position: absolute; inset: auto 0 0; display: flex; justify-content: space-between; align-items: end; padding: 32px 14px 12px;
  background: linear-gradient(transparent, rgb(0 0 0 / .7)); font-size: 13px;
}
.reel-tile strong { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.albums { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px 14px; padding: 0 var(--pad); }
.album { display: grid; gap: 1px; }
.album .cover { aspect-ratio: 1; border-radius: var(--radius); display: grid; place-items: center; color: var(--muted); }
.album .cover.empty { background: var(--card); }
.album .cover > svg { width: 40%; height: 40%; stroke-width: 1; }
.album-title { margin-top: 7px; font-size: 15px; line-height: 1.25; }
.album-meta { font-size: 13px; color: var(--muted); }
.album:hover .cover img { opacity: .92; }

/* ── album ─────────────────────────────────────────────────────────────── */
.album-head .hero { width: min(100%, calc(72svh * var(--ar))); margin: 0 auto; aspect-ratio: var(--ar); }
.album-info { padding: 18px var(--pad) 22px; display: grid; gap: 14px; max-width: 980px; }
.kicker { font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.desc { font-size: 15px; line-height: 1.55; color: #d2d2d7; max-width: 62ch; }
.credits { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 24px; margin: 0; }
.credits dt { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.credits dd { margin: 2px 0 0; font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: var(--gap); }
.thumb { aspect-ratio: 1; }
.thumb:focus-visible { outline-offset: -2px; border-radius: 0; z-index: 1; }

.empty, .state { padding: 48px var(--pad); color: var(--muted); text-align: center; display: grid; gap: 16px; justify-items: center; }
.state h1 { font-size: 22px; color: var(--fg); }
.state p { max-width: 42ch; }
.pill { display: inline-block; padding: 11px 20px; border-radius: 999px; background: var(--card); border: .5px solid var(--line); color: var(--fg); font-size: 15px; }

/* ── reel / about / contact ───────────────────────────────────────────── */
.reel { margin: 0; }
.reel .media { aspect-ratio: var(--ar); width: min(100%, calc(80svh * var(--ar))); margin: 0 auto; background: #000; }
.reel video, .reel iframe { width: 100%; height: 100%; object-fit: contain; border: 0; display: block; }
.reel figcaption { padding: 14px var(--pad); color: var(--muted); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.reel figcaption strong { color: var(--fg); font-weight: 600; }
.reel figcaption small { flex-basis: 100%; font-size: 12px; }

.about { display: grid; gap: 24px; padding: 0 var(--pad); max-width: 1100px; }
.portrait { aspect-ratio: var(--ar); border-radius: var(--radius); max-width: 460px; }
.about-text { display: grid; gap: 14px; align-content: start; }
.about-text h2 { font-size: 26px; font-weight: 650; letter-spacing: -.015em; }
.about-text p { color: #d2d2d7; line-height: 1.6; max-width: 62ch; }
.about-text h3 { margin-top: 18px; font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.list li { display: grid; padding: 10px 0; border-bottom: .5px solid var(--line); }
.list a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.list small { color: var(--muted); font-size: 13px; }

.contact { padding: 0 var(--pad); display: grid; gap: 14px; max-width: 640px; }
.contact h2 { margin-top: 14px; font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding-left: 16px; }
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.group li { display: flex; justify-content: space-between; gap: 16px; padding: 0 16px; min-height: 50px; align-items: center; border-bottom: .5px solid var(--line); font-size: 16px; }
.group li:last-child { border-bottom: 0; }
.group li > span:first-child { color: var(--muted); }
.group li > :last-child { text-align: right; overflow-wrap: anywhere; }
.group a:hover { text-decoration: underline; }

/* Content adapts to the width of #view, not the window: the same rules work
   inside Demo A's phone frame and next to Demo B's sidebar. */
#view { container-type: inline-size; }
@container (min-width: 700px) { #view > * { --pad: 24px; } .grid { --cols: 4; } .albums { grid-template-columns: repeat(3, 1fr); } }
@container (min-width: 900px) { .about { grid-template-columns: minmax(280px, 400px) 1fr; gap: 48px; } }
@container (min-width: 1000px) { .grid { --cols: 5; } .albums { grid-template-columns: repeat(4, 1fr); } }
@container (min-width: 1300px) { .grid { --cols: 6; } .albums { grid-template-columns: repeat(5, 1fr); } }
@container (min-width: 1700px) { .grid { --cols: 8; } }

/* ── viewer ────────────────────────────────────────────────────────────── */
.viewer {
  position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  color: var(--fg); background: rgb(0 0 0 / var(--dim, 1)); overflow: hidden; user-select: none; -webkit-user-select: none;
  container: viewer / size;
}
.viewer:not([open]) { display: none; }
.v-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; outline: none; transition: inset .3s ease; }
.v-track { display: flex; height: 100%; will-change: transform; transition: transform var(--advance, .36s) var(--advance-ease, cubic-bezier(.25, .8, .25, 1)); }
.v-track.dragging, .v-track.instant { transition: none; }
.v-slide { flex: 0 0 100%; height: 100%; display: grid; place-items: center; padding: 0 var(--slide-gap, 8px); container-type: size; }
.v-media { width: 100%; width: min(100cqw, 100cqh * var(--ar)); aspect-ratio: var(--ar); background-color: transparent; }
.v-media img, .v-media video, .v-media iframe { width: 100%; height: 100%; object-fit: contain; border: 0; display: block; }
.v-bar { position: absolute; left: 0; right: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px calc(var(--sar) + 10px) 8px calc(var(--sal) + 10px); transition: opacity .2s; pointer-events: none; }
.v-bar > * { pointer-events: auto; }
.v-top { top: 0; padding-top: calc(var(--sat) + 8px); background: linear-gradient(rgb(0 0 0 / .5), transparent); }
.v-bottom { bottom: 0; justify-content: center; padding-bottom: calc(var(--sab) + 10px); background: linear-gradient(transparent, rgb(0 0 0 / .5)); }
.v-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: rgb(40 40 40 / .55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
span.v-btn { visibility: hidden; }
.v-btn svg { width: 22px; height: 22px; stroke-width: 2; }
[aria-expanded="true"].v-btn { background: var(--fg); color: #000; }
.v-title { display: grid; text-align: center; min-width: 0; font-size: 15px; line-height: 1.25; text-shadow: 0 1px 8px rgb(0 0 0 / .6); }
.v-title strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-title span { font-size: 12px; color: #d2d2d7; }
.v-nav { position: absolute; top: 50%; translate: 0 -50%; z-index: 4; display: none; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: rgb(40 40 40 / .55); transition: opacity .2s; }
.v-prev { left: calc(var(--sal) + 14px); }
.v-next { right: calc(var(--sar) + 14px); }
.v-nav:disabled { opacity: 0; pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .v-nav { display: grid; } }
.viewer.zoomed .v-bar, .viewer.zoomed .v-nav { opacity: 0; pointer-events: none; }
.viewer.zoomed .v-bar > * { pointer-events: none; }

.v-info {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; max-height: 48%; overflow: auto; overscroll-behavior: contain;
  display: grid; gap: 12px; align-content: start; padding: 22px calc(var(--pad) + var(--sar)) calc(var(--sab) + 80px) calc(var(--pad) + var(--sal));
  background: rgb(22 22 22 / .94); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border-radius: 16px 16px 0 0;
  animation: sheet-up .32s cubic-bezier(.2, .8, .2, 1); user-select: text; -webkit-user-select: text;
}
.v-info h2 { font-size: 22px; font-weight: 650; }
.viewer.info-open .v-stage { inset: 0 0 48% 0; }
@keyframes sheet-up { from { translate: 0 100%; } }
@keyframes sheet-side { from { translate: 100% 0; } }
@container viewer (min-width: 900px) {
  .v-info { top: 0; left: auto; width: 380px; max-height: none; border-radius: 0; padding-top: calc(var(--sat) + 76px); animation-name: sheet-side; }
  .viewer.info-open .v-stage { inset: 0 380px 0 0; }
  .viewer.info-open .v-next { right: 394px; }
}

/* ── transitions ───────────────────────────────────────────────────────── */
::view-transition-group(hero) { animation-duration: .42s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-old(hero), ::view-transition-new(hero) { height: 100%; object-fit: cover; overflow: clip; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
