/* Hide navcheck globally (desktop & mobile) */
#navcheck{display:none}


/* Topbar grid on mobile/desktop fix */
@media (min-width: 769px){
  .topbar{
    display:grid;
    grid-template-columns: auto 1fr auto;
    align-items:center;
  }
}
@media (max-width: 768px){
  .topbar{
    display:grid;
    grid-template-columns: auto 1fr auto;
  }
  /* Keep layout: logo | burger | dial (nav drops below when opened) */
  .brand-link{ order: 1; }
  .hamburger { order: 2; justify-self:end; }
  .dial{ order: 3; grid-column: 1 / -1; justify-self:center; margin-top:4px; }
  .mainnav{ order: 4; }
}


/* Center main sections */
@media (max-width: 1024px){
  .cassette, .chat-card{ 
    margin-inline: auto;
    width: min(96%, 1100px);
  }
}


/* Force show mainnav on desktop */
@media (min-width: 769px){
  .mainnav{ display:flex !important; position: static !important; }
  .hamburger{ display:none !important; }
}


/* --- Fix mobile horizontal scrolling & enforce box sizing --- */
html, body { overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }

:root {
  --tap: 48px;
  --space: clamp(12px, 2vw, 18px);
  --fs-body: clamp(14px, 1.8vw, 16px);
  --fs-title: clamp(18px, 2.6vw, 24px);
}

html {
  font-size: 100%;
}

body {
  font-size: var(--fs-body);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.topbar {
  padding: clamp(10px, 2.5vw, 16px) clamp(12px, 3vw, 24px);
  gap: clamp(8px, 2vw, 16px);
}

.topbar .logo {
  max-height: clamp(30px, 5vw, 44px);
}

.dial {
  font-size: clamp(16px, 3.4vw, 28px);
  white-space: nowrap;
}

.mainnav {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(6px, 1.6vw, 14px);
}

.mainnav .tab {
  padding: 8px 12px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(13px, 1.6vw, 15px);
}

.cassette {
  padding: clamp(12px, 2.5vw, 20px);
}

.cassette .transport {
  gap: clamp(10px, 2.4vw, 16px);
}

.cassette .transport .btn-ctrl {
  width: var(--tap);
  height: var(--tap);
}

.cassette .marquee {
  height: clamp(22px, 3.4vw, 26px);
  width: 100%; max-width: 540px;
}

.cassette .marquee span {
  font-size: clamp(12px, 1.8vw, 13px);
}

.vol-row {
  gap: clamp(8px, 2vw, 12px);
}

.volume {
  width: 100%; max-width: 520px;
}

.vu .vu-title {
  font-size: clamp(12px, 1.8vw, 14px);
}

.vu canvas {
  height: clamp(130px, 26vw, 180px);
}

.chat-card {
  margin-top: clamp(16px, 3.5vw, 28px);
}

.chat-head {
  padding: 10px clamp(10px, 3vw, 16px);
}

.chat-box {
  height: clamp(280px, 42vh, 360px);
  padding: clamp(12px, 2.8vw, 18px);
}

.chat-input {
  min-height: var(--tap);
}

.emoji-btn, .btn.btn--primary {
  min-height: var(--tap);
}

@media (max-width: 1024px) {
.vu-wrap {
  grid-template-columns: 1fr;
  gap: clamp(10px, 3vw, 18px);
  width: min(96%, 940px);
}

.speaker {
  width: clamp(160px, 28vw, 190px);
  height: clamp(160px, 28vw, 190px);
  margin-inline: auto;
}
}


@media (max-width: 768px) {
.topbar {
  position: relative;
  align-items: center;
}

.topbar:has(.hamburger) .mainnav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(8,10,22,.96);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 10px;
  margin-top: 8px;
  box-shadow: 0 20px 40px rgba(0,0,0,.45);
  z-index: 40;
  flex-direction: column;
  gap: 6px;
}

#navcheck {
  display: none;
}

#navcheck:checked + .hamburger + .mainnav {
  display: flex;
}

.hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(18,16,40,.8);
  gap: 0;
}

.hamburger .bar,
  .hamburger::before,
  .hamburger::after {
  content: "";
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: #c9defc;
  box-shadow: 0 0 6px rgba(99,230,255,.35);
  position: relative;
}

