/* Halus Player — match live site tokens (website-live-reference/style.css) */

:root {
  --bg:       #07090c;
  --panel:    #0f141b;
  --panel-2:  #131922;
  --line:     #1f2833;
  --text:     #e9edf3;
  --dim:      #97a3b4;
  --cyan:     #2de1d6;
  --cyan-hi:  #7ff5ee;
  --cyan-lo:  #148f88;
  --font-head:"Space Grotesk", system-ui, sans-serif;
  --font-body:"Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:"JetBrains Mono", ui-monospace, monospace;

  --topbar-h: 56px;
  --drawer-h: min(280px, 38vh);
  --btn-h: 36px;
  --btn-radius: 10px;
  --bezel-pad: 10px;
  --bezel-radius: 14px;
  --screen-radius: 6px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---- ambient background (from live site) -------------------------------- */

.glow {
  position: fixed;
  top: -30vh;
  left: 50%;
  width: min(120vw, 1100px);
  height: min(120vw, 1100px);
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(45,225,214,.16) 0%, rgba(45,225,214,.05) 35%, transparent 68%);
  pointer-events: none;
  z-index: 0;
}

.grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(45,225,214,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45,225,214,.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 0%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

/* ---- app shell ---------------------------------------------------------- */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100dvh;
  max-height: 100dvh;
}

/* ---- top bar (OUTSIDE the bezel) ---------------------------------------- */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--topbar-h);
  padding: 0.55rem 1rem;
  background: rgba(7, 9, 12, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.wordmark {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  line-height: 1;
  text-decoration: none;
  background: linear-gradient(180deg, #ffffff 0%, var(--cyan-hi) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.wordmark:hover {
  text-decoration: none;
  filter: brightness(1.08);
}

.player-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border: 1px solid rgba(45, 225, 214, 0.35);
  border-radius: 999px;
  background: rgba(45, 225, 214, 0.08);
  font-family: var(--font-head);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--cyan);
  white-space: nowrap;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

/* ---- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--btn-h);
  padding: 0 0.95rem;
  border-radius: var(--btn-radius);
  font-family: var(--font-head);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s, opacity 0.15s;
  user-select: none;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-primary {
  background: var(--cyan);
  border: 1px solid var(--cyan);
  color: #04231f;
}
.btn-primary:hover:not(:disabled) { background: var(--cyan-hi); border-color: var(--cyan-hi); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
}
.btn-ghost:hover:not(:disabled) {
  border-color: rgba(45, 225, 214, 0.35);
  color: var(--text);
}

.btn-send {
  height: 32px;
  padding: 0 0.85rem;
  background: transparent;
  border: 1px solid rgba(45, 225, 214, 0.4);
  border-radius: 8px;
  color: var(--cyan);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.btn-send:hover:not(:disabled) {
  background: rgba(45, 225, 214, 0.1);
  border-color: var(--cyan);
}

.page-select-wrap { display: inline-flex; }

.demo-select {
  min-width: 9rem;
  max-width: 14rem;
}

.page-select {
  height: var(--btn-h);
  min-width: 7.5rem;
  max-width: 11rem;
  padding: 0 1.8rem 0 0.7rem;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--panel-2);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 55%,
    calc(100% - 9px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--line);
  border-radius: var(--btn-radius);
  color: var(--text);
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.page-select:disabled {
  opacity: 0.45;
  cursor: default;
}
.page-select:focus {
  outline: none;
  border-color: var(--cyan-lo);
  box-shadow: 0 0 0 3px rgba(45, 225, 214, 0.14);
}

/* ---- stage + device bezel ----------------------------------------------- */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem;
  overflow: hidden;
}

.device {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: min(920px, 100%);
  max-height: 100%;
}

