/* Shared site header (matches public/index.html). Load with Tailwind CDN + producer-tools.css */

:root {
  --studio-font: "Courier New", Courier, monospace;
  --glow-intensity: 1;
}

/* Match index #body-tag: monospace + bold; nav pills override font-weight in breakpoints */
#site-header {
  font-family: var(--studio-font);
  font-weight: 700;
}

@media (min-width: 769px) {
  body.site-shell {
    padding-top: calc(6.75rem + env(safe-area-inset-top, 0px));
  }
}
@media (max-width: 768px) {
  html.site-shell {
    scroll-padding-top: calc(10rem + env(safe-area-inset-top, 0px));
  }
  body.site-shell {
    padding-top: calc(10.5rem + env(safe-area-inset-top, 0px));
  }
}

.header-btn {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid;
}
.header-btn-icon {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
}
.mobile-header-shell {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 10px 14px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding-top: max(6px, env(safe-area-inset-top, 0px));
  padding-bottom: 10px;
}
.mobile-header-brand {
  min-width: 0;
  line-height: 1.2;
}
.mobile-header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
.mobile-header-meta #user-status {
  max-width: min(18vw, 120px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}
.mobile-header-meta .mobile-header-auth-btn {
  flex-shrink: 0;
  white-space: nowrap;
}
/* .header-btn sets display:flex; it loads after Tailwind and overrides .hidden on desktop */
#site-header #panel-btn.hidden,
#site-header #customer-panel-btn.hidden {
  display: none !important;
}
.mobile-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}
.mobile-header-actions-track {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
}
.header-btn:hover {
  transform: translateY(-1px);
}
#site-header .mobile-header-actions-track > .header-btn:not(#arcade-btn),
#site-header .mobile-header-actions-track .tools-dropdown-root > .header-btn {
  transition-property: background-color, border-color, color, box-shadow, opacity;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}
#site-header .mobile-header-actions-track > .header-btn:not(#arcade-btn):hover,
#site-header .mobile-header-actions-track > .header-btn:not(#arcade-btn):focus-visible,
#site-header .mobile-header-actions-track > .header-btn:not(#arcade-btn):active,
#site-header .mobile-header-actions-track .tools-dropdown-root > .header-btn:hover,
#site-header .mobile-header-actions-track .tools-dropdown-root > .header-btn:focus-visible,
#site-header .mobile-header-actions-track .tools-dropdown-root > .header-btn:active {
  transform: none !important;
  animation: none !important;
}
#site-header #arcade-btn {
  position: relative;
  z-index: 1;
  margin-inline: 2px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease;
}
#site-header #arcade-btn:hover {
  animation: site-header-glitch 0.35s ease-in-out;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  #site-header #arcade-btn:hover {
    animation: none;
  }
}
.site-header-bar {
  background: rgba(0, 0, 0, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 100vw;
  box-sizing: border-box;
}
.mobile-header-meta-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 42px;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
}
.mobile-header-meta-icon-wrap #header-tempo-toggle {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  border: none;
  background: transparent;
  border-radius: 11px;
}
.mobile-header-meta-icon-wrap #disco-ball {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}
@supports (backdrop-filter: blur(12px)) {
  .site-header-bar {
    background: rgba(0, 0, 0, 0.72);
  }
}
#site-header.site-header-scroll-hidden {
  transform: translateY(-110%);
}
.tools-dropdown-root {
  position: relative;
}
.tools-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  background: #0a0a0a;
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 4px;
  padding: 6px 0;
  z-index: 60;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.tools-dropdown-panel.hidden {
  display: none;
}
.tools-dropdown-panel a {
  display: block;
  padding: 12px 16px;
  font-size: 13px;
  color: #e5e7eb;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.tools-dropdown-panel a:last-child {
  border-bottom: 0;
}
.tools-dropdown-panel a:hover {
  background: rgba(34, 197, 94, 0.08);
  color: #4ade80;
}

@keyframes site-header-glitch {
  0% {
    transform: translate(0);
    filter: hue-rotate(0deg);
  }
  20% {
    transform: translate(-2px, 2px);
    filter: hue-rotate(90deg);
  }
  40% {
    transform: translate(-2px, -2px);
    filter: hue-rotate(180deg);
  }
  60% {
    transform: translate(2px, 2px);
    filter: hue-rotate(270deg);
  }
  80% {
    transform: translate(2px, -2px);
    filter: hue-rotate(360deg);
  }
  100% {
    transform: translate(0);
    filter: hue-rotate(0deg);
  }
}
.glitch-hover:hover {
  animation: site-header-glitch 0.3s ease-in-out;
}

