﻿/* c_challenge_engine.css */

.cch-wrap { margin-top: 10px; }

.cch-card{
  border: 0;
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

.cch-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.cch-meta{
  margin:6px 0 0 0;
  line-height: 1.35;
  font-size: 15px;
  padding: 4px 14px;
}

.cch-section-title {
  margin-top: 28px;
  margin-bottom: 6px;
}

.cch-section-intro {
  margin-top: 0;
  margin-bottom: 16px;
}


/* ---------- Split Layout (Instructions + Editor side-by-side) ---------- */
.cch-split{
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
  align-items: stretch; /* make both columns the same height */
  margin-top: 10px;
}

.cch-instructions{
  border: 1px solid #e6e6e6;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.5;
  height: 100%;
}

.cch-workarea{
  min-width: 0; /* IMPORTANT: prevents editor overflow */
  display: flex; /* lets editor panel fill height */
}

/* Instructions header row (title + layout toggle) */
.cch-instr-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  border-bottom: 1px solid #f1f1f1;
}

.cch-instructions h4{
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.1px;
  padding: 16px 14px 17px 14px;
}

/* Toggle icon button (HALF SIZE) */
.cch-layoutbtn{
  border: 1px solid #e6e6e6;
  background: #fff;
  color: #111;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  user-select:none;
  padding: 0;
  margin-right: 10px;
}
.cch-layoutbtn:hover{
  background:#f7f7f7;
  border-color:#d9d9d9;
}
.cch-layoutbtn:active{ transform: translateY(1px); }

.cch-layoutico{
  width: 14px;
  height: 14px;
  display:block;
  position: relative;
}

/* default: stacked (two horizontal cards) */
.cch-layoutico:before,
.cch-layoutico:after{
  content:"";
  position:absolute;
  left:0;
  width: 14px;
  border: 1px solid #111;
  border-radius: 2px;
  height: 6px;
}
.cch-layoutico:before{ top:0; }
.cch-layoutico:after{ bottom:0; }

/* pressed: split (two vertical cards) */
.cch-layoutbtn[aria-pressed=true] .cch-layoutico:before,
.cch-layoutbtn[aria-pressed=true] .cch-layoutico:after{
  top:0; bottom:auto;
  height: 14px;
  width: 6px;
}
.cch-layoutbtn[aria-pressed=true] .cch-layoutico:before{ left:0; }
.cch-layoutbtn[aria-pressed=true] .cch-layoutico:after{ left:auto; right:0; }

/* Stack on <=1450px (forced) */
@media (max-width: 1450px){
  .cch-split{ grid-template-columns: 1fr; }
  .cch-layoutbtn{ display:none; } /* button only available above 1450px */
}

/* --- Manual override ONLY applies above 1450px --- */
@media (min-width: 1451px){
  body.cch-force-stack .cch-split{
    grid-template-columns: 1fr; /* user can choose stacked even on large screens */
  }
}

/* ------- Editor Panel + Sticky Toolbar ------- */
.cch-editorpanel{
  margin-top: 0;
  border: 1px solid #1f2130;
  border-radius: 6px;
  overflow: hidden;
  background: #111;

  display:flex;          /* fill the column height */
  flex-direction:column; /* toolbar on top, editor fills rest */
  width: 100%;
}

/* Sticky toolbar (sticks within viewport) */
.cch-toolbar{
  position: sticky;
  top: 0;
  z-index: 2;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 10px 10px;

  background: #0f111a;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 2px 0 rgba(0,0,0,0.18);
}

.cch-toolbar-left{
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 0;
}
.cch-toolbar-title{
  color:#E7E9EB;
  font-weight: 700;
  font-size: 13px;
  opacity: 0.95;
  user-select:none;
  white-space: nowrap;
}

.cch-toolbar-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap: nowrap; /* prevent stacking */
}

/* Buttons */
.cch-btn{
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #111;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  user-select: none;
  display:inline-flex;
  align-items:center;
  gap:8px;
  white-space: nowrap;
}
.cch-btn:hover{
  background: #f5f5f5;
  border-color:#cfcfcf;
}
.cch-btn:active{ transform: translateY(1px); }

.cch-btn-primary{
  background:#04AA6D;
  border-color:#04AA6D;
  color:#fff;
}
.cch-btn-primary:hover{
  background:#039a63;
  border-color:#039a63;
}
.cch-btn-ghost{
  background:#f7f7f7;
}

/* Toolbar buttons slightly tighter */
.cch-toolbar .cch-btn{
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 6px;
  gap: 4px;
}

/* Small inline icons */
.cch-ico{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 16px;
  height: 16px;
  line-height: 1;
  font-size: 14px;
}