.hamburger::before {
  transform: translateY(-6px);
}

.hamburger::after {
  transform: translateY(6px);
}

.dial {
  order: 3;
  width: 100%;
  text-align: center;
  margin-top: 4px;
}

.cassette {
  padding: 12px;
}

.vu-wrap {
  grid-template-columns: 1fr;
  gap: 14px;
}

.speaker {
  display: none !important;
}

.vu-bars {
  gap: 14px;
}

.vu canvas {
  width: 100%;
  height: clamp(130px, 30vw, 180px);
}

.volume {
  width: 92vw;
}

.chat-form {
  position: sticky;
  bottom: 0;
  background: inherit;
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 10px);
}

.chat-box {
  max-height: 46vh;
}

.emoji-panel {
  right: 50% !important;
  left: auto;
  transform: translateX(50%);
  bottom: calc(var(--tap) + 14px);
  width: min(92vw, 360px);
}

.emoji-grid {
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  font-size: 22px;
}
}


@media (max-width: 480px) {
.topbar {
  padding: 8px 12px;
}

.mainnav .tab {
  padding: 10px 8px;
  font-size: 13px;
}

.cassette {
  padding: 10px;
}

.vu canvas {
  height: 132px;
}

.chat-box {
  max-height: 44vh;
}
}


button, .btn-ctrl, .btn, .emoji-item {
  -webkit-tap-highlight-color: rgba(255,255,255,0.08);
}

:focus-visible {
  outline: 2px solid rgba(99,230,255,.75);
  outline-offset: 2px;
}



/* ===== Mobile refinements (visual balance) ===== */

/* Bigger, more present logo & dial on small screens */
.topbar .logo{
  max-height: clamp(48px, 10vw, 90px);
}
.dial{
  font-size: clamp(22px, 5vw, 36px);
}

/* Navigation tabs a bit larger for readability */
.mainnav .tab{
  padding: 10px 12px;
  font-size: clamp(14px, 2.2vw, 17px);
}

/* Player controls: larger tap targets */
.cassette .transport .btn-ctrl{
  width: calc(var(--tap) + 6px);
  height: calc(var(--tap) + 6px);
}

/* Marquee spacing */
.cassette .marquee{ margin-top: 6px; }

/* VU canvas taller on phones */
.vu canvas{
  height: clamp(150px, 34vw, 200px);
}

/* Clock size adjustment on small screens */
@media (max-width: 768px){
  .cassette .digital-clock{ font-size: clamp(18px, 5vw, 24px); }
}

/* Chat: more comfortable height */
@media (max-width: 768px){
  .chat-box{ max-height: 50vh; }
}

/* Footer collaborators: logo size on small screens */
@media (max-width: 520px){
  .site-footer .logos img{ height: clamp(36px, 9vw, 56px); }
}


/* Safety widths */
img, canvas, video, svg { max-width: 100%; height: auto; }
.cassette, .chat-card, .site-footer, .vu, .vu-wrap, .marquee, .volume { overflow-x: clip; }


/* ===== FINAL MOBILE HEADER & CENTERING FIX ===== */
html, body { overflow-x: hidden; }

#navcheck{ display:none !important; }

@media (min-width: 769px){
  .topbar{
    display:grid;
    grid-template-columns:auto 1fr auto;
    align-items:center;
    position:relative;
  }
  .mainnav{ display:flex !important; position:static !important; }
  .hamburger{ display:none !important; }
}

