/* Number Search Demo — module-specific styles
   Reuses maze_demo.css design tokens and layout conventions.
   Sibling of wordsearch.css with ns-* selectors. */

/* ── Layout ── */
.ns-main {
  display: grid;
  grid-template-columns: 280px 1.5fr;
  gap: 0;
  /* Bound the shell to the viewport (mirrors maze_demo's .maze-main) so the
     columns' overflow-y:auto actually engages. A min-height let the grid grow
     unbounded, so the app shell's overflow:hidden clipped the settings panel
     and the primary Generate CTA was unreachable on short laptops (#773/#718). */
  height: calc(100vh - var(--mg-navbar-height));
  height: calc(100dvh - var(--mg-navbar-height));
  overflow: hidden;
}

/* Issue #718: bound the grid to the viewport at tablet/desktop so each column
   becomes its own scroll container. With only `min-height`, the grid grows with
   its content and the `.maze-app-layout` shell's `overflow:hidden` clips
   anything below the fold — including the primary Generate CTA — at short
   laptop heights (1366×768, 1280×720). Mirrors the maze generator's bounded
   `.maze-main` and the crossword/cryptogram `.cw-col` fix (#717). */
@media (min-width: 768px) {
  .ns-main {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    overflow: hidden;
  }
  .ns-col-1,
  .ns-col-2 {
    height: 100%;
  }
}

.ns-col-1 {
  padding: 1rem;
  border-right: 1px solid var(--mg-border);
  height: 100%;
  overflow-y: auto;
  background: var(--mg-surface);
}

.ns-col-2 {
  padding: 1.5rem;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ── Section titles ── */
.ns-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mg-text-muted);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--mg-border);
}

/* ── Type cards ── */
.ns-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ns-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--mg-border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--mg-surface);
  text-align: center;
  min-height: 44px;
}

.ns-type-card:hover {
  border-color: var(--mg-primary);
  background: rgba(37, 99, 235, 0.08);
  background: color-mix(in srgb, var(--mg-primary) 8%, transparent);
}

.ns-type-card.selected {
  border-color: var(--mg-primary);
  background: rgba(37, 99, 235, 0.12);
  background: color-mix(in srgb, var(--mg-primary) 12%, transparent);
  box-shadow: 0 0 0 1px var(--mg-primary);
}

.ns-type-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
  position: relative;
}

.ns-type-card.locked .lock-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.65rem;
  color: var(--mg-text-muted);
}

.ns-type-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ns-type-card .type-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: var(--mg-primary);
}

.ns-type-card .type-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mg-text);
}

.ns-type-card .type-desc {
  font-size: 0.65rem;
  color: var(--mg-text-muted);
}

/* ── Number-list source toggle ── */
.ns-numberlist-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ns-numberlist-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 2px solid var(--mg-border);
  border-radius: 0.5rem;
  cursor: pointer;
  background: var(--mg-surface);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--mg-text);
  transition: border-color 0.15s, background 0.15s;
  min-height: 44px;
}

.ns-numberlist-btn:hover {
  border-color: var(--mg-primary);
}

.ns-numberlist-btn.selected {
  border-color: var(--mg-primary);
  background: rgba(37, 99, 235, 0.12);
  background: color-mix(in srgb, var(--mg-primary) 12%, transparent);
  box-shadow: 0 0 0 1px var(--mg-primary);
}

.ns-numberlist-btn input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* ── Random params + custom-numbers textarea ── */
.ns-random-params {
  margin-bottom: 0.75rem;
}

.ns-custom-numbers {
  display: none;
}

.ns-custom-numbers.active {
  display: block;
}

.ns-custom-numbers textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem;
  border: 1px solid var(--mg-border);
  border-radius: 0.375rem;
  background: var(--mg-input-bg, var(--mg-surface));
  color: var(--mg-text);
}

.ns-custom-numbers textarea:focus {
  outline: 2px solid var(--mg-primary);
  outline-offset: 2px;
  border-color: var(--mg-primary);
}

.ns-custom-numbers .mg-form-hint {
  font-size: 0.75rem;
  color: var(--mg-text-muted);
  margin-top: 0.25rem;
}

/* ── Mobile ── */
.ns-tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--mg-surface);
  border-top: 1px solid var(--mg-border);
  z-index: 1000;
}

.ns-tabbar .ns-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--mg-text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  min-height: 44px;
}

.ns-tabbar .ns-tab.active {
  color: var(--mg-primary);
}

.ns-tabbar .ns-tab i {
  font-size: 1.1rem;
}

@media (max-width: 767.98px) {
  /* Issue #718: bound the panel to the space above the fixed tab bar so the
     active column scrolls internally — otherwise the app shell's overflow:hidden
     clips controls (incl. the Generate CTA) below the fold at short heights.
     Mirrors maze_demo's mobile `.maze-main` height. */
  .ns-main {
    grid-template-columns: 1fr;
    height: calc(100vh - var(--mg-navbar-height) - var(--mg-tabbar-height));
    height: calc(100dvh - var(--mg-navbar-height) - var(--mg-tabbar-height));
  }

  .ns-col-1,
  .ns-col-2 {
    display: none;
    border-right: none;
  }

  .ns-col-1.active-panel,
  .ns-col-2.active-panel {
    display: block;
    height: 100%;
    overflow-y: auto;
  }

  .ns-tabbar {
    display: flex;
  }

  .ns-type-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .ns-numberlist-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) and (max-width: 992px) {
  .ns-main {
    grid-template-columns: 260px 1fr;
  }
}

/* ── Focus indicators ── */
.ns-type-card:focus-within {
  outline: 2px solid var(--mg-primary);
  outline-offset: 2px;
}

.ns-numberlist-btn:focus-within {
  outline: 2px solid var(--mg-primary);
  outline-offset: 2px;
}

/* ── Print ── */
@media print {
  .ns-col-1,
  .ns-tabbar {
    display: none !important;
  }

  .ns-col-2 {
    display: block !important;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .ns-type-card,
  .ns-numberlist-btn {
    transition: none;
  }
}