@media (min-width: 769px) {
  /* Desktop: keep email subtle so it doesn't dominate the header. */
  .mobile-header-meta #user-status {
    max-width: min(12vw, 96px);
    font-size: 9px;
    opacity: 0.9;
  }
  #site-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
  }
  /* Keep desktop header strictly one row:
     nav pills scroll horizontally instead of wrapping to a new line. */
  .mobile-header-actions-track {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mobile-header-actions-track::-webkit-scrollbar {
    display: none;
  }
  .mobile-header-actions-track > .header-btn,
  .mobile-header-actions-track .tools-dropdown-root .header-btn {
    flex: 0 0 auto;
  }
  .mobile-header-actions-track > .header-btn,
  .mobile-header-actions-track .tools-dropdown-root .header-btn {
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: #d1fae5;
    font-weight: 500;
    min-height: 40px;
    padding: 8px 16px;
    box-shadow: none;
  }
  .mobile-header-actions-track > .header-btn:not(#arcade-btn):hover,
  .mobile-header-actions-track .tools-dropdown-root .header-btn:hover {
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.4);
    color: #ecfdf5;
    transform: none;
  }
  .mobile-header-actions-track > #arcade-btn:hover {
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.4);
    color: #ecfdf5;
  }
  #settings-btn.header-btn-icon {
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #e5e7eb;
  }
  #settings-btn.header-btn-icon:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.1);
  }
  .mobile-header-meta .mobile-header-auth-btn {
    border-radius: 9999px;
    font-weight: 500;
    min-height: 40px;
    padding: 8px 16px;
    box-shadow: none;
  }
  .mobile-header-meta .mobile-header-auth-btn.text-green-400 {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: #d1fae5;
  }
  .mobile-header-meta .mobile-header-auth-btn.text-green-400:hover {
    transform: none;
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.4);
    color: #ecfdf5;
  }
  .mobile-header-meta .mobile-header-auth-btn.text-red-400 {
    border: 1px solid rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.1);
    color: #fca5a5;
  }
  .mobile-header-meta .mobile-header-auth-btn.text-red-400:hover {
    transform: none;
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.55);
    color: #fecaca;
  }
}

@media (max-width: 768px) {
  #site-header #panel-btn.mobile-header-auth-btn,
  #site-header #customer-panel-btn.mobile-header-auth-btn {
    border-radius: 9999px;
    min-height: 40px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
  }
  #site-header #panel-btn.hidden,
  #site-header #customer-panel-btn.hidden {
    display: none !important;
  }
  #site-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
  }
  .mobile-header-brand.glitch-hover:hover {
    animation: none;
  }
  .mobile-header-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas:
      "brand meta"
      "nav nav";
    gap: 10px 12px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: 12px;
  }
  .mobile-header-brand {
    grid-area: brand;
    font-size: 1.0625rem !important;
    letter-spacing: -0.02em !important;
    text-transform: none !important;
    justify-self: start;
    align-self: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .mobile-header-meta {
    grid-area: meta;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    justify-self: end;
    align-self: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    row-gap: 6px;
    column-gap: 4px;
  }
  .mobile-header-actions {
    grid-area: nav;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    overflow: visible;
    padding: 4px 0 6px;
  }
  .mobile-header-actions-track {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-padding-inline-end: 16px;
    padding-inline-end: 20px;
    padding-block: 5px;
    box-sizing: border-box;
  }
  .mobile-header-actions-track::-webkit-scrollbar {
    display: none;
  }
  .mobile-header-actions-track .tools-dropdown-root {
    flex: 0 0 auto;
    width: auto;
  }
  .mobile-header-actions-track > .header-btn,
  .mobile-header-actions-track .tools-dropdown-root .header-btn {
    flex: 0 0 auto;
    width: auto !important;
    min-height: 40px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: #d1fae5;
    box-shadow: none;
  }
  .mobile-header-actions-track > .header-btn:not(#arcade-btn):hover,
  .mobile-header-actions-track .tools-dropdown-root .header-btn:hover {
    transform: none;
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.4);
    color: #ecfdf5;
  }
  .mobile-header-actions-track > #arcade-btn:hover {
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.4);
    color: #ecfdf5;
  }
  .mobile-header-meta #coin-balance {
    font-size: 12px;
  }
  .mobile-header-meta #user-status {
    max-width: min(28vw, 120px);
    font-size: 10px;
  }
  #settings-btn.header-btn-icon {
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
  }
  .mobile-header-meta .mobile-header-auth-btn {
    flex: 0 0 auto;
    min-height: 42px;
    width: auto;
    height: auto;
    padding: 8px 12px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    box-shadow: none;
    box-sizing: border-box;
  }
  .mobile-header-meta .mobile-header-auth-btn.text-green-400 {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: #d1fae5;
  }
  .mobile-header-meta .mobile-header-auth-btn.text-green-400:hover {
    transform: none;
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.4);
    color: #ecfdf5;
  }
  .mobile-header-meta .mobile-header-auth-btn.text-red-400 {
    border: 1px solid rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.1);
    color: #fca5a5;
  }
  .mobile-header-meta .mobile-header-auth-btn.text-red-400:hover {
    transform: none;
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.55);
    color: #fecaca;
  }
}

/* Injected settings modal + disco (shared header pages; namespaced keyframes) */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.settings-modal.active {
  opacity: 1;
  visibility: visible;
}
.settings-content {
  background: #000;
  border: 2px solid #22c55e;
  border-radius: 4px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 0 calc(30px * var(--glow-intensity, 1))
    rgba(34, 197, 94, 0.3);
}
.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: #333;
  border-radius: 4px;
  cursor: pointer;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  background: #22c55e;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 calc(10px * var(--glow-intensity, 1))
    rgba(34, 197, 94, 0.5);
}
.settings-select {
  width: 100%;
  background: #111;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  outline: none;
}
.settings-select:focus {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.2);
}

@keyframes site-header-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px) rotate(-2deg);
  }
  75% {
    transform: translateX(3px) rotate(2deg);
  }
}

@keyframes site-header-disco {
  0% {
    filter: hue-rotate(0deg);
  }
  25% {
    filter: hue-rotate(90deg);
  }
  50% {
    filter: hue-rotate(180deg);
  }
  75% {
    filter: hue-rotate(270deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}