.bezel {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  /* default pre-load frame; JS overrides from model size when loaded */
  aspect-ratio: 800 / 480;
  padding: var(--bezel-pad);
  border-radius: var(--bezel-radius);
  transition: box-shadow 0.35s ease, aspect-ratio 0.2s ease;
  background:
    linear-gradient(145deg, #1a222c 0%, #0c1016 45%, #151c26 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(45, 225, 214, 0.12),
    0 28px 70px rgba(45, 225, 214, 0.08);
}

.bezel.loaded {
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(45, 225, 214, 0.22),
    0 32px 80px rgba(45, 225, 214, 0.14);
}

.screen {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--screen-radius);
  background: #05070a;
  overflow: hidden;
  /* edge highlight around the glass */
  box-shadow:
    inset 0 0 0 1px rgba(45, 225, 214, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ---- drop zone (pre-load, inside bezel only) ---------------------------- */

.drop-zone {
  position: absolute;
  inset: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  border: 1.5px dashed rgba(45, 225, 214, 0.45);
  border-radius: 8px;
  background: rgba(15, 20, 27, 0.55);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  text-align: center;
  padding: 0.85rem 1rem 1rem;
  outline: none;
  overflow: auto;
}

.drop-zone.drag-over {
  border-color: var(--cyan-hi);
  background: rgba(45, 225, 214, 0.1);
  box-shadow: 0 0 28px rgba(45, 225, 214, 0.18);
}

.drop-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  border-radius: var(--btn-radius);
  padding: 0.35rem 0.5rem;
  outline: none;
}

.drop-main:hover,
.drop-main:focus-visible {
  /* keep the zone highlight language when the browse target is focused */
}

.drop-zone:has(.drop-main:hover),
.drop-zone:has(.drop-main:focus-visible) {
  border-color: var(--cyan);
  background: rgba(45, 225, 214, 0.05);
}

.drop-title {
  margin: 0;
  font-family: var(--font-head);
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  font-weight: 500;
  color: var(--cyan);
  letter-spacing: -0.01em;
}

.drop-hint {
  margin: 0;
  font-size: clamp(0.75rem, 2.2vw, 0.88rem);
  color: var(--dim);
}

/* ---- pre-load demo gallery (from demos.json) ----------------------------- */

.demo-gallery {
  width: min(100%, 520px);
  flex: 0 1 auto;
  min-height: 0;
}

.demo-gallery-label {
  margin: 0 0 0.5rem;
  text-align: center;
}

.demo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  align-items: stretch;
}

.demo-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  flex: 1 1 9.5rem;
  max-width: 16rem;
  min-width: 8.5rem;
  margin: 0;
  padding: 0.55rem 0.7rem;
  text-align: left;
  cursor: pointer;
  border-radius: var(--btn-radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font-body);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.demo-chip:hover:not(:disabled),
.demo-chip:focus-visible {
  border-color: rgba(45, 225, 214, 0.45);
  background: rgba(45, 225, 214, 0.06);
  outline: none;
}

.demo-chip:active:not(:disabled) {
  transform: translateY(1px);
}

.demo-chip:disabled {
  opacity: 0.5;
  cursor: default;
}

.demo-chip.active {
  border-color: rgba(45, 225, 214, 0.55);
  background: rgba(45, 225, 214, 0.1);
  box-shadow: 0 0 0 1px rgba(45, 225, 214, 0.12);
}

.demo-chip-name {
  font-family: var(--font-head);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--cyan);
  line-height: 1.25;
}

.demo-chip-desc {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--dim);
}

/* ---- canvas host -------------------------------------------------------- */

.canvas-host {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

/* Fit model ratio (aspect-ratio + width/height set from canvas.width/height
   on load). Caps via max-*; letterbox in the host — never stretch both axes. */
.canvas-host canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* nearest-neighbor: keep panel pixels / gauge arcs sharp (DESIGN-NOTES crisp) */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: crosshair;
}

/* ---- inline frame messages ---------------------------------------------- */

.frame-error,
.frame-status {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  z-index: 2;
  pointer-events: none;
}

