/**
 * mobile-shared.css — Faza 0: wspólna baza stylów mobile
 *
 * Breakpointy:
 *   900px — ukrycie .nav-links, hamburger
 *   768px — layout mobile, dolny nav app, status bar kompaktowy
 *   600px — phone
 *   400px — skrócony logotyp
 *   360px — wąski ekran (subnav)
 */

/* ── Tokeny layoutu ── */
:root {
  --nav-height: 60px;
  --app-mbnav-height: 3.25rem;
  --app-status-bar-height: 2.75rem;
  --app-status-bar-height-mobile: 2.125rem;
  --toast-bottom-offset: 2rem;
  --app-bottom-chrome: 2.75rem;
}

/* ── Safe area ── */
.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.has-fixed-status-bar {
  --app-bottom-chrome: var(--app-status-bar-height, 2.75rem);
}

/* ── Navbar — hamburger ── */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  align-items: center;
  gap: 0.4rem;
}

.mobile-menu-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.05);
}

.mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background: rgba(8, 12, 16, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
  z-index: 10200;
  flex-direction: column;
  gap: 0.3rem;
}

.mobile-menu-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10199;
  background: rgba(0, 0, 0, 0.55);
}

.mobile-menu-scrim.open {
  display: block;
}

.mobile-menu.open {
  display: flex;
}

.mobile-menu a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.9rem 1rem;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.mobile-menu a:hover,
.mobile-menu a.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.05);
}

@media (max-width: 900px) {
  .nav-links {
    display: none;
  }

  nav {
    padding: 0 1rem;
    justify-content: space-between;
  }

  .mobile-menu-btn {
    display: flex !important;
  }
}

/* app.html — sekcje w hamburgerze (desktop/tablet) */
.mobile-menu-divider {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--border);
  letter-spacing: 0.2em;
  text-align: center;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  user-select: none;
}

.mobile-menu .section-link {
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.mobile-menu .section-link.active-section {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.05);
}

/* ── Logotyp — skrót na wąskich ekranach ── */
@media (max-width: 400px) {
  .nav-logo-suffix {
    display: none;
  }
}

/* ── Status bar — strony publiczne ── */
.status-bar--public {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface, #0d1117);
  border-top: 1px solid var(--border, #21262d);
  padding: 0.4rem 2rem;
  padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 2rem;
  font-family: var(--font-mono, 'Space Mono', monospace);
  font-size: 0.65rem;
  color: var(--text-muted, #7d8590);
  z-index: 99;
}

.status-bar--public .status-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-bar--public .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #00ff88);
  animation: status-pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-bar--public .status-bar-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  gap: 1rem;
  min-width: 0;
}

.status-bar--public .status-bar-meta {
  flex-shrink: 0;
  opacity: 0.85;
}

@media (max-width: 768px) {
  .status-bar--public {
    flex-direction: column;
    align-items: stretch;
    gap: 0.12rem;
    padding: 0.35rem 1rem;
    padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
    font-size: 0.58rem;
  }

  .status-bar--public .status-bar-primary {
    min-width: 0;
  }

  .status-bar--public .status-bar-primary span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-bar--public .status-bar-secondary {
    font-size: 0.55rem;
    opacity: 0.92;
  }

  .status-bar--public .status-bar-secondary > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-bar--public .status-dot {
    animation: none;
  }
}

/* ── Status bar — app.html ── */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.4rem 2rem;
  padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 2rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  z-index: 999;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-progress-compact {
  display: none;
}

.status-bar-details {
  display: contents;
}

.status-expand-icon {
  font-size: 0.48rem;
  opacity: 0.5;
  margin-left: 0.25rem;
  flex-shrink: 0;
  transition: transform 0.2s;
}

/* SFX — desktop: pływający; mobile: w status barze */
.sfx-toggle {
  font-family: var(--font-mono);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sfx-toggle--floating {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}

.sfx-toggle--embedded {
  width: 1.5rem;
  height: 1.5rem;
  min-width: 1.5rem;
  min-height: 1.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.68rem;
  line-height: 1;
  flex-shrink: 0;
}

.sfx-toggle.is-on {
  color: var(--accent);
  border-color: rgba(0, 255, 136, 0.45);
  background: rgba(0, 255, 136, 0.08);
}

.sfx-toggle.is-off {
  color: var(--text-muted);
  border-color: var(--border);
}

.status-sfx-slot {
  display: none;
}

.status-progress-compact[aria-expanded="true"] .status-expand-icon {
  transform: rotate(180deg);
}

.status-detail-panel {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: none;
  pointer-events: none;
}

.status-detail-panel.open {
  display: block;
  pointer-events: auto;
}

.status-detail-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 16, 0.72);
}