@media (max-width: 768px){
  .topbar{
    display:grid;
    grid-template-columns:auto 1fr auto;
    align-items:center;
    position:relative;
  }
  .hamburger{
    display:inline-flex !important;
    align-items:center; justify-content:center;
    width:46px; height:40px; border-radius:10px;
    border:1px solid rgba(255,255,255,.14);
    background: rgba(18,16,40,.8);
    z-index:60;
  }
  .hamburger .bar{ display:block; width:22px; height:2px; border-radius:2px; background:#c9defc; box-shadow:0 0 6px rgba(99,230,255,.35); }
  .hamburger .bar + .bar{ margin-top:5px; }
  .dial{ grid-column:1 / -1; justify-self:center; margin-top:4px; width:100%; text-align:center; }

  .mainnav{
    display:none;
    position:absolute;
    left:12px; right:12px; top:calc(100% + 8px);
    background: rgba(8,10,22,.96);
    border:1px solid rgba(255,255,255,.08);
    border-radius:14px;
    padding:10px; gap:6px;
    box-shadow:0 20px 40px rgba(0,0,0,.45);
    z-index:55;
    flex-direction:column;
  }
  #navcheck:checked + .hamburger + .mainnav{ display:flex; }

  .section.card, .cassette, .chat-card{ width:min(96%, 720px); margin-inline:auto; }
  .volume{ width:100% !important; max-width:520px; }
  .cassette .marquee{ width:100% !important; max-width:540px; }
}

@media (max-width: 1024px){
  .section.card, .cassette, .chat-card{ width:min(96%, 940px); margin-inline:auto; }
}


/* --- Improved hamburger icon + open/close state --- */
@media (max-width: 768px){
  .hamburger{ color:#c9defc; }
  #navcheck:checked + .hamburger .hamburger-icon path{
    d: path("M3 3 L23 15 M23 3 L3 15"); /* fallback won't render in some browsers */
  }
  /* Use rotation cross effect as wider support */
  #navcheck:checked + .hamburger .hamburger-icon{
    transform: rotate(90deg) scale(0.9);
    transition: transform .18s ease;
  }
  .hamburger .hamburger-icon{ transition: transform .18s ease; }
}

/* --- Strong centering of player and chat on mobile --- */
@media (max-width: 768px){
  .cassette, .chat-card{
    display:block;
    max-width: 720px;
    width: 96%;
    margin-left: auto !important;
    margin-right: auto !important;
    left: auto !important; right: auto !important;
  }
  main{ overflow-x: clip; }
}


/* ===== Super strict narrow fix (<=392px) ===== */
@media (max-width: 392px){
  /* Ensure the outer cards never overflow the viewport */
  .cassette, .chat-card{
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 auto !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  /* The VU wrapper is usually the culprit (had fixed 220px columns) */
  .vu-wrap{
    display: grid !important;
    grid-template-columns: 1fr !important;   /* stack vertically */
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .speaker{ display: none !important; }      /* hide big side speakers on very small phones */
  .vu{ padding: 12px 10px 14px !important; }
  .vu-bars{
    display:flex !important;
    flex-direction: column !important;       /* stack L/R bars */
    gap: 10px !important;
    width: 100% !important;
  }
  .vu canvas{
    width: 100% !important;
    height: 120px !important;
  }

  /* Transport row and volume slider */
  .transport .btn-ctrl{ width: 38px !important; height: 38px !important; }
  .volume{ width: 100% !important; }

  /* Marquee fits container */
  .marquee{ width: 100% !important; }

  /* Chat internals must not exceed parent */
  .chat-head, .chat-box, .chat-form{
    width: 100% !important;
    max-width: 100% !important;
  }
  /* Emoji panel should not push width */
  .emoji-panel{ max-width: 100% !important; right: 0 !important; left: auto !important; }
}


/* ===== Narrow phones hard-fix (<=392px) — keep VU side‑by‑side & avoid clipping ===== */
@media (max-width: 392px){
  /* Cards occupy the viewport width but never overflow */
  .section.card, .cassette, .chat-card{
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    box-sizing: border-box !important;
  }

  /* Speakers off on tiny phones, but keep meters side‑by‑side */
  .cassette .vu-wrap{
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .cassette .speaker{ display: none !important; }

  .cassette .vu{ padding: 12px 10px 14px !important; }
  .cassette .vu-bars{
    display: flex !important;
    flex-direction: row !important;              /* <- keep L/R next to each other */
    justify-content: space-between !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .cassette .vu-bars canvas{
    flex: 1 1 0 !important;
    width: auto !important;                       /* allow flex to distribute */
    min-width: 0 !important;
    height: 130px !important;
  }

  /* Sliders / marquee span full width */
  .cassette .marquee{ width: 100% !important; max-width: 100% !important; }
  .volume{ width: 100% !important; max-width: 100% !important; }

  /* Chat internals respect container width */
  .chat-head, .chat-box, .chat-form{ width: 100% !important; max-width: 100% !important; }
  .emoji-panel{ right: 50% !important; transform: translateX(50%); left:auto !important; max-width: 92vw !important; }
}
