/*
  Shared crisp treatment for the GCSE interactive guides.
  This stylesheet is scoped to the guide shell so the CodeBash header and
  surrounding page retain their existing design.
*/

.gcse-guide-shell {
  --gcse-teal: #29d9a8;
  --gcse-teal-strong: #5eead4;
  --gcse-ink: #effffb;
  --gcse-soft: #b4cbc5;
  --gcse-muted: #78918b;
  --gcse-bg: #091411;
  --gcse-surface: #10211d;
  --gcse-surface-2: #17302a;
  --gcse-code: #0a1513;
  --gcse-line: rgba(41, 217, 168, .2);
  --gcse-line-strong: rgba(41, 217, 168, .42);
  position: relative;
  color: var(--gcse-ink);
  background:
    linear-gradient(90deg, rgba(41, 217, 168, .014) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--gcse-bg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif !important;
}

.gcse-guide-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  z-index: 0;
}

.gcse-guide-shell > * {
  position: relative;
  z-index: 1;
}

.gcse-guide-shell h1,
.gcse-guide-shell h2,
.gcse-guide-shell h3,
.gcse-guide-shell .hero h1 {
  color: var(--gcse-ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif !important;
  font-weight: 800;
  letter-spacing: -.055em;
}

.gcse-guide-shell h2 {
  font-size: clamp(1.4rem, 2vw, 1.65rem);
  line-height: 1.22;
  letter-spacing: -.025em;
}

.gcse-guide-shell p,
.gcse-guide-shell li {
  color: var(--gcse-soft);
}

.gcse-guide-shell .gcse-collection-bar {
  max-width: none !important;
  margin: 0 !important;
  padding: 13px max(20px, calc((100% - 1000px) / 2)) !important;
  border: 0 !important;
  border-bottom: 1px solid var(--gcse-line) !important;
  border-radius: 0 !important;
  background: rgba(9, 20, 17, .97) !important;
}

.gcse-guide-shell .gcse-collection-bar a:first-child {
  color: var(--gcse-teal-strong) !important;
}

.gcse-guide-shell .hero {
  max-width: none;
  padding: clamp(58px, 9vw, 104px) max(20px, calc((100% - 1000px) / 2)) 64px;
  text-align: left;
  border-bottom: 1px solid var(--gcse-line);
  background:
    linear-gradient(90deg, rgba(41, 217, 168, .04) 0 1px, transparent 1px) 0 0 / 72px 100%,
    var(--gcse-bg);
}

.gcse-guide-shell .hero h1 {
  max-width: 820px;
  margin-bottom: 22px;
  font-size: clamp(2.45rem, 5.4vw, 4.8rem);
  line-height: .98;
}

.gcse-guide-shell .hero .lede {
  max-width: 64ch;
  margin-right: 0 !important;
  margin-left: 0 !important;
  color: #c0d6d0;
  font-size: 1.15rem;
  line-height: 1.72;
}

.gcse-guide-shell .hero .badge,
.gcse-guide-shell .step-badge {
  padding: 3px 0 3px 10px;
  border: 0;
  border-left: 3px solid var(--gcse-teal);
  border-radius: 0;
  background: transparent;
  color: var(--gcse-teal-strong);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .8125rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.35;
  text-transform: uppercase;
}

.gcse-guide-shell nav,
.gcse-guide-shell .tabs {
  padding: 0 16px;
  gap: 0;
  border-color: var(--gcse-line);
  background: rgba(9, 20, 17, .97);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.gcse-guide-shell nav a,
.gcse-guide-shell .tab-btn {
  padding: 15px 13px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--gcse-soft);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
}

.gcse-guide-shell nav a.active,
.gcse-guide-shell .tab-btn.active {
  border-bottom-color: var(--gcse-teal) !important;
  background: transparent !important;
  color: var(--gcse-ink) !important;
}

.gcse-guide-shell nav a:not(.active):hover,
.gcse-guide-shell .tab-btn:hover:not(.active) {
  border-color: var(--gcse-teal);
  background: rgba(41, 217, 168, .045);
  color: var(--gcse-teal-strong);
}

.gcse-guide-shell section,
.gcse-guide-shell .quiz-section {
  padding-top: clamp(44px, 6vw, 78px);
  padding-bottom: clamp(34px, 5vw, 60px);
  border-color: var(--gcse-line);
  background: rgba(9, 20, 17, .94);
}

.gcse-guide-shell section > p,
.gcse-guide-shell section > .lede,
.gcse-guide-shell section .scenario-desc,
.gcse-guide-shell section .task-prompt {
  max-width: 64ch;
  color: var(--gcse-soft);
  font-size: 1.125rem;
  line-height: 1.72;
}

.gcse-guide-shell .layout {
  gap: 18px;
  margin: 24px 0;
}

.gcse-guide-shell .card,
.gcse-guide-shell .schema-tname,
.gcse-guide-shell .schema-col-row,
.gcse-guide-shell .explain-box,
.gcse-guide-shell .solution-box,
.gcse-guide-shell .simplify-step {
  border-radius: 0 !important;
  box-shadow: none !important;
}

.gcse-guide-shell .card {
  padding: 20px !important;
  border: 1px solid var(--gcse-line) !important;
  background: var(--gcse-surface) !important;
}

.gcse-guide-shell .card::before {
  display: none !important;
}

.gcse-guide-shell .schema-col {
  padding: 22px 18px;
  border-color: var(--gcse-line);
  background: rgba(16, 33, 29, .78);
}

.gcse-guide-shell .main-col {
  gap: 18px;
}

.gcse-guide-shell .schema-title,
.gcse-guide-shell .task-label,
.gcse-guide-shell .editor-label,
.gcse-guide-shell h3.box-h {
  color: var(--gcse-teal-strong);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .8125rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.35;
}

.gcse-guide-shell .card p,
.gcse-guide-shell .card ul,
.gcse-guide-shell .card ol,
.gcse-guide-shell .card li,
.gcse-guide-shell .side p,
.gcse-guide-shell .side ul,
.gcse-guide-shell .side ol,
.gcse-guide-shell .side li,
.gcse-guide-shell .explain-box,
.gcse-guide-shell .quiz-q p.qtext {
  color: var(--gcse-soft) !important;
  font-size: 1.0625rem !important;
  line-height: 1.7 !important;
}

.gcse-guide-shell .schema-tname {
  border-color: var(--gcse-line);
  background: var(--gcse-surface-2);
  color: var(--gcse-teal-strong);
}

.gcse-guide-shell .schema-cols,
.gcse-guide-shell .schema-col-row,
.gcse-guide-shell .results-scroll,
.gcse-guide-shell .results-table th,
.gcse-guide-shell .results-table td,
.gcse-guide-shell .stat-table th,
.gcse-guide-shell .stat-table td,
.gcse-guide-shell .truth-table th,
.gcse-guide-shell .truth-table td,
.gcse-guide-shell .laws-table th,
.gcse-guide-shell .laws-table td {
  border-color: var(--gcse-line);
}

.gcse-guide-shell .schema-col-row {
  background: rgba(9, 20, 17, .5);
}

.gcse-guide-shell .task-nav {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gcse-line);
}

