/* ============================================================================
 * Unified app header — persistent in Basic, Advanced and Auto Video.
 * Replaces the old #advancedOverlayChrome bar AND OpenCut's internal editor
 * header. There is exactly ONE chrome row across the top.
 *
 * Layout: fixed top, full width, glass backdrop, safe-area-aware.
 * Z-index: 40 — above the stage (default), above the Advanced overlay (25),
 * and above the settings panel (30). Always reachable.
 * ========================================================================== */

#vizzyHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 var(--space-4);
  padding-top: env(safe-area-inset-top);
  padding-left: max(var(--space-4), env(safe-area-inset-left));
  padding-right: max(var(--space-4), env(safe-area-inset-right));
  box-sizing: content-box;
  background: var(--surface-1);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--hairline);
  color: var(--ink);
  font-family: var(--font-body);
  /* The header itself is non-blocking by default — interactive children
     re-enable pointer events for themselves. Lets clicks fall through to
     the stage on the empty middle band. */
  pointer-events: auto;
}

.vh-left,
.vh-center,
.vh-right {
  display: flex;
  align-items: center;
  pointer-events: auto;
}
.vh-left   { flex: 1 1 0;   justify-content: flex-start; gap: var(--space-3); min-width: 0; }
.vh-center { flex: 0 0 auto; justify-content: center; }
.vh-right  { flex: 1 1 0;   justify-content: flex-end;   gap: var(--space-2); }

/* Brand mark + wordmark — the dot is the only place the accent color appears
   in the chrome at rest, so the brand reads as Vizzy without shouting. ----- */
.vh-mark {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  /* The markup carries a "●" glyph for no-CSS fallback; hide it so it
     doesn't paint a second white dot over the 9px mark. */
  font-size: 0;
  line-height: 0;
  color: transparent;
  overflow: hidden;
  /* Use the mark as a visual pulse anchor — animation could ride on beats
     in a later pass; static for now so it doesn't fight focus. */
}
.vh-brand {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.32em;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  /* hide on phone — the dot is enough branding */
}

/* Mode pill — segmented control. The thumb is a span that absolute-positions
   to the active option, animated with transform for crisp motion. ----------- */
.vh-mode-pill {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  height: 32px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--surface-4);
  border: 1px solid var(--hairline-2);
  user-select: none;
  font-size: 12px;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.vh-mode-opt {
  position: relative;
  z-index: 1;
  background: none;
  border: 0;
  color: var(--ink-3);
  padding: 0 18px;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  transition: color 0.2s var(--ease-out);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
}
.vh-mode-opt.is-active {
  color: #0a0a0a;
}
.vh-mode-opt:focus-visible {
  outline: 2px solid var(--ink-2);
  outline-offset: 2px;
}

/* Thumb is an absolutely-positioned highlight that slides between options.
   Width / x-offset are set inline via JS so the thumb matches the chosen
   option's measured width — handles text-length differences cleanly. */
.vh-mode-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: 0;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #fff, rgba(255,255,255,0.88));
  box-shadow: 0 1px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.6);
  transition: transform 260ms var(--ease-out),
              width 260ms var(--ease-out);
  pointer-events: none;
  z-index: 0;
}

/* Right-side icon buttons -------------------------------------------------- */
.vh-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-4);
  border: 1px solid var(--hairline);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s var(--ease-out),
              border-color 0.15s var(--ease-out),
              color 0.15s var(--ease-out),
              transform 0.1s var(--ease-out);
  font-family: inherit;
}
.vh-icon-btn:hover {
  background: var(--surface-4);
  border-color: var(--hairline-2);
  color: var(--ink);
}
.vh-icon-btn:active { transform: scale(0.94); }
.vh-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Record button — ⏺ at rest; while recording it pulses red and grows to
   show the elapsed time (export.js toggles .is-recording). */
.vh-rec-btn {
  width: auto;
  min-width: 36px;
  padding: 0 var(--space-2);
  gap: 6px;
  color: var(--ink-3);
}
.vh-rec-icon { font-size: 14px; line-height: 1; color: var(--record); opacity: 0.85; }
.vh-rec-time {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.vh-rec-time:empty { display: none; }
.vh-rec-btn:hover .vh-rec-icon { opacity: 1; }
.vh-rec-btn.is-recording {
  color: #fff;
  background: rgba(255, 48, 80, 0.22);
  border-color: var(--record);
  animation: vhRecPulse 1.4s ease-in-out infinite;
}
.vh-rec-btn.is-recording .vh-rec-icon { opacity: 1; }
@keyframes vhRecPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--record-glow); }
  50%      { box-shadow: 0 0 14px 2px var(--record-glow); }
}

/* Auto-hide during Basic playback (controls.js adds body.chrome-hidden with
   the transport; any move / tap / key brings both back). */
#vizzyHeader {
  transition: transform 0.4s var(--ease-out), opacity 0.4s var(--ease-out);
}
body.chrome-hidden #vizzyHeader {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

/* Mobile tuning ------------------------------------------------------------ */
@media (max-width: 767px) {
  #vizzyHeader {
    height: 48px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .vh-brand { display: none; }
  .vh-mode-pill {
    height: 30px;
    font-size: 11px;
  }
  .vh-mode-opt { padding: 0 9px; }
  .vh-right { padding-left: var(--space-1); }
  /* Recording on a phone: the elapsed time replaces the ⏺ glyph so the
     wider button never crowds the mode pill. */
  .vh-rec-btn.is-recording .vh-rec-icon { display: none; }
  .vh-rec-time { font-size: 11px; }
  .vh-mode-opt::before {
    content: '';
    position: absolute;
    inset: -7px 0;
  }
  /* ≥44px tap targets: the button stays compact visually, a transparent
     ::after extends the hit area. */
  .vh-icon-btn {
    position: relative;
    width: 36px;
    height: 36px;
  }
  .vh-icon-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
  }
  .vh-right { gap: var(--space-1); }
}

/* Push the body content down so the stage / overlay don't slide under the
   fixed header. Using a CSS var so other components can reference the same
   total height (including safe area). */
:root {
  --vizzy-header-height: calc(52px + env(safe-area-inset-top));
}
@media (max-width: 767px) {
  :root {
    --vizzy-header-height: calc(48px + env(safe-area-inset-top));
  }
}

/* Basic-only header controls (Record, ⚙ drawer) hide in Advanced / Auto Video. */
body:not([data-mode="basic"]) #recordBtn,
body:not([data-mode="basic"]) #vhSettingsBtn { display: none; }

/* Touch screens wider than the phone breakpoint (landscape phones): the
   same invisible ≥44px hit areas as the portrait phone layout. */
@media (pointer: coarse) {
  .vh-icon-btn { position: relative; }
  .vh-icon-btn::after { content: ''; position: absolute; inset: -4px; }
  .vh-mode-opt::before { content: ''; position: absolute; inset: -7px 0; }
}
