/* Python debugging practice: the app's Coding layout on the site. The
   problem sits beside the code; the tests sit under it. The editor keeps
   the app's dark code colors in both themes. */
.wrap-wide {
  max-width: calc(1180px + 2 * var(--gutter));
}
.cd-box {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  padding: 12px;
  cursor: auto;
}
.cd-desc {
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: auto;
  max-height: 620px;
}
.cd-title {
  font-size: 22px;
  letter-spacing: -0.02em;
}
.cd-statement {
  margin-top: 10px;
  color: var(--ink-2);
}
.cd-example {
  margin-top: 18px;
}
.cd-example b {
  font-size: 15px;
}
.cd-example p {
  margin-top: 4px;
  font-size: 15px;
  color: var(--ink-2);
}
.cd-desc code,
.cd-constraints code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-sunk);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.cd-label {
  margin-top: 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
}
.cd-constraints {
  margin-top: 6px;
  padding-left: 18px;
  font-size: 14px;
  color: var(--ink-3);
}
.cd-constraints li + li {
  margin-top: 4px;
}
.cd-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}
.cd-panel {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  min-width: 0;
  overflow: hidden;
}
.cd-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 6px 10px 6px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
}
.cd-head .spacer {
  flex: 1;
}
.cd-name {
  display: flex;
  align-items: center;
  gap: 7px;
}
.cd-name svg {
  color: var(--teal);
}
.cd-bugs {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-ink);
  font-size: 12.5px;
}
.cd-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.cd-icon:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

/* The editor: highlighted code under a transparent textarea, both in one
   grid cell so the textarea is always the code's size. */
.cd-code {
  background: #1c1c1e;
  border-color: #1c1c1e;
}
.cd-code .cd-head {
  color: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.07);
}
.cd-code .cd-name svg {
  color: var(--acc);
}
.cd-code .cd-bugs {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
}
.cd-code .cd-icon {
  color: rgba(255, 255, 255, 0.5);
}
.cd-code .cd-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.cd-editor {
  display: flex;
  padding: 12px 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
}
.cd-gutter {
  margin: 0;
  padding: 0 12px 0 14px;
  font: inherit;
  text-align: right;
  color: rgba(255, 255, 255, 0.28);
  user-select: none;
}
.cd-scroll {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}
.cd-area {
  display: grid;
  min-width: max-content;
  padding-right: 14px;
}
.cd-view,
.cd-input {
  grid-area: 1 / 1;
  margin: 0;
  padding: 0;
  font: inherit;
  line-height: inherit;
  white-space: pre;
  tab-size: 4;
}
/* Above the highlighted lines (they're positioned for the hint marks), so
   clicks and typing reach the textarea. */
.cd-input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: var(--acc);
}
.cd-input::selection {
  background: color-mix(in srgb, var(--acc) 35%, transparent);
}
.cd-view .ln {
  display: block;
  position: relative;
  color: rgba(255, 255, 255, 0.88);
}
.cd-view .k { color: var(--acc); }
.cd-view .b { color: #67b7f7; }
.cd-view .s { color: #8fd18a; }
.cd-view .n { color: #d0bf69; }
.cd-view .c { color: #7f8c98; }
/* Hint 1: the buggy lines, and a bar where a line is missing. */
.cd-view .ln.bug {
  background: color-mix(in srgb, var(--acc) 22%, transparent);
  box-shadow: -40px 0 0 color-mix(in srgb, var(--acc) 22%, transparent), 14px 0 0 color-mix(in srgb, var(--acc) 22%, transparent);
}
.cd-view .ln.missing::before,
.cd-view .ln.missing-after::after {
  content: "";
  position: absolute;
  left: -40px;
  right: -14px;
  height: 2px;
  background: var(--acc);
}
.cd-view .ln.missing::before {
  top: -1px;
}
.cd-view .ln.missing-after::after {
  bottom: -1px;
}
/* Hint 2: the fix, as a diff under the code. */
.cd-fix {
  margin: 0 12px 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
}
.cd-fix-head {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}
.cd-diff {
  margin-top: 8px;
}
.cd-diff .at {
  display: block;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}
.cd-diff code {
  display: block;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre;
  overflow-x: auto;
  padding: 1px 6px;
  border-radius: 4px;
}
.cd-diff .del {
  color: #ff8a80;
  background: rgba(224, 40, 41, 0.14);
}
.cd-diff .add {
  color: #7ee2a0;
  background: rgba(45, 181, 93, 0.16);
}

/* Tests */
.cd-tab {
  border: 0;
  background: none;
  padding: 6px 8px;
  border-radius: 7px;
  font: inherit;
  color: var(--ink-3);
  cursor: pointer;
}
.cd-tab.on {
  color: var(--ink);
}
.cd-tab:hover {
  color: var(--ink);
}
.cd-pane {
  padding: 12px 14px 14px;
  overflow: auto;
  max-height: 340px;
}
.cd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.cd-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 5px 11px;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
}
.cd-chip.on {
  background: var(--bg-sunk);
  color: var(--ink);
}
.cd-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.cd-chip i.ok {
  background: #2db55d;
}
.cd-chip i.bad {
  background: #e02829;
}
.cd-field {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.cd-field span {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}
.cd-field code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cd-field.bad code {
  color: #d93025;
}
:root[data-theme="dark"] .cd-field.bad code {
  color: #ff6b61;
}
.cd-pane .cd-label {
  margin-top: 12px;
}
.cd-verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 10px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.cd-verdict.ok {
  color: #1f9d4c;
}
.cd-verdict.bad {
  color: #d93025;
}
:root[data-theme="dark"] .cd-verdict.ok {
  color: #3fcf73;
}
:root[data-theme="dark"] .cd-verdict.bad {
  color: #ff6b61;
}
.cd-verdict small {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-3);
}
.cd-wait {
  padding: 28px 0;
  text-align: center;
  color: var(--ink-3);
}

/* Narrow screens: the problem above the code, everything full width. */
@media (max-width: 900px) {
  .cd-box {
    grid-template-columns: minmax(0, 1fr);
  }
  .cd-desc {
    max-height: none;
  }
}
@media (max-width: 560px) {
  .cd-box {
    padding: 8px;
    gap: 8px;
  }
  /* 16px so iOS doesn't zoom into the code when you tap it. */
  .cd-editor {
    font-size: 16px;
  }
  .cd-head {
    flex-wrap: wrap;
  }
}

/* Laptops and up: like the other tools, the head and the trainer fill one
   screen under the nav and picker; the problem, code and tests scroll
   inside their panels instead of the page. */
@media (min-width: 901px) {
  .tool-screen {
    height: calc(100svh - var(--above));
    min-height: 560px;
  }
  .tool-screen > .tool-band,
  .tool-screen > .tool-band > .wrap {
    min-height: 0;
  }
  .tool-head {
    padding: clamp(16px, 4svh, 48px) 0 clamp(12px, 2.4svh, 24px);
  }
  .tool-head .display {
    font-size: clamp(36px, 6svh, 60px);
  }
  .tool-head .lead {
    margin-top: 10px;
  }
  .cd-box {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }
  .cd-desc {
    max-height: none;
    min-height: 0;
  }
  .cd-main {
    min-height: 0;
    grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  }
  /* The code and the fix scroll together under the panel's header. */
  .cd-code {
    min-height: 0;
    overflow-y: auto;
  }
  .cd-code .cd-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1c1c1e;
  }
  .cd-tests {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .cd-pane {
    flex: 1;
    min-height: 0;
    max-height: none;
  }
}
