/* Modal UI Styles for Wordmunchr */
/* Copyright (c) 2025 Wordmunchr Team. All rights reserved. */

/* When a modal is open, override body's touch-action:none so inputs work on iOS.
   touch-action uses intersection semantics — ancestors with 'none' block all descendants.
   This attribute is toggled by ModalUI.show()/hide(). */
body[data-modal-open] {
  touch-action: auto;
}

/* Backdrop - fullscreen overlay */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-backdrop.visible {
  display: flex;
}

/* Panel - centered card */
.modal-panel {
  background: #1e1e32;
  border: 2px solid #555577;
  border-radius: 15px;
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 24px;
  position: relative;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
  -webkit-user-select: text;
  user-select: text;
}

/* Close button */
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: #3a3a55;
  color: #ccc;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
  background: #4a4a65;
  color: #fff;
}

/* Headings */
.modal-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 24px;
  text-align: center;
  margin: 0 0 8px 0;
  color: #fff;
}

.modal-subtitle {
  font-size: 14px;
  text-align: center;
  color: #aaa;
  margin: 0 0 20px 0;
}

/* Divider with "or" */
.modal-divider {
  display: flex;
  align-items: center;
  margin: 18px 0;
  gap: 12px;
}

.modal-divider::before,
.modal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #444;
}

.modal-divider span {
  font-size: 12px;
  color: #888;
}

/* Labels */
.modal-label {
  display: block;
  font-size: 14px;
  color: #ccc;
  margin-bottom: 6px;
}

/* Native inputs - 16px minimum prevents iOS zoom */
.modal-input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 16px;
  color: #fff;
  background: #282840;
  border: 1.5px solid #555577;
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 14px;
  -webkit-appearance: none;
  appearance: none;
  touch-action: auto;
  -webkit-user-select: text;
  user-select: text;
}

.modal-input::placeholder {
  color: #666;
}

.modal-input:focus {
  border-color: #00cc66;
  box-shadow: 0 0 0 2px rgba(0, 204, 102, 0.15);
}

/* Buttons */
.modal-btn {
  display: block;
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal-btn-primary {
  background: #00cc66;
  color: #fff;
}

.modal-btn-primary:hover {
  background: #00b35a;
}

.modal-btn-primary:disabled {
  background: #3a3a55;
  color: #777;
  cursor: default;
}

.modal-btn-google {
  background: #fff;
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.modal-btn-google:hover {
  background: #f0f0f0;
}

.modal-btn-google .google-g {
  font-size: 20px;
  font-weight: bold;
  color: #4285f4;
}

.modal-btn-secondary {
  background: #3a3a55;
  color: #ccc;
}

.modal-btn-secondary:hover {
  background: #4a4a65;
}

/* Status message */
.modal-status {
  text-align: center;
  font-size: 13px;
  min-height: 20px;
  margin: 8px 0;
  line-height: 1.4;
}

.modal-status.error {
  color: #ff6b6b;
}

.modal-status.success {
  color: #00cc66;
}

.modal-status.info {
  color: #88aaff;
}

/* Link-style text */
.modal-link {
  display: block;
  text-align: center;
  font-size: 13px;
  color: #888;
  cursor: pointer;
  padding: 8px 0;
  background: none;
  border: none;
  width: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal-link:hover {
  color: #bbb;
}

/* Leaderboard tabs */
.leaderboard-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.leaderboard-tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #2a2a44;
  color: #999;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.leaderboard-tab.active {
  background: #00cc66;
  color: #fff;
}

/* Leaderboard rows */
.leaderboard-list {
  margin-bottom: 12px;
  min-height: 100px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 6px 4px;
  font-size: 14px;
}

.leaderboard-rank {
  width: 28px;
  font-weight: 600;
  flex-shrink: 0;
}

.leaderboard-rank.gold { color: #ffd700; }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

.leaderboard-username {
  flex: 1;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: #00cc66;
  font-weight: 600;
  margin-left: 8px;
}

.leaderboard-empty {
  text-align: center;
  color: #888;
  padding: 30px 0;
  font-size: 14px;
  line-height: 1.6;
}

/* Daily stats box */
.daily-stats {
  background: #282840;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
}

.daily-stats-title {
  color: #888;
  margin-bottom: 6px;
}

.daily-stats-item {
  color: #ccc;
  margin-bottom: 3px;
}

/* Waiting screen */
.modal-waiting-email {
  color: #00cc66;
  font-weight: 600;
}

/* Signed-in indicator */
.modal-signed-in {
  font-size: 12px;
  color: #777;
  text-align: center;
  margin-bottom: 16px;
}

/* Responsive */
@media (max-height: 600px) {
  .modal-panel {
    padding: 20px 18px;
    max-height: 95vh;
  }

  .modal-title {
    font-size: 20px;
  }
}

@media (max-width: 360px) {
  .modal-panel {
    padding: 18px 14px;
  }
}
