/* DOM overlay shared styles (name entry, dialogue, lesson modals). */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 13, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.overlay.hidden { display: none; }

/* Lesson "studio" mode: lighter backdrop + vignette so the themed studio room
   on the canvas shows around the centered lesson card. */
.overlay.overlay--studio {
  background: radial-gradient(ellipse at center,
    rgba(8, 10, 13, 0.30) 0%,
    rgba(8, 10, 13, 0.62) 100%);
}
/* The lesson card "rises into" the studio after the entrance reveal. */
@keyframes card-rise {
  from { transform: translateY(26px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.overlay--studio .overlay-card { animation: card-rise 0.42s cubic-bezier(0.2, 0.8, 0.2, 1); }
@media (prefers-reduced-motion: reduce) { .overlay--studio .overlay-card { animation: none; } }

.overlay-card {
  background: #1a2330;
  border: 1px solid #2d3a4a;
  border-radius: 12px;
  padding: 22px 24px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  color: #e7ecf2;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5);
}

.overlay-title {
  margin: 0 0 6px;
  font-size: 22px;
  color: #ffffff;
  font-family: monospace;
}

.overlay-sub {
  margin: 0 0 14px;
  font-size: 14px;
  color: #aab7c5;
}

.overlay-coming-soon {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #2a3848;
  border-left: 3px solid #ffca28;
  border-radius: 4px;
  font-style: italic;
  color: #d6dee7;
}

.overlay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  font-family: monospace;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #3d4a5b;
  background: #2a3848;
  color: #e7ecf2;
  cursor: pointer;
  transition: background 0.12s, transform 0.06s;
}
.btn:hover { background: #36475c; }
.btn:active { transform: translateY(1px); }
.btn.active { background: #d32f2f; color: #fff; border-color: #b71c1c; }
.btn-primary { background: #1976d2; border-color: #1565c0; }
.btn-primary:hover { background: #1e88e5; }
.btn-success { background: #2e7d32; border-color: #1b5e20; }
.btn-success:hover { background: #388e3c; }
.btn.hidden { display: none; }

/* Name entry input */
.name-input {
  width: 100%;
  font-family: monospace;
  font-size: 16px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 6px;
  border: 1px solid #3d4a5b;
  background: #0e151d;
  color: #ffffff;
}
.name-input:focus { outline: 2px solid #1976d2; }

/* How to play (start screen) */
.how-to-play {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #2d3a4a;
}
.htp-title {
  margin: 0 0 8px;
  font-family: monospace;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8aa0b6;
}
.htp-list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.6;
  color: #c8d2dd;
}
.htp-list strong { color: #ffffff; }

/* Dialogue */
.dialogue-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.dialogue-swatch {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid #111;
  display: inline-block;
}
.dialogue-name { font-weight: bold; font-size: 16px; }
.dialogue-role { font-size: 12px; color: #99a7b6; font-family: monospace; }
.dialogue-line {
  font-size: 16px;
  line-height: 1.4;
  margin: 12px 0;
  color: #f0f4f8;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a2330;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2000;
}
.toast.toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast[data-tone="error"] { border-left: 4px solid #e53935; }
.toast[data-tone="good"]  { border-left: 4px solid #43a047; }

/* ── Phones / touch: keep overlays inside the viewport ── */
@media (pointer: coarse), (max-width: 820px) {
  .overlay { padding: 10px; align-items: flex-start; }
  .overlay-card {
    padding: 16px 16px;
    max-height: 94vh;
    max-height: 94dvh;
    /* keep clear of notches when an overlay covers a full-bleed game */
    margin-top: max(0px, env(safe-area-inset-top));
  }
  .overlay-title { font-size: 19px; }
  /* Any inner lesson control that hard-codes a px width must not overflow the
     card on a narrow screen (max-width caps width:NNNpx to the container). */
  .overlay-card canvas { max-width: 100%; height: auto; }
  .overlay-card input[type="range"] { max-width: 100%; }
  .overlay-card img,
  .overlay-card svg { max-width: 100%; height: auto; }
  /* Comfortable tap targets */
  .btn { padding: 10px 16px; font-size: 15px; }
  /* The 48-record crate grid is 6-col on desktop; 4-col fits a phone */
  .crate-grid { grid-template-columns: repeat(4, 1fr) !important; }
}
