/* Brainrotpedia — a phone-shaped feed: the clip fills the
   screen, the actions run down the right, captions sit low in the middle,
   sheets slide up from the bottom. On a wide screen it's a phone-width
   column in the middle. Everything sits above the hub's bar (overlay page:
   the app stops at --random-nav-h). */
:root {
  --bg: #0b0b10;
  --ink: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --sheet: #17171f;
  --line: rgba(255, 255, 255, 0.12);
  --hl: #ffe14d;
  --like: #ff3b5c;
  --cap: clamp(22px, 7vw, 30px);
  --nav: var(--random-nav-h, 0px);
  --top: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
html.cap-s { --cap: clamp(18px, 5.6vw, 24px); }
html.cap-l { --cap: clamp(28px, 9vw, 38px); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body { font: 15px/1.35 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  position: fixed; top: 0; bottom: var(--nav); left: 0; right: 0;
  width: min(100%, calc((100dvh - var(--nav)) * 0.5625)); margin-inline: auto;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
/* a phone (anything taller than 4:3 standing up) gets all of it, edge to edge; and anything held in the hand, a phone on its side
   or an iPad either way round, gets the whole screen too (a phone-shaped column in the middle of a landscape iPad is mostly black,
   and on a phone on its side it's a sliver). A computer with a mouse keeps the column. */
@media (max-aspect-ratio: 3/4), (pointer: coarse) { .app { width: 100%; } }
.viewport, .track, .stage { position: absolute; inset: 0; }
.viewport { overflow: hidden; }
.track { will-change: transform; }
.track.anim { transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1); }
.stage { touch-action: none; background: #222; }
#world { display: block; width: 100%; height: 100%; }
.shade {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.35), transparent 14%, transparent 55%, rgba(0, 0, 0, 0.55));
}

/* the next and previous clips, peeking while you drag */
.peek, .cover {
  position: absolute; left: 0; right: 0; height: 100%;
  display: grid; place-items: center; padding: 0 28px; text-align: center;
  font-weight: 900; font-size: clamp(26px, 8vw, 40px); line-height: 1.05; letter-spacing: -0.01em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.peek.prev { top: -100%; }
.peek.next { top: 100%; }
.peek small, .cover small { display: block; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; margin-bottom: 10px; }
.cover { top: 0; pointer-events: none; opacity: 0; }
.cover.on { opacity: 1; }
.cover.fade { transition: opacity 0.35s ease-out; }

/* captions: one line at a time, the words lit as they're said */
.caption {
  /* up in the sky, clear of the subject: the backdrops frame the car, the marble and the plane in the lower half */
  position: absolute; left: 16px; right: 16px; top: calc(var(--top) + 128px); margin: 0; /* (centred: up here the rail is below) */
  text-align: center; font-weight: 850; font-size: var(--cap); line-height: 1.18;
  letter-spacing: -0.005em; color: #fff; pointer-events: none;
  -webkit-text-stroke: 0.16em #000; paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
}
/* (a little room each side, so the word being said can grow without eating the space) */
/* (a short screen brings the rail up level with the captions: there they keep clear of it) */
@media (max-height: 720px) { .caption { right: 74px; } }
.caption .w { display: inline-block; padding: 0 0.07em; transition: transform 0.08s, color 0.08s; }
.caption .w.said { color: var(--hl); }
.caption .w.now { color: var(--hl); transform: translateY(-0.06em); } /* (a lift, not a grow: growing a long word eats the spaces beside it) */

/* the article's photos, popping in on a sentence's beat: a polaroid, tilted, up in the left column just under the captions
   (--photo-top, set as each one shows), beside the subject rather than on it: the backdrops frame theirs low in the middle */
.photo {
  /* as wide as its photo (a portrait stays whole), the caption wrapping to it */
  position: absolute; left: 14px; top: var(--photo-top, 34%); width: max-content; max-width: 46%; margin: 0; padding: 6px 6px 0;
  background: #fff; border-radius: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); pointer-events: none;
  transform: rotate(var(--rot, -4deg)); transform-origin: 30% 20%;
}
.photo img { display: block; width: auto; height: auto; max-width: min(42vw, 200px); max-height: 22vh; border-radius: 3px; background: #ddd; }
.photo figcaption { color: #222; font: 600 10px/1.3 ui-sans-serif, system-ui, sans-serif; padding: 5px 2px 7px; min-height: 8px; width: 0; min-width: 100%; }
.photo.in { animation: photoIn 0.42s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.photo.out { animation: photoOut 0.3s ease-in both; }
@keyframes photoIn { from { opacity: 0; transform: translate(-30%, 10%) rotate(calc(var(--rot, -4deg) * -3)) scale(0.5); } }
@keyframes photoOut { to { opacity: 0; transform: translate(-70%, -20%) rotate(calc(var(--rot, -4deg) - 25deg)) scale(0.7); } }
@media (prefers-reduced-motion: reduce) {
  @keyframes photoIn { from { opacity: 0; } }
  @keyframes photoOut { to { opacity: 0; } }
}
html.reduced .photo.in { animation-name: fadeIn; } html.reduced .photo.out { animation-name: fadeOut; }
@keyframes fadeIn { from { opacity: 0; } } @keyframes fadeOut { to { opacity: 0; } }

.meta { position: absolute; left: 14px; right: 80px; bottom: 18px; pointer-events: none; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.meta p { margin: 0 0 4px; }
.handle { font-weight: 800; font-size: 16px; }
.desc { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.source {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
  padding: 5px 10px 5px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.45);
  color: #fff; text-decoration: none; font-size: 13px; font-weight: 700; max-width: 100%;
}
.source svg { width: 16px; height: 16px; flex: none; }
.source span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the progress bar, and the strip along the foot of the clip that scrubs it: press it and it thickens, a knob on it, and dragging
   along it moves through the clip (the captions follow; the narrator waits, then carries on from the word you let go on) */
.scrub { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; z-index: 3; touch-action: none; cursor: pointer; }
.scrub:focus { outline: none; } .scrub:focus-visible .progress { outline: 2px solid var(--hl); outline-offset: 2px; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, 0.2); transition: height 0.12s; }
.progress i { display: block; height: 100%; width: 0; background: #fff; }
.knob { position: absolute; bottom: -4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); transform: scale(0); transition: transform 0.12s; left: var(--at, 0%); }
.scrub:hover .progress, .scrub.on .progress { height: 6px; }
.scrub.on .knob { transform: scale(1); }
.scrub-bubble { position: absolute; bottom: 34px; left: var(--bx, 50%); transform: translateX(-50%); z-index: 4; margin: 0; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 12px 7px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.78); color: #fff; white-space: nowrap; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); }
.scrub-bubble .t { font: 600 12px/1 ui-sans-serif, system-ui, sans-serif; font-variant-numeric: tabular-nums; opacity: 0.8; }
.scrub-bubble .w { font-weight: 850; font-size: 20px; line-height: 1.1; color: var(--hl); }
/* while scrubbing, the description and the rail step back so the bubble reads */
.stage .meta, .stage .rail { transition: opacity 0.15s; }
.stage.scrubbing .meta, .stage.scrubbing .rail { opacity: 0.12; }
.paused-icon {
  position: absolute; left: 50%; top: 45%; width: 76px; height: 76px; transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.85); filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5)); pointer-events: none;
}

.top {
  position: absolute; top: calc(var(--top) + 10px); left: 0; right: 0;
  display: flex; justify-content: center; align-items: center; gap: 22px;
  font-weight: 800; font-size: 16px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.tab { color: var(--muted); padding: 4px 2px; }
.tab.on { color: #fff; border-bottom: 2px solid #fff; }
.gear { position: absolute; right: 12px; top: -4px; width: 36px; height: 36px; display: grid; place-items: center; }
.gear svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }

.badge2x, .chip {
  position: absolute; top: calc(var(--top) + 52px); left: 50%; transform: translateX(-50%);
  margin: 0; padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.6);
  font-weight: 800; font-size: 13px; display: flex; align-items: center; gap: 6px; white-space: nowrap; pointer-events: none;
}
.chip { top: calc(var(--top) + 88px); font-weight: 600; }
.badge2x svg { width: 16px; height: 16px; }

.rail {
  position: absolute; right: 8px; bottom: 112px; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.rail button { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 56px; }
.rail svg { width: 36px; height: 36px; fill: #fff; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55)); }
.rail svg .dot { fill: #333; }
.rail b { font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.rail #like[aria-pressed="true"] svg { fill: var(--like); }
.rail #like.pop svg { animation: pop 0.35s; }
@keyframes pop { 40% { transform: scale(1.3); } }
#sound .on { display: none; }
#sound[aria-pressed="true"] .on { display: block; }
#sound[aria-pressed="true"] .off { display: none; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid #fff; margin-bottom: 6px;
  display: grid; place-items: center; font-weight: 900; font-size: 20px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.rail button:focus-visible, .top button:focus-visible, .source:focus-visible { outline: 2px solid var(--hl); outline-offset: 2px; border-radius: 8px; }

.toast {
  position: absolute; left: 50%; bottom: 40%; transform: translateX(-50%); margin: 0;
  padding: 8px 14px; border-radius: 10px; background: rgba(0, 0, 0, 0.78); font-weight: 700; pointer-events: none;
}

/* sheets: comments and settings */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 72%; overflow: auto; overscroll-behavior: contain;
  background: var(--sheet); border-radius: 16px 16px 0 0; animation: up 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
  user-select: text; -webkit-user-select: text;
}
@keyframes up { from { transform: translateY(100%); } }
.sheet header { position: sticky; top: 0; background: var(--sheet); display: flex; align-items: center; justify-content: center; padding: 14px 44px 10px; border-bottom: 1px solid var(--line); z-index: 1; }
.sheet h2 { margin: 0; font-size: 15px; }
.close { position: absolute; right: 8px; top: 6px; width: 36px; height: 36px; font-size: 26px; line-height: 1; color: var(--muted); }
.comments { list-style: none; margin: 0; padding: 8px 16px 24px; }
.comments li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 10px 0; }
.comments .face { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; }
.comments .who { font-size: 13px; color: var(--muted); font-weight: 600; }
.comments .who em { font-style: normal; font-weight: 800; color: #6fe3c1; margin-left: 4px; }
.comments p { margin: 2px 0 0; }
.comments .ago { font-size: 12px; color: rgba(255, 255, 255, 0.45); }
.comments .likes { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--muted); }
.comments .likes svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
/* a comment's link to another clip: a card, like a shared TikTok */
.rich { display: flex; gap: 10px; align-items: center; width: 100%; margin: 6px 0 4px; padding: 6px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); text-align: left; }
.rich:hover, .rich:focus-visible { background: rgba(255, 255, 255, 0.12); }
.rich .thumb { flex: none; width: 46px; height: 64px; border-radius: 6px; display: grid; place-items: center; }
.rich .thumb svg { width: 20px; height: 20px; fill: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
.rich .txt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rich b { font-size: 14px; }
.rich small { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.settings { padding: 12px 16px 28px; display: grid; gap: 16px; }
.settings fieldset { border: 0; margin: 0; padding: 0; }
.settings legend { font-weight: 800; margin-bottom: 8px; padding: 0; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button, .chips button { padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); font-weight: 700; }
.seg button[aria-pressed="true"] { background: #fff; color: #000; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { display: inline-flex; align-items: center; gap: 6px; }
.chips button i { width: 12px; height: 12px; border-radius: 50%; }
.chips button[aria-pressed="false"] { opacity: 0.45; text-decoration: line-through; }
.switch { display: flex; gap: 10px; align-items: flex-start; }
.switch input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--hl); flex: none; }
.voice-status { margin: 0; color: var(--muted); font-size: 14px; }
.voice-status button { text-decoration: underline; font-weight: 700; }
.settings details summary { font-weight: 800; cursor: pointer; }
.settings details p { color: var(--muted); font-size: 14px; }
.settings a { color: #fff; }

/* the long press's menu */
.more-list { display: grid; padding: 6px 0 18px; }
.more-list button { text-align: left; padding: 14px 18px; font-weight: 700; border-bottom: 1px solid var(--line); }
.more-list button:last-child { border-bottom: 0; }
/* the fact of the day's badge */
.day-badge { position: absolute; top: calc(var(--top) + 52px); left: 50%; transform: translateX(-50%); margin: 0; padding: 5px 12px; border-radius: 999px;
  background: var(--hl); color: #1a1400; font-weight: 900; font-size: 13px; letter-spacing: 0.02em; pointer-events: none; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); }
/* the saved clips, profile style */
.likes-line { margin: 6px 0 0; font-size: 14px; color: #fff; }
.likes-line b { color: var(--hl); }
.saved-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; }
.saved-tools input { flex: 1 1 140px; min-width: 0; padding: 8px 12px; border-radius: 999px; border: 0; background: rgba(255, 255, 255, 0.1); color: #fff; font: inherit; }
.saved-tools select { padding: 8px 10px; border-radius: 999px; border: 0; background: rgba(255, 255, 255, 0.1); color: #fff; font: inherit; }
.saved-tools button { padding: 8px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); font-weight: 700; }
.saved-tools button#savedPlay { background: #fff; color: #000; }
.profile { position: absolute; inset: 0; background: var(--bg); overflow: auto; animation: up 0.24s cubic-bezier(0.2, 0.7, 0.2, 1); }
.profile header { position: relative; text-align: center; padding: calc(var(--top) + 28px) 16px 14px; border-bottom: 1px solid var(--line); }
.profile .close { top: calc(var(--top) + 8px); }
.profile .me { display: block; width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 50%; background: conic-gradient(#ff5c8a, #ffd166, #06d6a0, #2f6bff, #9b5de5, #ff5c8a); border: 3px solid #fff; }
.profile h2 { margin: 0; font-size: 18px; }
.profile .stats { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.profile .empty { text-align: center; color: var(--muted); padding: 40px 24px; margin: 0; }
.grid { list-style: none; margin: 0; padding: 2px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.grid button { position: relative; width: 100%; aspect-ratio: 9 / 16; display: flex; align-items: flex-end; padding: 8px; text-align: left; font-weight: 800; font-size: 13px; line-height: 1.15; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45); overflow: hidden; }
.grid button small { position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 700; opacity: 0.85; }

/* the loading screen: the icon, the name, a line and a bar, over everything for a second or two, then a fade */
.loading { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 24px; text-align: center; background: radial-gradient(120% 80% at 50% 38%, #2a1530, var(--bg) 70%); transition: opacity 0.35s ease-out; }
.loading.gone { opacity: 0; pointer-events: none; }
.loading img { width: 112px; height: 112px; animation: bob 1.6s ease-in-out infinite; }
.loading h1 { margin: 6px 0 0; font-size: 26px; line-height: 1.1; font-weight: 900; letter-spacing: -0.01em; max-width: 12em; }
.loading p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
.loading .bar { display: block; width: 140px; height: 4px; margin-top: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.14); overflow: hidden; position: relative; }
.loading .bar::after { content: ""; position: absolute; inset: 0; width: 40%; border-radius: 4px; background: var(--hl); animation: sweep 1.1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

@media (prefers-reduced-motion: reduce) {
  .loading img, .loading .bar::after { animation: none; }
  .loading .bar::after { width: 100%; opacity: 0.6; }
  .sheet, .profile { animation: none; }
  .track.anim { transition-duration: 0.01s; }
}

/* ---- other screens ----
   A big one held in the hand (an iPad, either way round: the clip fills it, above): the clip's own controls grow with it, and the captions with them, kept to a
   width that reads; the sheets sit in the middle at a readable width; the saved grid has more across. */
@media (min-width: 700px) and (min-height: 700px) and (pointer: coarse) {
  :root { --cap: clamp(30px, 3.4vmax, 46px); }
  .rail, .meta, .top, .badge2x, .chip, .scrub-bubble { zoom: 1.3; }
  .meta { right: 120px; }
  .caption { left: max(16px, calc(50% - 460px)); right: max(16px, calc(50% - 460px)); top: calc(var(--top) + 150px); }
  .sheet { left: 0; right: 0; margin-inline: auto; max-width: 560px; border-radius: 16px 16px 0 0; zoom: 1.25; }
  .profile header, .profile .empty { zoom: 1.25; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .photo img { max-width: min(30vw, 300px); max-height: 26vh; }
}
/* a short one (a phone on its side): everything tighter, the captions higher and smaller so the clip shows between them and
   the description, the rail closer together */
@media (max-height: 500px) {
  :root { --cap: clamp(17px, 5.4vh, 24px); }
  .caption { top: calc(var(--top) + 46px); left: 90px; right: 90px; }
  .top { top: calc(var(--top) + 4px); font-size: 14px; }
  .rail { bottom: 46px; gap: 6px; zoom: 0.8; }
  .avatar { display: none; }
  .meta { bottom: 10px; right: 140px; }
  .desc { -webkit-line-clamp: 1; }
  .sheet { left: 0; right: 0; margin-inline: auto; max-width: 560px; max-height: 88%; }
  .profile header { padding-top: calc(var(--top) + 12px); }
  .profile .me { width: 48px; height: 48px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .badge2x { top: calc(var(--top) + 30px); }
}
/* the biggest iPads: a step bigger again */
@media (min-width: 1000px) and (min-height: 1000px) and (pointer: coarse) {
  .rail, .meta, .top, .badge2x, .chip, .scrub-bubble { zoom: 1.55; }
  .meta { right: 150px; }
}