.gcse-guide-shell .task-type-badge,
.gcse-guide-shell .group-chip {
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 0;
  background: transparent;
}

.gcse-guide-shell button,
.gcse-guide-shell .size-btn,
.gcse-guide-shell .toggle-btn {
  min-height: 38px;
  border-color: var(--gcse-line-strong);
  border-radius: 0 !important;
  background: var(--gcse-surface-2) !important;
  color: var(--gcse-ink);
  transition: border-color .16s ease, background-color .16s ease, color .16s ease;
}

.gcse-guide-shell button:hover:not(:disabled),
.gcse-guide-shell .size-btn:hover,
.gcse-guide-shell .toggle-btn:hover {
  border-color: var(--gcse-teal);
  background: #1d3a33;
  color: var(--gcse-teal-strong);
}

.gcse-guide-shell button.primary,
.gcse-guide-shell .size-btn.active {
  border-color: var(--gcse-teal) !important;
  background: var(--gcse-teal) !important;
  color: #07130f !important;
}

.gcse-guide-shell button.primary:hover:not(:disabled),
.gcse-guide-shell .size-btn.active:hover {
  border-color: var(--gcse-teal-strong);
  background: var(--gcse-teal-strong);
  color: #07130f;
}

.gcse-guide-shell button:focus-visible,
.gcse-guide-shell a:focus-visible,
.gcse-guide-shell textarea:focus-visible,
.gcse-guide-shell .kmap-cell:focus-visible {
  outline: 2px solid var(--gcse-teal-strong);
  outline-offset: 3px;
}

