/* ==========================================================================
   portfolio : compiler.css, the Pyodide python compiler (add-on layer)
   self-contained. it reuses root design tokens only tho and never edits chatbot.css
   ========================================================================== */

#py-compiler {
  padding: 100px 0;
  background: var(--bg3);
  transition: background 0.3s;
}

.compiler-shell {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  gap: 18px;
}

.compiler-pane {
  flex: 1 1 50%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: background 0.3s, border-color 0.35s, box-shadow 0.45s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.compiler-pane:focus-within {
  border-color: rgba(201, 169, 110, 0.45);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(201, 169, 110, 0.12);
}

.compiler-pane--terminal {
  display: flex;
  flex-direction: column;
}
.compiler-body--terminal {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.compiler-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.06);
}

.compiler-widget-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.compiler-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  margin-left: auto;
  transition: background 0.25s;
}
.compiler-status-dot--ready {
  background: var(--gold);
  animation: compilerPulse 2.6s ease-in-out infinite;
}
@keyframes compilerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.75); }
}

.compiler-status-label {
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.compiler-body {
  padding: 22px 24px 26px;
}

.py-editor {
  display: flex;
  align-items: stretch;
  min-height: 160px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.04);
  transition: border-color 0.22s;
}
[data-theme="dark"] .py-editor { background: rgba(255, 255, 255, 0.04); }
.py-editor:focus-within { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(201, 169, 110, 0.12); }

.py-gutter {
  flex-shrink: 0;
  width: 38px;
  margin: 0;
  padding: 16px 8px 16px 0;
  border: none;
  border-right: 1px solid var(--border-light);
  text-align: right;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--muted);
  opacity: 0.55;
  user-select: none;
  white-space: pre;
  background: rgba(0, 0, 0, 0.02);
}
[data-theme="dark"] .py-gutter { background: rgba(255, 255, 255, 0.02); }

.py-editor-body {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
}
.py-editor-body > * { grid-area: 1 / 1; }

.py-highlight,
.py-input {
  margin: 0;
  padding: 16px 18px;
  border: none;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
  -moz-tab-size: 4;
}

.py-highlight {
  pointer-events: none;
  color: var(--text);
  background: transparent;
}
.py-highlight code { font: inherit; }

.py-editor .py-input {
  display: block;
  width: 100%;
  min-height: unset;
  border-radius: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--gold);
  outline: none;
  resize: none;
  overflow: hidden;
}

.tok-keyword   { color: #0000ff; }
.tok-string    { color: #a31515; }
.tok-comment   { color: #008000; font-style: italic; }
.tok-number    { color: #098658; }
.tok-funcdef,
.tok-funccall,
.tok-decorator { color: #795e26; }
.tok-classname { color: #267f99; }
.tok-self      { color: #001080; }

[data-theme="dark"] .tok-keyword   { color: #569cd6; }
[data-theme="dark"] .tok-string    { color: #ce9178; }
[data-theme="dark"] .tok-comment   { color: #6a9955; }
[data-theme="dark"] .tok-number    { color: #b5cea8; }
[data-theme="dark"] .tok-funcdef,
[data-theme="dark"] .tok-funccall,
[data-theme="dark"] .tok-decorator { color: #dcdcaa; }
[data-theme="dark"] .tok-classname { color: #4ec9b0; }
[data-theme="dark"] .tok-self      { color: #9cdcfe; }

.compiler-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.py-run-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: 1px solid rgba(201, 169, 110, 0.5);
  border-radius: 4px;
  background: transparent;
  color: var(--gold);
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.22s, color 0.22s, border-color 0.22s, transform 0.15s, opacity 0.2s;
}
.py-run-btn:hover:not(:disabled) {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
  transform: translateY(-1px);
}
.py-run-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.py-run-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.py-clear-btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.22s, color 0.22s;
}
.py-clear-btn:hover { border-color: var(--gold); color: var(--gold); }
.py-clear-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.compiler-actions { flex-wrap: wrap; }

.py-snippet-picker {
  margin-left: auto;
}

.py-snippet-select {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.22s, color 0.22s;
}
.py-snippet-select:hover { border-color: var(--gold); color: var(--gold); }
.py-snippet-select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.py-snippet-select option {
  background: var(--card-bg);
  color: var(--text);
  text-transform: none;
}

.compiler-body--terminal { padding: 22px 24px 26px; }

.py-output-wrap {
  margin-top: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.py-output-label {
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.py-output {
  margin: 0;
  flex: 1 1 auto;
  min-height: 300px;
  max-height: none;
  overflow-y: auto;
  padding: 16px 18px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  outline: none;
  cursor: text;
  transition: border-color 0.22s;
}
.py-output--awaiting-input { border-color: rgba(201, 169, 110, 0.5); }
[data-theme="dark"] .py-output { background: rgba(255, 255, 255, 0.03); }
.py-output::-webkit-scrollbar       { width: 4px; }
.py-output::-webkit-scrollbar-track { background: transparent; }
.py-output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.py-output .py-stderr { color: #c62828; }
[data-theme="dark"] .py-output .py-stderr { color: #ef9a9a; }

.py-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  background: transparent;
  caret-color: transparent;
  pointer-events: none;
}

.py-typed-input {
  color: var(--gold);
  font-weight: 700;
}

.py-caret {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 1px;
  background: var(--gold);
  vertical-align: text-bottom;
  animation: pyCaretBlink 1s step-end infinite;
}
@keyframes pyCaretBlink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .py-caret { animation: none; opacity: 1; }
}

.chat-code-block { margin: 4px 0 2px; }

.chat-code-block pre {
  margin: 0 0 8px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
[data-theme="dark"] .chat-code-block pre { background: rgba(255, 255, 255, 0.04); }

.run-in-compiler-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(201, 169, 110, 0.5);
  border-radius: 4px;
  background: transparent;
  color: var(--gold);
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.22s, color 0.22s;
}
.run-in-compiler-btn:hover { background: var(--gold); color: var(--bg); }
.run-in-compiler-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (max-width: 980px) {
  .compiler-shell { flex-direction: column; padding: 0 18px; }
  .compiler-pane  { flex: 1 1 auto; }
}

@media (max-width: 768px) {
  #py-compiler            { padding: 64px 0; }
  .compiler-widget-header { padding: 13px 18px; }
  .compiler-body          { padding: 18px 18px 22px; }
  .py-editor              { min-height: 140px; max-height: 280px; }
  .py-output              { min-height: 200px; }

  .py-gutter,
  .py-highlight,
  .py-input {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .compiler-status-dot--ready { animation: none; opacity: 1; }
}