.frame-error {
  background: rgba(40, 12, 12, 0.92);
  border: 1px solid rgba(255, 122, 122, 0.45);
  color: #ff9a9a;
}

.frame-status {
  background: rgba(7, 9, 12, 0.88);
  border: 1px solid var(--line);
  color: var(--dim);
}

/* ---- bottom drawer (OUTSIDE the bezel) ---------------------------------- */

.drawer {
  flex: 0 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-height: 0;
  overflow: hidden;
  background: rgba(10, 13, 18, 0.97);
  border-top: 1px solid transparent;
  transition: max-height 0.28s ease, border-color 0.2s ease;
}

.drawer.open {
  flex: 0 0 auto;
  max-height: var(--drawer-h);
  height: var(--drawer-h);
  border-top-color: var(--line);
}

.drawer-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0.65rem 0.85rem 0.7rem;
  overflow: hidden;
}

.drawer-terminal {
  border-right: 1px solid var(--line);
}

.section-label {
  margin: 0 0 0.45rem;
  font-family: var(--font-head);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
}

.section-label-sub {
  margin: 0.7rem 0 0.35rem;
  color: var(--dim);
  letter-spacing: 0.1em;
}

/* terminal */

.term-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.45rem;
  background: #05070a;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  color: var(--dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.term-line { display: block; }
.term-line.tx { color: #5c6878; }
.term-line.rx { color: var(--cyan); }
.term-line.sys { color: var(--dim); }
.term-line.err { color: #ff9a9a; }

.term-input-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.term-prompt {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cyan);
  flex: 0 0 auto;
}

.term-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 32px;
  padding: 0 0.6rem;
  background: #05070a;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}
.term-input::placeholder { color: #5c6878; }
.term-input:focus {
  outline: none;
  border-color: var(--cyan-lo);
  box-shadow: 0 0 0 3px rgba(45, 225, 214, 0.12);
}

/* inspector tables */

.inspector-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.ids-table,
.channels-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.35;
}

.ids-table th,
.channels-table th {
  text-align: left;
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
  position: sticky;
  top: 0;
  background: rgba(10, 13, 18, 0.96);
}

.ids-table td,
.channels-table td {
  padding: 0.28rem 0.4rem;
  border-bottom: 1px solid rgba(31, 40, 51, 0.65);
  color: var(--text);
  vertical-align: top;
}

.ids-table tr:hover td,
.channels-table tr:hover td {
  background: rgba(45, 225, 214, 0.04);
}

.ids-table .empty-row td,
.channels-table .empty-row td {
  color: var(--dim);
  font-style: normal;
  text-align: center;
  padding: 0.75rem 0.4rem;
}

.ch-value {
  color: var(--cyan);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- utilities ---------------------------------------------------------- */

/* Author display rules beat the UA [hidden] { display:none }; force it. */
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- phone / narrow (390px first-class) --------------------------------- */

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    padding: 0.5rem 0.65rem;
    gap: 0.45rem;
  }

  .controls {
    width: 100%;
    justify-content: flex-start;
  }

  .btn {
    height: 34px;
    padding: 0 0.7rem;
    font-size: 0.82rem;
  }

  .page-select {
    height: 34px;
    min-width: 6.5rem;
    flex: 1 1 auto;
  }

  .stage {
    padding: 0.75rem 0.65rem;
  }

  .bezel {
    --bezel-pad: 7px;
    border-radius: 12px;
  }

  /* Drawer: full-width stacked overlay-style panel */
  .drawer.open {
    --drawer-h: min(48vh, 340px);
    height: var(--drawer-h);
    max-height: var(--drawer-h);
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .drawer-terminal {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .drawer-panel {
    padding: 0.5rem 0.65rem 0.55rem;
  }
}

@media (max-width: 420px) {
  .wordmark { font-size: 1.15rem; }
  .player-tag { font-size: 0.65rem; }
  .drop-zone { inset: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