.gcse-guide-shell textarea,
.gcse-guide-shell .code-box,
.gcse-guide-shell .solution-box {
  border-color: var(--gcse-line);
  border-radius: 0;
  background: var(--gcse-code);
  color: #d9ebe6;
}

.gcse-guide-shell textarea {
  border-color: var(--gcse-line-strong);
  line-height: 1.65;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}

.gcse-guide-shell .code-line.hl {
  border-left-color: var(--gcse-teal);
}

.gcse-guide-shell .explain-box {
  border: 1px solid var(--gcse-line-strong);
  border-left: 3px solid var(--gcse-teal);
  background: rgba(23, 48, 42, .76);
}

.gcse-guide-shell .results-scroll,
.gcse-guide-shell .results-table,
.gcse-guide-shell .kmap-cell,
.gcse-guide-shell .toggle-btn,
.gcse-guide-shell .gate-output,
.gcse-guide-shell .quiz-opt,
.gcse-guide-shell .status-msg,
.gcse-guide-shell .quiz-fb {
  border-radius: 0 !important;
}

.gcse-guide-shell .results-table th,
.gcse-guide-shell .stat-table th,
.gcse-guide-shell .truth-table th,
.gcse-guide-shell .laws-table th {
  color: var(--gcse-teal-strong);
}

.gcse-guide-shell .results-table th {
  background: var(--gcse-surface-2);
}

.gcse-guide-shell .kmap-cell,
.gcse-guide-shell .quiz-opt {
  border-color: var(--gcse-line-strong);
  background: var(--gcse-surface-2) !important;
}

.gcse-guide-shell .quiz-opt:hover {
  border-color: var(--gcse-teal);
}

@media (max-width: 800px) {
  .gcse-guide-shell .tabs,
  .gcse-guide-shell nav {
    padding-right: 10px;
    padding-left: 10px;
  }

  .gcse-guide-shell .workspace {
    min-height: 0;
  }

  .gcse-guide-shell .schema-col {
    max-height: 300px;
  }
}

@media (max-width: 640px) {
  .gcse-guide-shell .hero {
    padding: 54px 18px 44px;
  }

  .gcse-guide-shell .hero h1 {
    font-size: clamp(2.45rem, 13vw, 4rem);
  }

  .gcse-guide-shell section,
  .gcse-guide-shell .quiz-section {
    padding-right: 16px;
    padding-left: 16px;
  }

  .gcse-guide-shell .card {
    padding: 16px;
  }

  .gcse-guide-shell nav a,
  .gcse-guide-shell .tab-btn {
    padding: 12px 10px 10px;
    font-size: .8125rem;
  }

  .gcse-guide-shell .kmap-cell,
  .gcse-guide-shell .toggle-btn {
    width: 50px;
    height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gcse-guide-shell button,
  .gcse-guide-shell .size-btn,
  .gcse-guide-shell .toggle-btn {
    transition: none;
  }
}