/* ==========================================================================
   Online PHP & HTML Compiler
   ========================================================================== */

/* ---- Editor: line numbers + textarea ---- */
.pc-editor {
  --pc-font: 0.86rem;
  --pc-line: 1.6;
  --pc-pad-y: 0.85rem;
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--field-bg);
  overflow: hidden;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.pc-editor:hover { border-color: rgba(var(--ink), 0.22); }
.pc-editor:focus-within {
  border-color: rgba(139, 92, 246, 0.7);
  background-color: var(--field-bg-focus);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.16);
}
.pc-gutter {
  flex: none;
  min-width: 3.4em;
  margin: 0;
  padding: var(--pc-pad-y) 0.6rem calc(var(--pc-pad-y) + 40px) 0.5rem;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: var(--pc-font)/var(--pc-line) var(--font-mono);
  text-align: right;
  white-space: pre;
  user-select: none;
}
.pc-gutter mark { border-radius: 4px; background: rgba(251, 113, 133, 0.22); color: var(--danger-text); font-weight: 700; }
.pc-gutter mark.is-warn { background: rgba(245, 158, 11, 0.2); color: var(--warn-text); }
.pc-code {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 420px;
  margin: 0;
  padding: var(--pc-pad-y) 0.9rem;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: var(--pc-font)/var(--pc-line) var(--font-mono);
  white-space: pre;
  overflow: auto;
  overflow-wrap: normal;
  tab-size: 4;
  resize: vertical;
  caret-color: var(--lilac);
}
.pc-code::selection { background: rgba(139, 92, 246, 0.35); }

.pc-hint { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; margin: -0.6rem 0 0; }
.pc-cursor { font-family: var(--font-mono); white-space: nowrap; }

/* ---- Run / Stop ---- */
.pc-run-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; }
.pc-run { gap: 0.55rem; }
.pc-run .icon, .pc-stop .icon { width: 16px; height: 16px; }
.pc-run .icon { fill: currentColor; }
.pc-kbd {
  padding: 0.1rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  font: 600 0.72rem/1.4 var(--font-body);
  white-space: nowrap;
}
.pc-stop { gap: 0.5rem; }
.pc-stop:not([disabled]) { border-color: rgba(251, 113, 133, 0.55); color: var(--danger-text); }
.pc-js { font-size: 0.85rem; }

.pc-facts { display: flex; flex-direction: column; gap: 0.55rem; margin: 0; padding: 0; list-style: none; color: var(--text-2); font-size: 0.85rem; line-height: 1.5; }
.pc-facts li { display: flex; align-items: flex-start; gap: 0.55rem; }
.pc-facts .icon { flex: none; width: 16px; height: 16px; margin-top: 0.15rem; color: var(--lilac); }
.pc-facts strong { color: var(--text); font-weight: 600; }
.pc-credits { margin: -0.4rem 0 0; line-height: 1.5; }
.pc-credits a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }

/* ---- Status line ---- */
.pc-status {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.6rem;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.88rem;
  line-height: 1.5;
}
.pc-status-icon { display: inline-grid; place-items: center; flex: none; }
.pc-status-icon .icon { width: 18px; height: 18px; stroke-width: 2.4; }
.pc-status-icon .spinner { border-color: rgba(139, 92, 246, 0.3); border-top-color: var(--lilac); }
.pc-status-text { flex: 1 1 12rem; min-width: 0; }
.pc-status.is-good { border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); color: var(--success-text); }
.pc-status.is-warn { border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.08); color: var(--warn-text); }
.pc-status.is-bad { border-color: rgba(251, 113, 133, 0.35); background: rgba(251, 113, 133, 0.08); color: var(--danger-text); }
.pc-bar { flex: 1 0 100%; height: 6px; overflow: hidden; border-radius: 999px; background: var(--border); }
.pc-bar > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--grad); transition: width 0.2s; }

/* ---- Errors ---- */
.pc-errors {
  display: flex; flex-direction: column; gap: 0.5rem;
  margin: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(251, 113, 133, 0.35);
  border-radius: 12px;
  background: rgba(251, 113, 133, 0.07);
  font-size: 0.86rem;
}
.pc-errors.is-warn { border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.07); }
.pc-errors-title { margin: 0; color: var(--text); font-size: 0.9rem; font-weight: 700; }
.pc-errors ol { display: flex; flex-direction: column; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.pc-err { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.5rem; color: var(--text-2); }
.pc-err-kind { flex: none; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.pc-err.is-bad .pc-err-kind { background: rgba(251, 113, 133, 0.18); color: var(--danger-text); }
.pc-err.is-warn .pc-err-kind { background: rgba(245, 158, 11, 0.18); color: var(--warn-text); }
.pc-err-msg { flex: 1 1 14rem; min-width: 0; margin: 0; color: var(--text); font: 0.82rem/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.pc-err-line {
  flex: none;
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--link);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.pc-err-line:hover { border-color: rgba(139, 92, 246, 0.55); }
.pc-err-line:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; }
.pc-err-more { color: var(--muted); font-size: 0.8rem; }

/* ---- Result panels ---- */
.pc-preview { display: block; width: 100%; height: 560px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color-scheme: light; }
.pc-raw { max-height: 560px; min-height: 160px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pc-raw .pc-e { border-radius: 4px; }
.pc-raw .pc-e.is-bad { background: rgba(251, 113, 133, 0.14); color: var(--danger-text); }
.pc-raw .pc-e.is-warn { background: rgba(245, 158, 11, 0.13); color: var(--warn-text); }
.pc-raw .pc-none { color: var(--muted); font-style: italic; }

@media (max-width: 960px) {
  .pc-code { min-height: 340px; }
  .pc-preview { height: 480px; }
  .pc-raw { max-height: 480px; }
}
@media (max-width: 520px) {
  .pc-editor { --pc-font: 0.8rem; }
  .pc-code { min-height: 300px; }
  .pc-gutter { min-width: 2.6em; padding-left: 0.3rem; padding-right: 0.4rem; }
  .pc-run, .pc-stop { flex: 1 1 auto; }
  .pc-kbd { display: none; }
  .pc-preview { height: 380px; }
  .pc-raw { max-height: 380px; }
}
