/* Dynamic Text Lab: the poster on the left (on top on phones), its settings on the right, and a bar along the bottom
   for playback and exports. The look follows the Replit version: white and light grey, near-square corners, and one
   blue for everything that's on or chosen. */
:root {
 --background: #fff;
 --foreground: hsl(0 0% 5%);
 --border: hsl(0 0% 88%);
 --card: hsl(0 0% 98%);
 --muted: hsl(0 0% 95%);
 --muted-foreground: hsl(0 0% 45%);
 --primary: hsl(234 74% 56%);
 --primary-soft: hsl(234 74% 56% / .2);
 --input: hsl(0 0% 85%);
 --button-outline: rgba(0, 0, 0, .1);
 --hover: rgba(0, 0, 0, .03);
 --press: rgba(0, 0, 0, .08);
 --radius: 2px;
 --sans: 'Space Grotesk', sans-serif;
 --mono: Menlo, monospace;
 --header: 48px;
 --bar: 56px;
}
@media (min-width: 768px) { :root { --header: 64px; --bar: 64px; } }

*, *::before, *::after { box-sizing: border-box; border: 0 solid var(--border); }
html, body { margin: 0; height: 100%; }
body {
 display: flex; flex-direction: column; overflow: hidden;
 background: var(--background); color: var(--foreground);
 font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, p { margin: 0; font: inherit; }
button, input, textarea { font: inherit; color: inherit; margin: 0; }
button { background: none; padding: 0; cursor: pointer; }
svg { display: block; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--primary); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Header ---------- */
.lab-header {
 position: relative; z-index: 10; flex-shrink: 0; height: var(--header);
 display: flex; align-items: center; justify-content: space-between; gap: 8px;
 padding: 0 12px; border-bottom-width: 1px; background: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.wordmark { display: flex; gap: 6px; flex-shrink: 0; font-family: 'Press Start 2P', monospace; font-size: 10px; }
.wordmark .accent { color: var(--primary); }
.made-by {
 display: none; margin-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
 font: 12px/16px var(--mono); color: var(--muted-foreground); text-decoration: none; transition: color .15s;
}
.made-by:hover { color: var(--primary); }
.header-tools { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ratios { display: flex; padding: 2px; border-width: 1px; border-radius: var(--radius); background: var(--muted); }
.ratios button {
 padding: 4px 8px; font: 10px/1.5 var(--mono); color: var(--muted-foreground); transition: color .15s, background-color .15s;
}
.ratios button:hover { color: var(--foreground); }
.ratios button[aria-pressed="true"] { background: var(--primary); color: #fff; font-weight: 600; }
.icon-button {
 position: relative; display: inline-flex; align-items: center; justify-content: center;
 width: 32px; height: 32px; border: 1px solid transparent; border-radius: var(--radius); color: var(--muted-foreground);
}
.icon-button:hover { color: var(--foreground); }
.icon-button svg { width: 14px; height: 14px; }
/* The narrowest phones need a smaller title and tighter shape buttons for the whole title to fit */
@media (max-width: 419px) {
 .wordmark { font-size: 8px; }
 .ratios button { padding: 4px 5px; }
}
@media (min-width: 768px) {
 .lab-header { padding: 0 24px; }
 .wordmark { gap: 8px; font-size: 14px; }
 .header-tools { gap: 8px; }
 .ratios { padding: 4px; }
 .ratios button { padding: 6px 12px; font-size: 12px; line-height: 16px; }
 .icon-button { width: 40px; height: 40px; }
 .icon-button svg { width: 16px; height: 16px; }
}
@media (min-width: 1024px) {
 .wordmark { gap: 12px; font-size: 16px; }
 .made-by { display: block; }
}

/* ---------- Buttons ---------- */
/* Outline buttons darken a touch on hover and a little more while pressed */
.button {
 position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
 min-height: 36px; padding: 8px 16px; white-space: nowrap;
 font-size: 14px; line-height: 20px; font-weight: 500;
 border: 1px solid var(--button-outline); border-radius: var(--radius); transition: color .15s, border-color .15s;
}
.button::after, .icon-button::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; }
.button:hover::after, .icon-button:hover::after { background: var(--hover); }
.button:active::after, .icon-button:active::after { background: var(--press); }
.button:disabled { opacity: .5; pointer-events: none; }
.button svg { width: 16px; height: 16px; }
.button.wide { width: 100%; }
.button.small-text { font-size: 12px; line-height: 16px; font-weight: 600; }

/* ---------- Layout ---------- */
.lab { display: flex; flex-direction: column; height: calc(100svh - var(--header) - var(--bar)); overflow: hidden; }
.canvas-area {
 position: relative; flex: 0 0 auto; height: max(42vw, 220px); max-height: 52svh; min-height: 0; background: hsl(0 0% 95% / .3);
}
/* The poster always fits whole inside its grey stage */
.preview {
 position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
 padding: 12px; overflow: hidden; background: #f3f4f6; border-width: 1px; border-radius: 4px;
}
.preview canvas {
 display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain;
 border: 1px solid hsl(0 0% 88% / .5); background: #fff;
}
.preview:fullscreen { border: 0; border-radius: 0; }
.export-overlay {
 position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center;
 background: rgba(255, 255, 255, .8); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.export-overlay[hidden] { display: none; }
.export-overlay p { margin-bottom: 16px; color: var(--primary); font: 700 20px/28px var(--mono); animation: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite; }
.export-track { width: 256px; max-width: 80%; height: 8px; overflow: hidden; border-radius: 9999px; background: var(--muted); }
.export-fill { width: 0; height: 100%; background: var(--primary); transition: width .3s; }
@keyframes pulse { 50% { opacity: .5; } }

.controls { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-top-width: 1px; background: var(--card); }
.controls-scroll { flex: 1; overflow-y: auto; padding: 16px 16px 112px; scrollbar-width: thin; }
@media (min-width: 768px) {
 .lab { flex-direction: row; }
 .canvas-area { flex: 1 1 0%; height: auto; max-height: none; }
 .controls { flex: none; width: 400px; border-top-width: 0; border-left-width: 1px; }
 .controls-scroll { padding: 24px 24px 112px; }
}

/* ---------- Settings ---------- */
.panel-section + .panel-section { margin-top: 32px; }
.panel-section h2 {
 margin-bottom: 16px; font: 600 12px/16px var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--muted-foreground);
}
.stack-2 > * + * { margin-top: 8px; }
.stack-3 > * + * { margin-top: 12px; }
.stack-4 > * + * { margin-top: 16px; }
.stack-6 > * + * { margin-top: 24px; }
.top-gap-2 { padding-top: 8px; }
.divided { padding-top: 16px; border-top-width: 1px; }
.field-label { font-size: 12px; line-height: 16px; font-weight: 600; }

textarea {
 display: block; width: 100%; min-height: 100px; resize: vertical; padding: 8px 12px;
 font: 16px/24px var(--mono); background: var(--card); border: 1px solid var(--input); border-radius: var(--radius);
}
.toggle-row {
 display: flex; align-items: center; justify-content: space-between; gap: 12px;
 padding: 12px; border-width: 1px; border-radius: var(--radius); background: var(--card);
}
.toggle-title { font-size: 14px; line-height: 20px; font-weight: 500; }
.toggle-hint { margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.switch {
 position: relative; flex-shrink: 0; display: inline-flex; align-items: center; width: 36px; height: 20px;
 border: 2px solid transparent; border-radius: 9999px; background: var(--input); transition: background-color .15s;
}
.switch span { width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"] span { transform: translateX(16px); }
.switch:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary); }

/* A dropdown's button, and the list it opens */
.select-button { width: 100%; justify-content: space-between; background: var(--card); }
.select-button.mono { font-family: var(--mono); }
.select-value { overflow: hidden; text-overflow: ellipsis; }
.select-button .chevron { opacity: .5; margin-left: 8px; }
.menu {
 position: fixed; z-index: 9999; max-height: 288px; overflow-y: auto; padding: 4px 0;
 background: var(--card); border-width: 1px; border-radius: var(--radius);
}
.menu.effects { max-height: 256px; }
.menu button { display: block; width: 100%; padding: 8px 12px; text-align: left; font-size: 14px; line-height: 20px; transition: background-color .15s; }
.menu button:hover, .menu button:focus-visible { background: var(--muted); box-shadow: none; }
.menu button[aria-selected="true"] { background: var(--muted); font-weight: 600; }
.menu .effect-name { font-family: var(--mono); }
.menu .effect-description { display: block; margin-top: 2px; font-size: 12px; line-height: 16px; font-weight: 400; color: var(--muted-foreground); }

/* Sliders: a thin blue-tinted track that fills with blue up to a white thumb */
.slider-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; line-height: 16px; }
.slider-head label { font-weight: 600; }
.slider-head output { font-family: var(--mono); }
.slider { --fill: 50%; display: block; width: 100%; height: 16px; margin: 0; background: none; cursor: pointer; -webkit-appearance: none; appearance: none; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 9999px; background: linear-gradient(to right, var(--primary) var(--fill), var(--primary-soft) var(--fill)); }
.slider::-webkit-slider-thumb {
 -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%;
 background: var(--background); border: 1px solid hsl(234 74% 56% / .5); transition: box-shadow .15s;
}
.slider::-moz-range-track { height: 6px; border-radius: 9999px; background: var(--primary-soft); }
.slider::-moz-range-progress { height: 6px; border-radius: 9999px; background: var(--primary); }
.slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--background); border: 1px solid hsl(234 74% 56% / .5); }
.slider:focus-visible { box-shadow: none; }
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--primary); }
.slider:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--primary); }

