/**
 * Tool Product Contract Layer
 *
 * Loaded after per-site CSS so active tool sites keep one product shell:
 * 1400px max width, five template families, stable surfaces, no letter spacing.
 */

.tool-site-shell {
  --container-max: 1400px;
  --tool-max: 1400px;
  --tool-reading-max: 880px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 8px;
  --radius-button: 6px;
  --radius-card: 8px;
  --tool-page-bg: #f7fafc;
  --tool-surface: #ffffff;
  --tool-surface-soft: #f8fafc;
  --tool-accent: var(--color-primary, #2563eb);
  --tool-accent-strong: var(--color-primary-dark, #1d4ed8);
  --tool-ink: #172033;
  --tool-muted: #5b6678;
  --tool-line: #d8e0ea;
  --tool-card-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tool-accent) 7%, white) 0, var(--tool-page-bg) 320px),
    var(--tool-page-bg);
  color: var(--tool-ink);
  overflow-x: hidden;
}

.tool-site-shell,
.tool-site-shell * {
  letter-spacing: 0 !important;
}

body.site-1,
body.site-8,
body.site-17 {
  --tool-template-family: math-practice;
  --tool-page-bg: #f5faf8;
  --tool-surface-soft: #eef8f3;
  --tool-accent: #0f766e;
  --tool-accent-strong: #115e59;
  --tool-line: #cfe3dd;
}

body.site-3,
body.site-4,
body.site-5,
body.site-6,
body.site-10,
body.site-11,
body.site-14,
body.site-15,
body.site-16,
body.site-18 {
  --tool-template-family: grid-puzzle;
  --tool-page-bg: #f8faf7;
  --tool-surface-soft: #f1f5ea;
  --tool-accent: #4f6f52;
  --tool-accent-strong: #314c37;
  --tool-line: #dce6d4;
}

body.site-9 {
  --tool-template-family: coloring-print;
  --tool-page-bg: #fff8fb;
  --tool-surface-soft: #fff0f5;
  --tool-accent: #be185d;
  --tool-accent-strong: #9f1239;
  --tool-line: #f5cddd;
}

body.site-2,
body.site-13,
body.site-20,
body.site-21,
body.site-22,
body.site-23,
body.site-24,
body.site-29 {
  --tool-template-family: early-learning;
  --tool-page-bg: #f7fbff;
  --tool-surface-soft: #edf7ff;
  --tool-accent: #2f6f91;
  --tool-accent-strong: #255d7a;
  --tool-line: #d2e5f1;
}

body.site-7,
body.site-12,
body.site-27 {
  --tool-template-family: generator-tool;
  --tool-page-bg: #f9faf7;
  --tool-surface-soft: #f0f4ef;
  --tool-accent: #64703f;
  --tool-accent-strong: #48512d;
  --tool-line: #dfe5d3;
}

.tool-site-shell .container,
.tool-site-shell .detail-page,
.tool-site-shell .home-page,
.tool-site-shell .list-page,
.tool-site-shell .category-page,
.tool-site-shell .detail-content-area {
  width: min(var(--tool-max), calc(100% - 32px));
  max-width: var(--tool-max);
  margin-inline: auto;
}

.tool-site-shell :is(
  .page-header,
  .intro,
  .body-content,
  .set-switcher,
  #detail-atom-mount,
  .seo-card,
  .guide-content-card,
  .intro-content-card,
  .form-problem,
  .activity-card,
  .sheet-preview,
  .sheet-block,
  .sheet-reference-card,
  .canvas-container,
  .creative-canvas
) {
  border-radius: var(--radius-card) !important;
}

.tool-site-shell :is(.btn, button, .set-btn, .detail-atom-btn) {
  border-radius: var(--radius-button) !important;
}

.tool-site-shell .page-header {
  border: 1px solid var(--tool-line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--tool-accent) 10%, white), var(--tool-surface) 58%),
    var(--tool-surface);
  box-shadow: var(--tool-card-shadow);
}

.tool-site-shell #detail-atom-mount {
  width: 100%;
  max-width: var(--tool-max);
  margin: 1.25rem auto 1.75rem;
  border: 1px solid var(--tool-line);
  background: var(--tool-surface);
  box-shadow: var(--tool-card-shadow);
  overflow: clip;
}

.tool-site-shell #detail-atom-mount .loading {
  display: none !important;
}

/* Product polish: keep unfinished/secondary plugin panels out of the default worksheet view. */
.tool-site-shell :is(
  .ia-data-panel,
  .ia-daily-challenge,
  .ia-favorites-controls,
  .challenge-mode-plugin-wrapper,
  .achievement-plugin-wrapper,
  .achievement-badge-wall-panel,
  .achievement-progress-panel,
  .error-counter,
  .session-replay-container,
  .replay-control-panel,
  .classroom-mode-plugin-container
) {
  display: none !important;
}

.tool-site-shell .detail-atom-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--tool-line);
  background: color-mix(in srgb, var(--tool-surface-soft) 72%, white);
}

.tool-site-shell .detail-atom-btn {
  min-height: 44px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--tool-line);
  background: #ffffff;
  color: var(--tool-ink);
  font-weight: 750;
}

.tool-site-shell .detail-atom-btn-reveal,
.tool-site-shell .detail-atom-btn-check {
  border-color: var(--tool-accent);
  background: var(--tool-accent);
  color: #ffffff;
}

body.site-2 .form-exercise-container,
body.site-20 .form-exercise-container,
body.site-21 .form-exercise-container,
body.site-22 .form-exercise-container,
body.site-23 .form-exercise-container,
body.site-24 .form-exercise-container,
body.site-29 .sheet-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1rem;
  padding: clamp(1rem, 2vw, 1.5rem);
}

body.site-2 .form-problem,
body.site-20 .form-problem,
body.site-21 .form-problem,
body.site-22 .form-problem,
body.site-23 .form-problem,
body.site-24 .form-problem,
body.site-29 .sheet-block,
body.site-29 .sheet-reference-card {
  min-width: 0;
  min-height: 150px;
  border: 1px solid var(--tool-line);
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

body.site-9 .canvas-container,
body.site-9 .creative-canvas {
  display: grid;
  place-items: center;
  min-height: clamp(440px, 60vh, 760px);
  padding: clamp(1rem, 2vw, 1.75rem);
  background: #ffffff;
}

body.site-9 :is(.canvas-container, .creative-canvas, .coloring-scene-svg) svg,
body.site-9 .coloring-scene-svg {
  width: min(100%, 980px);
  height: auto;
  max-height: 72vh;
  border: 1px solid var(--tool-line);
  background: #ffffff;
}

body.site-7 :is(.card-grid, .card-activity-grid),
body.site-27 :is(.card-grid, .card-activity-grid) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
  padding: clamp(1rem, 2vw, 1.5rem);
}

body.site-12 .sheet-preview {
  display: grid;
  place-items: center;
  padding: clamp(1rem, 2vw, 1.5rem);
  overflow: auto;
}

body.site-12 :is(.sheet-grid-svg, .sheet-dots-svg) {
  width: min(100%, 1100px);
  height: auto;
  border: 1px solid var(--tool-line);
  background: #ffffff;
}

@media (max-width: 768px) {
  .tool-site-shell .container,
  .tool-site-shell .detail-page,
  .tool-site-shell .home-page,
  .tool-site-shell .list-page,
  .tool-site-shell .category-page,
  .tool-site-shell .detail-content-area {
    width: min(100% - 20px, var(--tool-max));
  }

  .tool-site-shell #detail-atom-mount {
    margin-block: 1rem 1.25rem;
  }
}
