/* CollaBoard - Mobile layout
 * Loaded last. Desktop defaults for mobile-only elements come first, then one breakpoint.
 * Keep the breakpoint in sync with MOBILE_QUERY in core/viewport.js.
 */

/* ==========================================================================
   Desktop defaults for elements that only appear on mobile
   ========================================================================== */
.lobby-tabs,
.label-short,
.mobile-icon,
.nav-mobile-actions,
.room-current-app {
  display: none;
}

.svg-icon {
  display: block;
}

/* Icon and label were one "✏️ 펜" string before they were split into spans */
.wb-btn .btn-icon {
  margin-right: 0.3em;
}

/* Network state colors for the status dot (visible on every screen size) */
.p2p-status-pill.is-waiting .status-dot { background-color: #f59e0b; }
.p2p-status-pill.is-connecting .status-dot { background-color: #3b82f6; }
.p2p-status-pill.is-offline .status-dot { background-color: #ef4444; animation: none; }

/* Participants list inside the profile sheet */
.profile-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.profile-sheet-badge {
  align-self: flex-start;
  font-size: 1rem;
  padding: 0.5rem 0.9rem;
}

.profile-sheet-badge .inline-edit-icon {
  opacity: 1;
}

.profile-sheet-badge .inline-nickname-input {
  width: 180px;
  font-size: 1rem;
}

.profile-sheet-participants-btn {
  width: 100%;
}

.profile-sheet-participants {
  max-height: 50vh;
  overflow-y: auto;
}

@media (max-width: 640px) {
  /* ==========================================================================
     Shared utilities
     ========================================================================== */
  .label-full,
  .desktop-label,
  .btn-icon {
    display: none;
  }

  .label-short {
    display: inline;
  }

  .mobile-icon {
    display: inline-flex;
  }

  .icon-on-mobile {
    padding: 0.4rem 0.55rem;
  }

  /* ==========================================================================
     Navbar (lobby + room)
     ========================================================================== */
  .app-navbar {
    padding: 0.4rem 0.75rem;
    gap: 0.5rem;
    height: 50px;
  }

  .brand-badge {
    display: none;
  }

  .nav-right {
    gap: 0.35rem;
  }

  .lang-switch-btn {
    padding: 0.25rem 0.45rem;
    font-size: 0.78rem;
    gap: 0.25rem;
  }

  .lang-switch-btn .lang-icon {
    font-size: 0.8rem;
  }

  .lang-switch-btn .lang-label {
    font-size: 0.78rem;
  }

  .lang-switch-btn .lang-caret {
    font-size: 0.55rem;
  }

  .nav-portal-link {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
  }

  .user-profile-badge .user-name-text {
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (max-width: 380px) {
    .nav-portal-link {
      display: none;
    }
    .user-profile-badge .user-name-text {
      max-width: 50px;
    }
  }

  /* ==========================================================================
     Lobby
     ========================================================================== */
  .lobby-container {
    width: 100%;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .lobby-hero {
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.5rem 0.25rem;
    gap: 0.65rem;
    text-align: center;
  }

  .hero-pill {
    font-size: 0.72rem;
    padding: 0.2rem 0.6rem;
  }

  .hero-title {
    font-size: 1.7rem;
    line-height: 1.22;
  }

  .hero-subtitle {
    font-size: 0.88rem;
    line-height: 1.45;
  }

  .philosophy-banner {
    display: flex;
    flex-direction: column;
    padding: 1.1rem;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .banner-badge {
    align-self: flex-start;
  }

  .workflow-steps-grid,
  .scenarios-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .site-footer {
    padding: 2.5rem 1rem 1.5rem;
  }

  .site-footer-inner {
    flex-direction: column;
    gap: 2rem;
  }

  .site-footer-nav-group {
    flex-direction: column;
    gap: 1.75rem;
  }

  .site-footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .lobby-alert-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem;
  }

  .lobby-alert-banner .alert-icon {
    display: none;
  }

  .lobby-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
  }

  .lobby-tab {
    padding: 0.6rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
  }

  .lobby-tab.active {
    background: var(--primary);
    color: #ffffff;
  }

  .lobby-actions-grid {
    display: block;
  }

  .lobby-actions-grid[data-active-tab="create"] [data-lobby-card="join"],
  .lobby-actions-grid[data-active-tab="join"] [data-lobby-card="create"] {
    display: none;
  }

  .action-card {
    padding: 1rem;
    gap: 0;
  }

  .action-card .card-header-icon,
  .action-card-intro,
  .create-app-group,
  .form-label-hint,
  .form-toggle-text small {
    display: none;
  }

  .action-card .form-group {
    margin-bottom: 0.9rem;
  }

  .action-card .btn-lg {
    margin-top: 0.5rem;
    width: 100%;
  }

  .action-card .form-toggle {
    margin-bottom: 0.25rem;
  }

  /* ==========================================================================
     Room navbar
     ========================================================================== */
  .room-navbar .nav-brand {
    display: none;
  }

  .nav-mobile-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  .nav-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    cursor: pointer;
  }

  .nav-leave-icon-btn {
    color: #fca5a5;
  }

  .nav-leave-icon-btn:active {
    background: rgba(239, 68, 68, 0.15);
  }

  /* Board menu drops down from the app bar (positioned below, so it is the context) */
  .nav-app-menu {
    position: absolute;
    top: 100%;
    left: 0.5rem;
    margin-top: 0.25rem;
    min-width: 200px;
    padding: 0.35rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .nav-app-menu[hidden] {
    display: none;
  }

  .nav-app-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  .nav-app-menu-item:active,
  .nav-app-menu-item:focus-visible {
    background: var(--bg-surface-elevated);
    outline: none;
  }

  .nav-app-menu-item.active {
    background: rgba(79, 70, 229, 0.2);
    border-color: var(--primary-border);
    color: #a5b4fc;
  }

  .nav-app-menu-icon {
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
  }

  .room-navbar .nav-center {
    gap: 0.5rem;
    min-width: 0;
  }

  .room-meta-pill {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
    gap: 0.3rem;
    min-width: 0;
  }

  /* Custom room codes can be up to 32 characters; the full code stays in the title */
  .room-id-code {
    min-width: 0;
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
  }

  #openQrBtn {
    flex-shrink: 0;
  }

  #copyRoomCodeBtn,
  #p2pStatusLabel,
  .room-navbar .participants-menu,
  #leaveRoomBtn,
  #roomProfileBadge .user-avatar,
  #roomProfileBadge .inline-edit-icon {
    display: none;
  }

  /* Status as a plain colored ball; the label moves to the title attribute */
  .p2p-status-pill {
    padding: 0.35rem;
    background: transparent;
    border: none;
  }

  .p2p-status-pill .status-dot {
    width: 12px;
    height: 12px;
  }

  .room-navbar .nav-right {
    gap: 0.5rem;
    min-width: 0;
  }

  #roomProfileBadge {
    min-width: 0;
    gap: 0.25rem;
  }

  /* Long names shrink with an ellipsis so the host star stays inside the badge */
  #roomProfileBadge .user-name-wrapper,
  #roomProfileBadge .user-name-text {
    min-width: 0;
  }

  #roomProfileBadge .user-name-text {
    max-width: 110px;
  }

  #roomProfileBadge .host-star {
    flex-shrink: 0;
  }

  /* Profile sheet slides up from the bottom */
  .profile-sheet {
    align-items: flex-end;
    padding: 0;
  }

  .profile-sheet .modal-dialog {
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .profile-sheet .modal-header {
    padding: 0.9rem 1rem;
  }

  .profile-sheet .modal-body {
    padding: 1rem;
  }

  /* ==========================================================================
     Room app bar
     ========================================================================== */
  .room-shell {
    height: calc(100dvh - 50px);
  }

  .room-app-bar {
    padding: 0.35rem 0.5rem;
    gap: 0.5rem;
    position: relative;
    z-index: 40;
  }

  /* Tabs move into the navbar menu; the bar only names the current board */
  .room-app-tabs,
  .room-app-bar-e2e {
    display: none !important;
  }

  .room-current-app {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding: 0.3rem 0.4rem;
    margin-left: -0.4rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
  }

  .room-current-app:active,
  .room-current-app[aria-expanded="true"] {
    background: var(--bg-surface-elevated);
  }

  .room-current-app-chevron {
    display: inline-flex;
    color: var(--text-muted);
    transition: transform 0.15s;
  }

  .room-current-app[aria-expanded="true"] .room-current-app-chevron {
    transform: rotate(180deg);
  }
  .room-current-app-icon {
    font-size: 1.15rem;
  }

  .room-current-app-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .room-app-bar-actions {
    flex-shrink: 0;
  }

  /* ==========================================================================
     Whiteboard: labels only, single scrollable toolbar row
     ========================================================================== */
  .wb-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
  }

  .wb-tool-group {
    flex-shrink: 0;
  }

  .wb-btn {
    white-space: nowrap;
  }

  .wb-toolbar-spacer {
    display: none;
  }

  /* ==========================================================================
     Apps: remove outer spacing and descriptions
     ========================================================================== */
  .app-brainstorm-wrapper,
  .app-qna-wrapper,
  .app-quiz-wrapper,
  .app-poll-wrapper,
  .app-fileshare-wrapper {
    padding: 0;
  }

  /* Boards: flat full-width sections split by rules instead of floating cards,
     with about 30% of the desktop inner padding (1.5rem -> 0.45rem) */
  .app-brainstorm-wrapper,
  .bs-content-grid,
  .app-qna-wrapper,
  .qna-layout-grid,
  .app-quiz-wrapper,
  .quiz-layout-grid,
  .app-fileshare-wrapper,
  .fs-main-grid {
    gap: 0;
  }

  .bs-header-card,
  .bs-submit-card,
  .bs-board-panel,
  .qna-header-card,
  .qna-form-card,
  .qna-stream-panel,
  .quiz-header-card,
  .quiz-creator-card,
  .quiz-pool-panel,
  .poll-nav-bar,
  .poll-main-card,
  .fs-header-card,
  .fs-dropzone,
  .fs-list-panel {
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
    padding: 0.45rem;
    gap: 0.6rem;
  }

  /* The last section of each board needs no closing rule */
  .bs-board-panel,
  .qna-stream-panel,
  .quiz-pool-panel,
  .poll-main-card,
  .fs-list-panel {
    border-bottom: none;
  }

  .poll-nav-bar {
    margin-bottom: 0;
  }

  /* Poll: 2rem -> 0.6rem, the dropzone: 2.5rem -> 0.75rem */
  .poll-main-card {
    padding: 0.6rem;
    gap: 1rem;
  }

  .fs-dropzone {
    padding: 0.75rem 0.45rem;
  }

  .bs-empty,
  .qna-empty,
  .quiz-empty,
  .fs-empty,
  .poll-history-empty {
    padding: 1.5rem 0.75rem;
  }

  .bs-desc,
  .quiz-subtitle,
  .quiz-desc,
  .quiz-panel-sub,
  .fs-subtitle {
    display: none;
  }

  /* ==========================================================================
     Notice board: list only; the selected notice opens full screen
     ========================================================================== */
  .app-notice-wrapper {
    padding: 0;
    gap: 0;
  }

  .notice-header,
  .notice-compose {
    padding: 0.45rem;
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
  }

  .notice-tag {
    display: none;
  }

  .notice-heading {
    font-size: 1.05rem;
  }

  .notice-compose-hint {
    display: none;
  }

  .notice-compose-actions {
    justify-content: flex-end;
  }

  .notice-list {
    flex: 1 1 auto;
    max-height: none;
    border: none;
    border-radius: 0;
    background: transparent;
  }

  .notice-row {
    gap: 0.5rem;
    padding: 0.7rem 0.6rem;
  }

  .notice-row.active {
    background: transparent;
    box-shadow: none;
  }

  .notice-row-author {
    max-width: 4.5rem;
    font-size: 0.75rem;
  }

  .notice-row-date {
    font-size: 0.72rem;
  }

  .notice-detail {
    display: none;
  }

  .is-detail-open .notice-detail {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 90;
    min-height: 0;
    border: none;
    border-radius: 0;
    background: var(--bg-main);
  }

  .is-detail-open .notice-detail-head {
    align-items: center;
    padding: 0.5rem 0.6rem;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
  }

  .notice-back-btn {
    display: inline-flex;
    border: none;
  }

  .notice-detail-title {
    font-size: 1rem;
  }

  .notice-detail-meta {
    font-size: 0.72rem;
  }

  .notice-detail-body {
    padding: 0.9rem 0.8rem 2rem;
  }

  /* ==========================================================================
     Feedback board: flat sections
     ========================================================================== */
  .app-feedback-wrapper,
  .fb-layout,
  .fb-main {
    padding: 0;
    gap: 0;
  }

  .fb-header-card,
  .fb-bank-card,
  .fb-current-card,
  .fb-answer-card,
  .fb-responses-panel,
  .fb-history-panel {
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    padding: 0.6rem 0.5rem;
  }

  .fb-tag,
  .fb-present-btn,
  .fb-bank-note,
  .fb-answer-hint {
    display: none;
  }

  .fb-heading {
    font-size: 1.05rem;
  }

  .fb-bank-card {
    position: static;
    max-height: none;
  }

  .fb-bank-sections {
    max-height: 40vh;
  }

  .fb-question-text {
    font-size: 1.15rem;
  }

  .fb-answer-row {
    justify-content: space-between;
  }

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

  /* Infinite Memo Board Mobile Adjustments */
  .board-main-toolbar {
    top: 8px;
    max-width: 96vw;
    padding: 3px 8px;
    gap: 3px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .board-main-toolbar .tb-label {
    display: none;
  }

  .board-main-toolbar .tb-btn {
    padding: 4px 6px;
    font-size: 0.75rem;
  }

  .board-main-toolbar .tb-search-input {
    width: 75px;
  }

  .board-main-toolbar .tb-search-input:focus {
    width: 105px;
  }

  .board-minimap-panel {
    bottom: 8px;
    right: 8px;
    transform: scale(0.75);
    transform-origin: bottom right;
  }

  .board-style-picker-modal {
    top: 48px;
    width: 95vw;
    max-height: 80vh;
  }

  .style-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    padding: 10px;
  }
}