/* Colour: a saturation/brightness square, a hue strip, a hex field and ten presets */
.color-picker > * + * { margin-top: 12px; }
.color-area {
 --hue: #f00; position: relative; height: 128px; overflow: hidden; cursor: crosshair; user-select: none; touch-action: none;
 border-width: 1px; border-radius: var(--radius);
 background: linear-gradient(to bottom, transparent 0%, #000 100%), linear-gradient(to right, #fff 0%, var(--hue) 100%);
}
.color-knob {
 position: absolute; width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; pointer-events: none;
 transform: translate(-50%, -50%); box-shadow: 0 0 0 1px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .4);
}
.hue-slider {
 display: block; width: 100%; height: 12px; border-radius: 9999px; cursor: pointer; -webkit-appearance: none; appearance: none;
 background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
 border: 1px solid var(--border);
}
.hue-slider::-webkit-slider-thumb {
 -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
 background: #fff; border: 2px solid rgba(0, 0, 0, .25); box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.hue-slider::-moz-range-thumb {
 width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
 background: #fff; border: 2px solid rgba(0, 0, 0, .25); box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.hex-row { display: flex; align-items: center; gap: 8px; }
.color-swatch { flex-shrink: 0; width: 36px; height: 36px; border-width: 1px; border-radius: var(--radius); }
.hex-input {
 flex: 1; min-width: 0; height: 36px; padding: 4px 12px; font: 16px/24px var(--mono);
 background: var(--card); border: 1px solid var(--input); border-radius: var(--radius);
}
.presets { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.presets button { aspect-ratio: 1; border-width: 1px; transition: transform .15s, border-color .15s, box-shadow .15s; }
.presets button:hover { transform: scale(1.1); border-color: var(--muted-foreground); }
.presets button[aria-pressed="true"] { transform: scale(1.05); border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

/* Backgrounds: a scrolling grid of square thumbnails, the videos first */
.bg-picker { height: 192px; overflow-y: auto; padding: 8px; border-width: 1px; border-radius: var(--radius); background: var(--card); }
.bg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bg-tile {
 position: relative; display: block; aspect-ratio: 1; overflow: hidden;
 border: 2px solid transparent; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.bg-tile:hover { border-color: hsl(0 0% 45% / .5); }
.bg-tile[aria-pressed="true"] { transform: scale(.95); border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.bg-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bg-tile .play-badge { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .2); }
.play-badge span { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(255, 255, 255, .8); }
.play-badge svg { width: 12px; height: 12px; margin-left: 2px; fill: #000; stroke: #000; }

/* ---------- Bottom bar ---------- */
.control-bar {
 position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: var(--bar);
 display: flex; align-items: center; justify-content: space-between; padding: 0 12px;
 border-top-width: 1px; background: hsl(0 0% 98% / .95); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.playback { display: flex; align-items: center; gap: 8px; }
.button.round { width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 50%; }
.button.round svg { width: 14px; height: 14px; }
body.is-playing .button.round { color: var(--primary); border-color: var(--primary); }
body.is-playing .when-paused, body:not(.is-playing) .when-playing { display: none; }
.when-paused { margin-left: 2px; }
.loop-status { display: flex; align-items: center; gap: 6px; font: 500 10px/1.5 var(--mono); color: var(--muted-foreground); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: oklch(63.7% .237 25.331); }
body.is-playing .status-dot { background: oklch(72.3% .219 149.579); animation: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite; }
.wide-only { display: none; }
.exports { display: flex; align-items: center; gap: 6px; }
/* Phones get just the icons */
.button.export { width: 32px; height: 32px; min-height: 0; padding: 0; }
.button.export svg { width: 14px; height: 14px; }
.button.export span { display: none; }
@media (min-width: 640px) {
 .wide-only { display: inline; }
 .narrow-only { display: none; }
}
@media (min-width: 768px) {
 .control-bar { padding: 0 24px; }
 .playback { gap: 16px; }
 .button.round { width: 40px; height: 40px; }
 .loop-status { gap: 8px; font-size: 12px; line-height: 16px; }
 .status-dot { width: 8px; height: 8px; }
 .exports { gap: 8px; }
 .button.export { width: auto; height: auto; min-height: 36px; padding: 8px 16px; font-size: 12px; line-height: 16px; font-weight: 600; }
 .button.export svg { width: 16px; height: 16px; }
 .button.export span { display: inline; }
 textarea { font-size: 14px; line-height: 20px; }
 .hex-input { font-size: 14px; line-height: 20px; }
}
