/**
 * hud-layout.css - Grid Viewport, Responsive Media Queries, and Anti-AFK Focus Glow
 */

/* =========================================================
 * 3. IN-GAME HUD
 * ========================================================= */
.game-viewport-container {
  display: grid;
  grid-template-columns: clamp(250px, 17vw, 275px) minmax(0, 1fr) clamp(260px, 19vw, 300px);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "left board right"
    "left bottom right";
  height: calc(100dvh - 56px);
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  position: relative;
}


/* =========================================================
 * RESPONSIVE LAYOUT (UX-01)
 * ========================================================= */
@media (max-width: 1024px) {
  .hud-overlay-toggle {
    display: flex;
  }

  .game-viewport-container {
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-areas:
      "left board"
      "left bottom";
  }

  .hud-left {
    padding: 10px;
    gap: 8px;
  }

  .hud-right {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    grid-area: unset;
    z-index: 80;
    transform: translateX(100%);
    transition: transform var(--transition-smooth);
    border-left: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
  }

  .game-viewport-container.sidebar-open .hud-right {
    transform: translateX(0);
  }

  .hud-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 56px 0 0 0;
    background: oklch(0.1 0.02 264 / 0.45);
    z-index: 70;
  }

  .game-viewport-container.sidebar-open .hud-sidebar-backdrop {
    display: block;
  }

  .btn-build-action,
  .btn-glass,
  .lobby-tab-btn,
  .segmented-tab,
  .sidebar-tab-btn {
    min-height: 44px;
  }

  .board-control-btn {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 0 10px;
  }

  .brand-title {
    font-size: 13px;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sound-label {
    display: none;
  }

  .header-actions .btn-glass span:not(.btn-icon):not(.ico) {
    display: none;
  }

  .lobby-container,
  .waiting-container {
    margin: 16px auto;
    padding: 0 12px;
  }

  .lobby-panel {
    padding: 16px;
  }

  .lobby-tabs {
    flex-wrap: wrap;
    border-radius: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .waiting-header,
  .waiting-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .game-viewport-container {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(220px, 1fr) auto;
    grid-template-areas:
      "status"
      "board"
      "hand";
    height: calc(100dvh - 56px);
  }

  .board-viewport {
    min-height: 42dvh;
  }

  .hud-left {
    display: contents;
    padding: 0;
    border: none;
    overflow: visible;
    background: transparent;
  }

  .hud-left-status {
    grid-area: status;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px;
    gap: 8px;
    background: oklch(0.165 0.012 264 / 0.92);
    border-bottom: 1px solid var(--border-subtle);
    max-height: none;
  }

  .hud-left-status .turn-banner,
  .hud-left-status .dice-container {
    flex: 0 0 auto;
    min-width: 148px;
  }

  .hud-left-status .ck-hud-widget {
    flex: 0 0 auto;
    min-width: 160px;
  }

  .hud-build-actions-wrapper {
    padding: 8px 10px;
    background: oklch(0.165 0.012 264 / 0.92);
    border-bottom: 1px solid var(--border-subtle);
  }

  .build-actions-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .hud-bottom {
    grid-area: hand;
    min-height: 72px;
    padding: 6px 10px;
    overflow-x: auto;
    gap: 8px;
  }

  .resource-cards-deck {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .res-card {
    width: 56px;
    height: 68px;
    flex-shrink: 0;
  }

  .hud-right {
    top: auto;
    height: min(70dvh, 520px);
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
  }

  .game-viewport-container.sidebar-open .hud-right {
    transform: translateY(0);
  }

  .modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-box,
  .trade-modal-box {
    max-width: 100% !important;
    width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 16px;
  }

  .trade-steppers-grid,
  .trade-inputs-row,
  body.mode-cities-knights #discard-form .trade-steppers-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board-hint {
    bottom: 8px;
    padding: 6px 12px;
    font-size: 11px;
  }
}

/* =========================================================
 * VERTICAL RESPONSIVENESS (SHORT VIEWPORTS / LAPTOPS)
 * ========================================================= */
@media (max-height: 820px) {
  .hud-left {
    padding: 8px 10px;
    gap: 8px;
  }

  .hud-left-status {
    gap: 8px;
  }

  .turn-banner {
    padding: 8px 10px;
  }

  .turn-commander {
    font-size: 14px;
    margin: 1px 0;
  }

  .dice-container {
    padding: 8px 10px;
    gap: 6px;
  }

  .die {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  .dice-prod-card {
    padding: 4px 6px;
    gap: 3px;
  }

  .dice-prod-chip {
    font-size: 11px;
    padding: 2px 6px;
  }

  .build-actions-list {
    gap: 4px;
  }

  .btn-build-action {
    padding: 6px 8px;
    font-size: 12px;
  }

  .btn-end-turn {
    min-height: 38px;
    padding: 8px;
    font-size: 13px;
  }

  .hud-bottom {
    min-height: 80px;
  }

  .res-card {
    height: clamp(62px, 6vw, 74px);
  }
}


.board-container-fill {
  width: 100%;
  height: 100%;
}

/* =========================================================
 * TURN FOCUS & ACTIVE ACTION GLOW (Anti-AFK UX)
 * ========================================================= */
@keyframes actionPulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(226, 185, 59, 0.7);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 16px 4px rgba(226, 185, 59, 0.45);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(226, 185, 59, 0);
    transform: scale(1);
  }
}

.btn-pulse-glow {
  animation: actionPulseGlow 1.8s infinite ease-in-out !important;
  border-color: var(--gold-primary, #e2b93b) !important;
  color: #ffffff !important;
}

.turn-active-glow {
  box-shadow: 0 0 24px -2px rgba(226, 185, 59, 0.35) !important;
  border-color: rgba(226, 185, 59, 0.6) !important;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
