/* Copyright (c) CrossRoads Digital Media LLC. All rights reserved. */
/* Defines the internal recording canvas, phone frame, HUD, and review surface. */

:root {
  color-scheme: dark;
  font-family: "Work Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --surface: #111619;
  --surface-raised: #182024;
  --border: #29353a;
  --text: #f3fafb;
  --muted: #91a4aa;
  --teal: #4ecdc4;
  --purple: #6c4ce8;
  --stage-ratio: 9 / 16;
  --phone-scale: 0.82;
  --phone-x: 0px;
  --phone-y: 0px;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050708;
  color: var(--text);
}

button,
select,
input { font: inherit; }

button { color: inherit; }

#studio-root {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 24px 344px 24px 24px;
  background: #050708;
}

.capture-stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: var(--stage-ratio);
  width: auto;
  height: min(calc(100vh - 48px), calc((100vw - 392px) * 16 / 9));
  max-width: calc(100vw - 392px);
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 18px 70px rgb(0 0 0 / 48%);
}

.capture-stage.stage-wide {
  --stage-ratio: 16 / 9;
  width: min(calc(100vw - 392px), calc((100vh - 48px) * 16 / 9));
  height: auto;
}

.background-black { background: #000; }

.background-crossroads {
  background:
    linear-gradient(118deg, transparent 0 35%, rgb(21 136 132 / 30%) 45%, transparent 55%),
    linear-gradient(62deg, transparent 0 42%, rgb(88 48 212 / 34%) 51%, transparent 61%),
    radial-gradient(circle at 16% 18%, rgb(20 112 110 / 46%), transparent 33%),
    radial-gradient(circle at 84% 82%, rgb(82 41 193 / 48%), transparent 38%),
    #071013;
}

.background-night {
  background:
    radial-gradient(ellipse at 68% 112%, rgb(57 45 140 / 48%), transparent 46%),
    radial-gradient(ellipse at 22% 8%, rgb(17 51 86 / 38%), transparent 42%),
    linear-gradient(168deg, #010207 0%, #050b17 52%, #0d1026 100%);
}

.background-opening {
  background:
    radial-gradient(ellipse at 50% 18%, rgb(255 255 255 / 8%), transparent 34%),
    radial-gradient(ellipse at 50% 72%, rgb(47 58 63 / 26%), transparent 45%),
    linear-gradient(145deg, #080b0d 0%, #151a1d 48%, #07090a 100%);
}

.stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  left: var(--star-x);
  top: var(--star-y);
  width: var(--star-size);
  height: var(--star-size);
  border-radius: 50%;
  background: rgb(255 255 255 / var(--star-alpha));
  box-shadow: 0 0 var(--star-glow) rgb(128 199 255 / 48%);
}

.background-night .stars { opacity: 0.72; }
.hide-decoration .stars { display: none; }

.phone-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 393px;
  aspect-ratio: 393 / 852;
  overflow: visible;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 55px;
  background:
    linear-gradient(145deg, rgb(255 255 255 / 13%), transparent 18% 82%, rgb(255 255 255 / 8%)),
    #080a0b;
  box-shadow:
    0 34px 90px rgb(0 0 0 / 58%),
    0 9px 24px rgb(0 0 0 / 38%),
    inset 0 0 0 1px rgb(255 255 255 / 11%),
    inset 0 0 0 7px #050607;
  transform:
    translate(-50%, -50%)
    translate(var(--phone-x), var(--phone-y))
    scale(var(--phone-scale));
  transform-origin: center;
  transition: transform 160ms ease, border-radius 160ms ease, box-shadow 160ms ease;
  z-index: 2;
}

.phone-frame::before {
  position: absolute;
  inset: 8px;
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 47px;
  background: #0c151b;
  box-shadow: inset 0 0 22px rgb(0 0 0 / 28%);
  content: "";
  pointer-events: none;
}

.phone-frame.frame-hidden {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.frame-hidden::before { display: none; }

.phone-speaker {
  position: absolute;
  top: 15px;
  left: 50%;
  width: 112px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 4%);
  background: #000;
  box-shadow: 0 2px 7px rgb(0 0 0 / 52%);
  transform: translateX(-50%);
  z-index: 7;
  pointer-events: none;
}

.phone-camera {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 35%, #456f88 0 8%, #152935 24%, #06090c 62%);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 7%);
  transform: translateY(-50%);
}

.phone-button {
  position: absolute;
  width: 4px;
  border: 1px solid rgb(255 255 255 / 12%);
  background: linear-gradient(90deg, #090b0c, #303538 48%, #080a0b);
  box-shadow: 0 3px 9px rgb(0 0 0 / 45%);
  pointer-events: none;
}

.phone-button-action { top: 118px; left: -4px; height: 34px; border-radius: 3px 0 0 3px; }
.phone-button-volume-up { top: 174px; left: -4px; height: 64px; border-radius: 3px 0 0 3px; }
.phone-button-volume-down { top: 251px; left: -4px; height: 64px; border-radius: 3px 0 0 3px; }
.phone-button-power { top: 184px; right: -4px; height: 104px; border-radius: 0 3px 3px 0; }

.phone-home-indicator {
  position: absolute;
  bottom: 12px;
  left: 50%;
  width: 112px;
  height: 4px;
  border-radius: 999px;
  background: rgb(235 242 244 / 72%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 38%);
  transform: translateX(-50%);
  z-index: 7;
  pointer-events: none;
}

.frame-hidden .phone-speaker,
.frame-hidden .phone-button,
.frame-hidden .phone-home-indicator { display: none; }

.flutter-host {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 38px;
  background: #0c151b;
}

.phone-frame:not(.frame-hidden) .flutter-host {
  position: absolute;
  inset: 53px 9px 26px;
  width: auto;
  height: auto;
  border-radius: 0 0 43px 43px;
}

.frame-hidden .flutter-host {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.studio-hud {
  position: fixed;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: 304px;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgb(17 22 25 / 94%);
  box-shadow: 0 18px 64px rgb(0 0 0 / 42%);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.brand-row,
.preview-header,
.range-label > span,
.check-row,
.preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p { margin: 0; }

h1,
h2 {
  font-family: "Space Grotesk", Inter, system-ui, sans-serif;
  letter-spacing: -0.03em;
}

h1 { font-size: 27px; }
h2 { font-size: 23px; }

.eyebrow {
  margin-bottom: 2px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

fieldset {
  margin: 24px 0 18px;
  padding: 0;
  border: 0;
}

legend,
label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 8px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #0a0e10;
}

.segmented button,
.secondary-button,
.primary-button,
.icon-button,
.show-hud {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 7%);
}

.help-text,
.shortcut,
.status {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.help-text { margin-top: 8px; }

select {
  width: 100%;
  height: 42px;
  margin: 7px 0 18px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: #0a0e10;
}

.range-label {
  display: block;
  margin-bottom: 17px;
}

input[type="range"] {
  width: 100%;
  margin: 9px 0 0;
  accent-color: var(--teal);
}

output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.position-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check-row {
  justify-content: flex-start;
  min-height: 34px;
  color: var(--text);
  cursor: pointer;
}

.check-row input { accent-color: var(--teal); }

.capture-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 18px;
}

.record-button,
.screenshot-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 9px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.record-button { background: linear-gradient(90deg, #094d52, #39218d); }
.screenshot-button { background: #1a2428; }

.record-button:hover,
.screenshot-button:hover { filter: brightness(1.1); }
.record-button:disabled,
.screenshot-button:disabled { cursor: wait; opacity: 0.62; }

.record-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff4f5e;
  box-shadow: 0 0 0 4px rgb(255 79 94 / 14%);
}

.screenshot-icon {
  position: relative;
  width: 17px;
  height: 13px;
  border: 2px solid #d9f8f5;
  border-radius: 3px;
}

.screenshot-icon::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border: 1px solid #d9f8f5;
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.screenshot-icon::after {
  position: absolute;
  top: -5px;
  left: 2px;
  width: 7px;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: #d9f8f5;
  content: "";
}

.shortcut { margin-top: 9px; text-align: center; }
.status { margin-top: 8px; text-align: center; color: var(--teal); }

.icon-button {
  width: 40px;
  flex: 0 0 40px;
  color: var(--muted);
  font-size: 25px;
}

.icon-button:hover,
.icon-button:focus-visible { color: #fff; background: var(--surface-raised); }

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgb(0 0 0 / 28%);
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: clamp(96px, 16vw, 280px);
  font-weight: 700;
  text-shadow: 0 8px 38px rgb(0 0 0 / 65%);
  z-index: 30;
}

.countdown[hidden] { display: none; }

.show-hud {
  position: fixed;
  top: 18px;
  right: 18px;
  padding: 0 15px;
  border: 1px solid var(--border);
  background: rgb(17 22 25 / 92%);
  z-index: 25;
}

.preview-dialog {
  width: min(900px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 28px 100px rgb(0 0 0 / 65%);
}

.preview-dialog::backdrop { background: rgb(0 0 0 / 72%); backdrop-filter: blur(8px); }

.preview-dialog video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 250px);
  margin-top: 18px;
  background: #000;
}

.preview-dialog img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 250px);
  margin-top: 18px;
  object-fit: contain;
  background: #000;
}

.preview-dialog [hidden] { display: none; }

.preview-actions { justify-content: flex-end; margin-top: 16px; }

.secondary-button,
.primary-button { padding: 0 18px; }
.secondary-button { border: 1px solid var(--border); }
.primary-button { background: var(--teal); color: #061112; font-weight: 700; }

body.hud-hidden #studio-hud { display: none; }
body.recording #studio-hud,
body.recording #show-hud { display: none; }

body.recording #studio-root {
  padding: 0;
  background: #000;
}

body.recording .capture-stage {
  width: auto;
  height: 100vh;
  max-width: 100vw;
  box-shadow: none;
}

body.recording .capture-stage.stage-wide {
  width: 100vw;
  height: auto;
}

@media (max-width: 980px) {
  #studio-root { padding: 16px; }
  .studio-hud { right: 16px; bottom: 16px; top: auto; width: min(360px, calc(100vw - 32px)); max-height: 72vh; }
  .capture-stage { max-width: calc(100vw - 32px); height: calc(100vh - 32px); }
  .capture-stage.stage-wide { width: calc(100vw - 32px); }
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