.status-detail-content {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  padding: 0.85rem 1rem 1rem;
  max-height: min(50vh, 320px);
  overflow-y: auto;
}

body.has-app-mbnav .status-detail-content {
  bottom: calc(var(--app-mbnav-height) + var(--app-status-bar-height) + env(safe-area-inset-bottom, 0px));
}

body:not(.has-app-mbnav) .status-detail-content {
  bottom: calc(var(--app-status-bar-height) + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 768px) {
  body:not(.has-app-mbnav) .status-detail-content {
    bottom: calc(var(--app-status-bar-height-mobile) + env(safe-area-inset-bottom, 0px));
  }
}

.status-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.status-detail-head button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  min-width: 32px;
  min-height: 32px;
  cursor: pointer;
}

.status-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
}

.status-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.status-detail-row dt {
  color: var(--text-muted);
  margin: 0;
}

.status-detail-row dd {
  color: var(--text);
  margin: 0;
  font-weight: 700;
}

@media (max-width: 768px) {
  .status-bar {
    padding: 0.5rem 1rem;
    font-size: 0.65rem;
    gap: 0.8rem;
    flex-wrap: wrap;
  }
}

/* ── Wewnętrzna nawigacja app.html / index.html ── */
.app-subnav {
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  background: rgba(13, 17, 23, 0.97);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0;
  padding: 0 2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.app-subnav::-webkit-scrollbar {
  display: none;
}

.subnav-label-short {
  display: none;
}

.app-subnav a {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.75rem 1.1rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  letter-spacing: 0.08em;
}

.app-subnav a:hover {
  color: var(--text);
}

.app-subnav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.app-subnav a.subnav-locked {
  opacity: 0.55;
  cursor: pointer;
  pointer-events: auto;
}

.app-mbnav-item.subnav-locked,
#mmenu-sections .section-link.subnav-locked {
  opacity: 0.55;
  cursor: pointer;
  pointer-events: auto;
}

#nav-progress-wrap,
.nav-progress {
  pointer-events: none;
}

.app-subnav a.done-tab {
  color: var(--accent);
}

.app-subnav a.subnav-next-step,
.app-mbnav-item.subnav-next-step,
#mmenu-sections .section-link.subnav-next-step {
  color: var(--accent) !important;
  border-bottom-color: var(--accent);
  animation: subnavNextPulse 1.4s ease-in-out infinite;
}

@keyframes subnavNextPulse {
  0%, 100% { box-shadow: inset 0 -2px 0 var(--accent); opacity: 1; }
  50% { box-shadow: inset 0 -2px 0 var(--accent3), 0 0 12px rgba(0, 255, 136, 0.25); opacity: 0.92; }
}

.has-subnav .page {
  padding-top: 101px;
}

body.demo-mode .page {
  padding-top: 118px;
}

.has-subnav .page .section-wrap {
  padding-top: 1.5rem;
}

