/* Calcudoku Demo - module-specific styles.
   Reuses maze_demo.css design tokens and layout conventions. */

/* ── Layout ── */
.calcudoku-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 —
     #calcudoku-colors-toggle, the colour pickers and the upgrade link fell below
     the fold with no way to scroll to them 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 (e.g. the Color Options fields once expanded) at short
   laptop heights (1366×768, 1280×720). Mirrors the maze generator's bounded
   `.maze-main` and the crossword/cryptogram fix (#717). */
@media (min-width: 768px) {
  .calcudoku-main {
    height: calc(100vh - var(--mg-navbar-height));
    height: calc(100dvh - var(--mg-navbar-height));
    overflow: hidden;
  }
  .calcudoku-col-1,
  .calcudoku-col-2 {
    height: 100%;
  }
}

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

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

/* ── SEO content below the generator (#1711) ──
   The preview keeps the full column height (no flex-shrink) and the content
   block follows it, reached by scrolling the column itself. */
.calcudoku-col-2 > .preview-area {
  flex-shrink: 0;
}

.calcudoku-seo {
  max-width: 820px;
  width: 100%;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--mg-border);
  color: var(--mg-text);
  line-height: 1.6;
}

.calcudoku-seo .calcudoku-seo-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--mg-text);
  margin: 1.5rem 0 0.75rem;
}

.calcudoku-seo .calcudoku-seo-heading:first-child {
  margin-top: 0;
}

.calcudoku-seo-steps {
  padding-left: 1.25rem;
  margin-bottom: 0;
}

.calcudoku-seo-steps li + li {
  margin-top: 0.35rem;
}

.calcudoku-seo-card {
  height: 100%;
  padding: 1rem 1.25rem;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  background: var(--mg-surface);
}

.calcudoku-seo-card h3,
.calcudoku-seo-faq-item h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--mg-text);
  margin-bottom: 0.5rem;
}

.calcudoku-seo-card h3 i {
  color: var(--mg-primary);
  margin-right: 0.35rem;
}

.calcudoku-seo-card p,
.calcudoku-seo-faq-item p {
  color: var(--mg-text-muted);
  margin-bottom: 0;
}

.calcudoku-seo-faq-item + .calcudoku-seo-faq-item {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--mg-border);
}

/* ── Section titles ── */
.calcudoku-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);
}
.calcudoku-section-title i {
  color: var(--mg-primary);
}

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

.calcudoku-type-card {
  position: relative;
  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;
}

.calcudoku-type-card:hover {
  border-color: var(--mg-primary);
  background: color-mix(in srgb, var(--mg-primary) 8%, transparent);
}

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

.calcudoku-type-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.calcudoku-type-card.locked:hover {
  border-color: var(--mg-border);
  background: var(--mg-surface);
}

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

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

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

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

/* ── Mobile tab bar ── */
.calcudoku-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;
}

.calcudoku-tabbar .calcudoku-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;
}

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

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

@media (max-width: 767.98px) {
  .calcudoku-main {
    grid-template-columns: 1fr;
    padding-bottom: 60px;
  }

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

  .calcudoku-col-1.active-panel,
  .calcudoku-col-2.active-panel {
    display: block;
  }

  .calcudoku-tabbar {
    display: flex;
  }
}

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

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

.calcudoku-tabbar .calcudoku-tab:focus-visible {
  outline: 2px solid var(--mg-primary);
  outline-offset: 2px;
}

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

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

/* ── Loading state ── */
#preview-container.is-loading #image-container {
  opacity: 0.3;
}

/* ── Paid export: batch ZIP control (issue #679) ── */
.mg-batch-control {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
  width: 100%;
}

.mg-batch-control .mg-batch-count {
  flex: 0 0 4.5rem;
  width: 4.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  background: var(--mg-surface);
  color: var(--mg-text);
  font-size: 0.95rem;
  text-align: center;
}

.mg-batch-control .btn-download-batch {
  flex: 1 1 auto;
}

.mg-batch-control .mg-batch-count:focus-visible {
  outline: 2px solid var(--mg-primary);
  outline-offset: 1px;
}

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