/* Chevron */
.cch-chev{
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #111;
  transition: transform 0.18s ease;
}
.cch-btn[aria-expanded=true] .cch-chev{
  transform: rotate(180deg);
}

/* Editor */
.c-editor-wrap{
  position: relative;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  margin-top: 0;

  flex: 1 1 auto; /* fill remaining height under toolbar */
  min-height: 240px;
}

.c-editor-highlight{
  margin: 0;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 240px;
  color: #E7E9EB;
}

.c-editor-input{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  margin: 0;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
  background: transparent;
  color: transparent;
  caret-color: #ffffff;
  resize: vertical;
  outline: none;
}
.c-editor-input::selection{
  background: rgba(4, 170, 109, 0.25);
}

/* Syntax colors */
.c-k{ color:#C792EA; font-weight:600; }
.c-t{ color:#82AAFF; font-weight:600; }
.c-f{ color:#FFCB6B; }
.c-s{ color:#C3E88D; }
.c-n{ color:#F78C6C; }
.c-c{ color:#A0A4B8; font-style:italic; }

.c-line-ok{
  background: rgba(4, 170, 109, 0.14);
  border-left: 4px solid #04AA6D;
  padding-left: 10px;
  margin-left: -14px;
  margin-right: -14px;
}

/* Summary + checklist */
.cch-summary{
  display:none;
  margin-top: 12px;
  border-radius: 12px;
  padding: 12px;
}

.cch-checkwrap{ display:none; margin-top:12px; }
.cch-checkwrap h4{
  margin:0 0 8px 0;
  font-size: 16px;
  letter-spacing: -0.1px;
}

.cch-checklist{
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #e6e6e6;
  border-radius: 6px;
  overflow: hidden;
}

.cch-checklist li{
  display:flex;
  gap:10px;
  align-items:flex-start;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  font-size: 14px;
}
.cch-checklist li:first-child{ border-top: 0; }

.cch-checklist .chk-badge{
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  flex: 0 0 22px;
  margin-top: 1px;
}

.cch-checklist .chk-badge.ok{
  background: rgba(4,170,109,0.14);
  color: #037a50;
  border: 1px solid rgba(4,170,109,0.25);
}
.cch-checklist .chk-badge.no{
  background: rgba(179,29,40,0.10);
  color: #b31d28;
  border: 1px solid rgba(179,29,40,0.20);
}

/* Solution box */
.cch-solutionbox{
  display:block;
  margin-top: 12px;
  border:1px solid #ddd;
  border-radius: 6px;
  overflow:hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease, transform 0.18s ease;
}
.cch-solutionbox[hidden]{
  opacity: 0;
  pointer-events: none;
}
.cch-solutionbox.is-open{
  opacity: 1;
  transform: translateY(0);
}

.cch-solution-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  background:#E7E9EB;
  border-bottom:1px solid #E7E9EB;
  color:black;
}

.cch-solution-title{
  font-weight:700;
  font-size: 15px;
}

.cch-solution-sub{
  color:#666;
  font-size: 13px;
  margin-top:2px;
}

.cch-solution-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}

/* Tiny toast */
.cch-soltoast{
  display:none;
  font-size: 13px;
  color:#037a50;
  background: rgba(4,170,109,0.14);
  border: 1px solid rgba(4,170,109,0.25);
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.cch-soltoast.show{
  display:inline-flex;
  align-items:center;
  gap:6px;
}

.cch-solution-codewrap{
  padding: 10px;
}

/* Solution textarea */
.cch-solution-plain{
  width: 100%;
  min-height: 190px;
  border: none;
  border-radius: 6px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
  background: #282A35;
  color: #E7E9EB;
  resize: none;
}

/* Small screens: shrink buttons, shorten labels */
@media (max-width: 520px){
  .cch-toolbar{ padding: 8px; }

  .cch-toolbar .cch-btn{
    padding: 6px 8px;
    font-size: 12px;
    gap:6px;
  }
  .cch-chev{
    border-left-width:4px;
    border-right-width:4px;
    border-top-width:5px;
  }

  /* Solution */
  .cch-sol-label-long{ display:none; }
  .cch-sol-label-short{ display:inline; }

  /* Check */
  .cch-check-label-long{ display:none; }
  .cch-check-label-short{ display:inline; }
}
@media (min-width: 521px){
  /* Solution */
  .cch-sol-label-long{ display:inline; }
  .cch-sol-label-short{ display:none; }

  /* Check */
  .cch-check-label-long{ display:inline; }
  .cch-check-label-short{ display:none; }
}

/* Dark theme tweak */
body.darkpagetheme .cch-instructions,
body.darkpagetheme .cch-instr-head{
  border: 1px solid #38444d;
}