@media (max-width: 600px) {
  body.demo-mode .page {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .app-subnav {
    padding: 0 0.25rem;
  }

  .app-subnav a {
    padding: 0.5rem 0.6rem;
    font-size: 0.63rem;
    letter-spacing: 0.04em;
  }
}

/* ── Dolna nawigacja sekcji — app.html mobile ── */
.app-mbnav {
  display: none;
}

@media (max-width: 768px) {
  /* Mobile jak desktop: subnav etapów u góry, bez dolnego mbnav */
  .app-subnav {
    display: flex !important;
    position: sticky;
    top: var(--nav-height);
    z-index: 95;
    padding: 0 0.15rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  }

  .app-subnav a {
    flex: 1 0 auto;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.55rem;
    font-size: 0.58rem;
    letter-spacing: 0.03em;
  }

  .subnav-label-full {
    display: none !important;
  }

  .subnav-label-short {
    display: inline !important;
  }

  body.has-subnav .page {
    padding-top: calc(var(--nav-height) + 2.65rem);
    padding-bottom: calc(var(--app-status-bar-height-mobile) + 0.75rem + env(safe-area-inset-bottom, 0px));
  }

  .app-mbnav,
  .app-mbnav.is-visible {
    display: none !important;
  }

  .status-sfx-slot {
    display: block;
    flex: 0 0 auto;
    order: 3;
  }

  .status-bar--app {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem 0.5rem;
    padding-bottom: calc(0.18rem + env(safe-area-inset-bottom, 0px));
    min-height: var(--app-status-bar-height-mobile);
    bottom: 0;
    z-index: 10048;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.35);
    border-top: 1px solid var(--border);
  }

  .status-bar--app .status-nick-row {
    flex: 0 1 auto;
    max-width: 32%;
    min-width: 0;
    order: 1;
  }

  .status-bar--app .status-nick-row .status-dot {
    width: 5px;
    height: 5px;
  }

  .status-bar--app .status-nick-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.54rem;
    letter-spacing: 0.02em;
  }

  .status-bar--app .status-bar-details {
    display: none;
  }

  .status-bar--app .status-progress-compact {
    flex: 1 1 auto;
    order: 2;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.52rem;
    cursor: pointer;
    text-align: left;
    min-height: 24px;
    -webkit-tap-highlight-color: transparent;
  }

  .status-progress-compact span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  .sfx-toggle--floating {
    display: none !important;
  }

  :root {
    --toast-bottom-offset: calc(var(--app-status-bar-height-mobile) + 0.75rem + env(safe-area-inset-bottom, 0px));
    --app-bottom-chrome: var(--app-status-bar-height-mobile);
  }

  .mbnav-hint.is-visible {
    bottom: calc(var(--app-status-bar-height-mobile) + 0.5rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 360px) {
  .app-subnav a {
    padding: 0.45rem 0.4rem;
    font-size: 0.55rem;
  }

  .subnav-label-full {
    display: none !important;
  }

  .subnav-label-short {
    display: inline !important;
  }
}

/* ── Gry: powrót do listy + podpowiedź dolnego nav ── */
.game-back-bar {
  position: sticky;
  top: var(--nav-height);
  z-index: 45;
  margin: 0 0 0.85rem;
  padding: 0.35rem 0;
  background: linear-gradient(to bottom, var(--bg) 75%, transparent);
}

.game-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.game-back-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.06);
}

.game-back-hint {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.games-mobile-nav-hint {
  display: none;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: rgba(0, 255, 136, 0.06);
  border: 1px solid rgba(0, 255, 136, 0.22);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.games-mobile-nav-hint strong {
  color: var(--accent);
}

@media (max-width: 768px) {
  .game-back-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .game-back-hint {
    display: block;
  }

  .games-mobile-nav-hint {
    display: block;
  }
}

.mbnav-hint {
  display: none;
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  z-index: 10047;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.55;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.mbnav-hint.is-visible {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.mbnav-hint-text {
  flex: 1;
  min-width: 0;
}

.mbnav-hint-text strong {
  color: var(--accent);
}

.mbnav-hint-close {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .mbnav-hint.is-visible {
    bottom: calc(var(--app-status-bar-height-mobile) + 0.5rem + env(safe-area-inset-bottom, 0px));
  }

  .status-detail-next {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
  }

  .status-detail-next-btn {
    width: 100%;
    min-height: 44px;
    padding: 0.65rem 1rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
  }

  .survey-mbnav-hint.is-visible {
    border-color: var(--accent3);
    z-index: 1003;
  }

  .survey-mbnav-hint .mbnav-hint-text strong {
    color: var(--accent3);
  }
}

@keyframes mbnav-pending-pulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(255, 170, 0, 0); }
  50% { box-shadow: inset 0 0 0 1px rgba(255, 170, 0, 0.45); }
}
