/* Phase 18: universal centering and mobile-safe section layout */
:root {
  --rockstar-gutter: clamp(1rem, 4vw, 2rem);
  --rockstar-header-offset: 84px;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  scroll-padding-top: var(--rockstar-header-offset);
}

body,
main,
.section-panel,
.section-shell,
.hero-content,
.split-layout,
.about-copy,
.slanted-shell,
.counter-skew,
.player-shell,
.mix-board,
.reviews-panel,
.admin-main,
.admin-panel,
.admin-card,
.upload-card {
  min-width: 0;
  max-width: 100%;
}

body {
  width: 100%;
  overflow-x: clip;
}

.section-panel {
  scroll-margin-top: var(--rockstar-header-offset);
}

h1,
h2,
h3,
.approved-review-heading h4,
.chromatic-title,
.section-heading,
.about-copy,
.reviews-heading,
.admin-hero {
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
  text-wrap: balance;
}

input,
select,
textarea,
button,
label,
fieldset,
.control-cluster {
  min-width: 0;
  max-width: 100%;
}

.site-header,
.admin-header {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.site-header nav {
  max-height: calc(100dvh - 84px - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.admin-tabs {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.admin-tabs button {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 900px) {
  :root { --rockstar-header-offset: 76px; }

  .section-panel {
    overflow: visible !important;
  }

  .section-shell {
    width: 100% !important;
    padding-inline: var(--rockstar-gutter);
    margin-inline: auto;
  }

  .section-heading,
  .section-heading.centered,
  .about-copy,
  .hero-copy,
  .reviews-heading,
  .approved-review-heading {
    width: 100%;
    margin-inline: auto;
    text-align: center;
  }

  .eyebrow {
    max-width: 100%;
    padding-inline: .25rem;
    font-size: .72rem;
    letter-spacing: .17em;
    line-height: 1.45;
    overflow-wrap: break-word;
  }

  h2 {
    width: 100%;
    font-size: clamp(2.15rem, 8.7vw, 4.25rem);
    line-height: 1.08;
    letter-spacing: -.035em;
  }

  .hero {
    min-height: 100svh;
    height: auto;
    align-items: start;
  }

  .hero-content {
    width: 100%;
    max-width: 760px;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    justify-items: center;
    gap: 0;
    padding: calc(5rem + env(safe-area-inset-top)) var(--rockstar-gutter) 3.25rem;
    margin-inline: auto;
    text-align: center;
  }

  .dj-portrait-wrap {
    width: min(96vw, 650px);
    height: auto !important;
    min-height: 0;
    aspect-ratio: 1 / 1.02;
    justify-self: center;
  }

  .hero-copy {
    margin-top: clamp(-2rem, -4vw, -.75rem) !important;
    padding-inline: .25rem;
  }

  .chromatic-title {
    width: 100%;
    max-width: 14ch;
    margin-inline: auto;
    font-size: clamp(2.3rem, 10.8vw, 4.6rem);
    line-height: 1;
    letter-spacing: -.045em;
  }

  .photonic-button {
    white-space: normal;
    text-align: center;
  }

  .about,
  .gallery-section,
  .player-section,
  .connect-section {
    min-height: auto;
    padding-block: 5.5rem 4.5rem;
  }

  .split-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 2rem;
  }

  .speaker-stage {
    width: 100%;
    min-height: 500px;
  }

  .about-copy {
    padding: clamp(1.1rem, 4vw, 1.75rem);
  }

  .typewriter {
    min-height: 0 !important;
    margin-top: 1.4rem;
    text-align: left;
  }

  .gallery-section {
    padding-block: 0 !important;
  }

  .slanted-shell {
    width: 100% !important;
    margin: 0 !important;
    padding: 5.5rem 0 4.5rem !important;
    transform: none !important;
  }

  .counter-skew {
    transform: none !important;
  }

  .gallery-tabs {
    display: flex;
    width: min(100%, 420px);
    margin-inline: auto;
  }

  .gallery-tab {
    flex: 1 1 0;
    padding-inline: .75rem;
  }

  .gallery-rail {
    width: 100%;
    max-width: 100%;
    grid-auto-columns: min(86vw, 520px);
    margin-inline: 0 !important;
    padding: 1rem .25rem 1.75rem;
  }

  .player-shell,
  .connect-section > .section-shell {
    width: 100%;
  }

  .media-player,
  .mix-board,
  .reviews-panel {
    width: 100%;
  }

  .mix-board {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .name-cluster,
  .fader-control,
  .toggle-bank,
  .phone-deck,
  .deck-pad,
  .jog-control,
  .submit-deck {
    grid-column: 1 !important;
  }

  .admin-main {
    width: 100%;
    padding-inline: var(--rockstar-gutter);
  }

  .admin-hero {
    text-align: center;
  }

  .admin-hero p:last-child {
    margin-inline: auto;
  }

  .admin-tabs {
    flex-wrap: nowrap;
    padding-bottom: .4rem;
  }
}

@media (max-width: 560px) {
  :root {
    --rockstar-gutter: max(.9rem, env(safe-area-inset-left));
    --rockstar-header-offset: 70px;
  }

  .site-header {
    height: 66px;
  }

  .site-header nav {
    left: .75rem;
    right: .75rem;
    width: auto;
    max-width: none;
  }

  h2 {
    font-size: clamp(1.95rem, 9.4vw, 3rem);
    line-height: 1.1;
  }

  .hero-content {
    padding-top: calc(4.75rem + env(safe-area-inset-top));
    padding-bottom: 2.75rem;
  }

  .dj-portrait-wrap {
    width: min(104vw, 560px);
  }

  .hero-copy {
    margin-top: -1.25rem !important;
  }

  .chromatic-title {
    max-width: 12.5ch;
    font-size: clamp(2.05rem, 11.2vw, 3.25rem);
  }

  .section-heading {
    margin-bottom: 1.5rem;
  }

  .speaker-stage {
    min-height: 430px;
  }

  .speaker-box {
    width: min(300px, 86vw);
  }

  .gallery-rail {
    grid-auto-columns: min(88vw, 420px);
  }

  .media-card,
  .video-placeholder {
    min-height: 280px;
  }

  .stream-orb {
    width: min(220px, 64vw);
  }

  .media-player,
  .mix-board,
  .reviews-panel,
  .admin-card,
  .upload-card {
    border-radius: 20px;
  }

  .mix-board,
  .reviews-panel {
    padding: 1rem;
  }

  .board-topline {
    gap: .35rem;
    font-size: .58rem;
    letter-spacing: .08em;
  }

  .toggle-bank {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .style-bar label,
  .style-bar select,
  .style-bar input {
    width: 100%;
  }

  .style-bar label {
    flex: 1 1 100%;
  }

  .emoji-picker {
    width: 100%;
    justify-content: space-between;
  }

  .admin-body {
    padding-top: 76px;
  }

  .admin-header {
    height: 66px;
  }

  .admin-header .photonic-button.compact {
    padding: .6rem .8rem;
    font-size: .72rem;
  }

  .admin-hero {
    padding-top: 2rem;
  }

  .admin-hero h1 {
    font-size: clamp(2rem, 11vw, 3.2rem);
  }

  .admin-row-header {
    display: grid;
  }
}

@media (max-width: 390px) {
  .chromatic-title {
    font-size: clamp(1.9rem, 10.8vw, 2.55rem);
  }

  h2 {
    font-size: clamp(1.8rem, 9vw, 2.45rem);
  }

  .eyebrow {
    font-size: .66rem;
    letter-spacing: .13em;
  }

  .gallery-tab {
    font-size: .76rem;
    letter-spacing: .08em;
  }

  .toggle-bank {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (orientation: landscape) and (max-height: 560px) and (max-width: 1000px) {
  .hero-content {
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr) !important;
    grid-template-rows: auto !important;
    max-width: 1000px;
    padding-top: 4.5rem;
    gap: .5rem;
  }

  .dj-portrait-wrap {
    width: min(48vw, 470px);
  }

  .hero-copy {
    margin-top: 0 !important;
    text-align: left;
  }

  .chromatic-title {
    margin-inline: 0;
    font-size: clamp(2rem, 6vw, 4rem);
  }
}
