/* ==========================================================================
   theme.css — terminal/agentic UI starter
   Flexoki palette · https://stephango.com/flexoki
   Companion to DESIGN.md. @import this, then build components on the tokens.
   ========================================================================== */

/* --- Design tokens: dark (default) --------------------------------------- */
:root {
  /* Neutral ramp: bg → raised surfaces → borders → text */
  --bg: #100f0f;
  --bg-2: #1c1b1a;
  --ui: #282726;
  --ui-2: #343331;
  --ui-3: #403e3c;
  --tx-3: #575653; /* faint   */
  --tx-2: #878580; /* muted   */
  --tx: #cecdc3; /* primary */

  /* Accents — 400-level, tuned for dark */
  --red: #d14d41;
  --orange: #da702c;
  --yellow: #d0a215;
  --green: #879a39;
  --cyan: #3aa99f;
  --blue: #4385be;
  --purple: #8b7ec8;
  --magenta: #ce5d97;

  /* Code/diff panes — stay dark in both themes */
  --code-bg: #100f0f;
  --code-fg: #cecdc3;
  --diff-add: rgba(135, 154, 57, 0.16);
  --diff-del: rgba(209, 77, 65, 0.16);

  --radius: 2px;
  --nav-h: 42px;
}

/* --- Design tokens: light (warm paper) ----------------------------------- */
:root[data-theme='light'] {
  --bg: #fffcf0;
  --bg-2: #f2f0e5;
  --ui: #e6e4d9;
  --ui-2: #dad8ce;
  --ui-3: #cecdc3;
  --tx-3: #b7b5ac;
  --tx-2: #6f6e69;
  --tx: #100f0f;

  /* Accents — 600-level, tuned for light */
  --red: #af3029;
  --orange: #bc5215;
  --yellow: #ad8301;
  --green: #66800b;
  --cyan: #24837b;
  --blue: #205ea6;
  --purple: #5e409d;
  --magenta: #a02f6f;

  /* Code panes follow the theme in light mode */
  --code-bg: #fffcf0;
  --code-fg: #100f0f;
  --diff-add: rgba(102, 128, 11, 0.14);
  --diff-del: rgba(175, 48, 41, 0.14);
}

/* --- Reset --------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background-color: var(--bg);
  color: var(--tx);
  font-family: ui-monospace, 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* --- Typography ---------------------------------------------------------- */
h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.3;
}

h1 {
  font-size: 1.4rem;
  color: var(--tx);
}

h2 {
  font-size: 1.1rem;
  color: var(--tx);
}

/* Shell-prompt motifs — the signature. Remove or scope out for rendered
   user content (e.g. `.markdown h1::before { content: none; }`). */
h1::before {
  content: '$ ';
  color: var(--green);
}

h2::before {
  content: '# ';
  color: var(--tx-3);
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  color: var(--cyan);
}

hr {
  border: none;
  border-top: 1px solid var(--ui);
}

code {
  font-family: inherit;
}

::selection {
  background: var(--blue);
  color: var(--bg);
}

/* --- Form controls ------------------------------------------------------- */
input,
textarea,
select,
button {
  background-color: var(--bg-2);
  border: 1px solid var(--ui-2);
  border-radius: var(--radius);
  color: var(--tx);
  font-family: inherit;
  font-size: inherit;
  padding: 6px 10px;
}

input::placeholder,
textarea::placeholder {
  color: var(--tx-3);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 1px var(--blue);
}

textarea {
  min-height: 90px;
  resize: vertical;
  width: 100%;
}

/* File inputs — theme the native control and its selector button so it matches
   the other form controls instead of falling back to the browser default. */
input[type='file'] {
  cursor: pointer;
  line-height: 1.6;
}

input[type='file']::file-selector-button {
  margin-right: 10px;
  padding: 3px 10px;
  background-color: var(--ui);
  border: 1px solid var(--ui-3);
  border-radius: var(--radius);
  color: var(--tx);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  transition:
    background-color 0.1s ease,
    border-color 0.1s ease;
}

input[type='file']::file-selector-button:hover {
  background-color: var(--ui-3);
  border-color: var(--tx-3);
}

label {
  color: var(--tx-2);
}

button {
  cursor: pointer;
  transition:
    background-color 0.1s ease,
    border-color 0.1s ease,
    color 0.1s ease;
}

button:hover {
  background-color: var(--ui);
  border-color: var(--ui-3);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Intent button variants — recolor text + border, faint tinted hover fill. */
.btn-create {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 55%, var(--ui-2));
}

.btn-create:hover {
  background: color-mix(in srgb, var(--green) 14%, var(--bg-2));
  border-color: var(--green);
}

.btn-danger {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 50%, var(--ui-2));
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--red) 14%, var(--bg-2));
  border-color: var(--red);
}

/* Square, terminal-style checkboxes and radios. */
input[type='radio'],
input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  display: inline-grid;
  place-content: center;
  border: 1px solid var(--ui-3);
  border-radius: 0;
  background: var(--bg);
  cursor: pointer;
  vertical-align: -2px;
  transition:
    border-color 0.1s ease,
    background-color 0.1s ease;
}

input[type='radio']:hover,
input[type='checkbox']:hover {
  border-color: var(--tx-2);
}

input[type='radio']:checked,
input[type='checkbox']:checked {
  border-color: var(--cyan);
}

input[type='radio']::before,
input[type='checkbox']::before {
  transform: scale(0);
  transition: transform 0.08s ease-in-out;
}

input[type='radio']::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--cyan);
}

input[type='checkbox']:checked {
  background: var(--cyan);
}

input[type='checkbox']::before {
  content: '\2713';
  color: var(--bg);
  font-size: 11px;
  line-height: 1;
}

input[type='radio']:checked::before,
input[type='checkbox']:checked::before {
  transform: scale(1);
}

input[type='radio']:focus-visible,
input[type='checkbox']:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cyan) 45%, transparent);
}

/* --- Scrollbars (blocky, on-theme) --------------------------------------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ui-3) var(--bg-2);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-2);
}

::-webkit-scrollbar-thumb {
  background: var(--ui-3);
  border: 2px solid var(--bg-2);
  border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--tx-3);
}

::-webkit-scrollbar-corner {
  background: var(--bg-2);
}

/* --- Animations ---------------------------------------------------------- */
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

/* --- Utilities ----------------------------------------------------------- */
.muted {
  color: var(--tx-2);
}

.faint {
  color: var(--tx-3);
}

.error {
  color: var(--red);
}

.warning {
  color: var(--yellow);
}

/* Workhorse panel: raised surface inside a hairline border. */
.panel {
  border: 1px solid var(--ui);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 16px;
}

/* Centered page column. */
.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}

/* Blinking block cursor (pair with a brand/logo). */
.cursor {
  color: var(--green);
  animation: blink 1.1s step-end infinite;
}

/* Outline status badge, color via currentColor, with a leading dot. */
.status-badge {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  font-size: 0.82em;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}

.status-badge::before {
  content: '● ';
  font-size: 0.8em;
}

.status-open,
.status-done {
  color: var(--green);
}

.status-closed {
  color: var(--red);
}

.status-merged {
  color: var(--purple);
}

.status-pending,
.status-draft {
  color: var(--yellow);
}

/* --- Code & diff surfaces ------------------------------------------------ */
.code {
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--ui);
  border-radius: var(--radius);
  overflow: auto;
  tab-size: 4;
}

.diff-add {
  background: var(--diff-add);
}

.diff-del {
  background: var(--diff-del);
}

/* --- Responsive — single 820px breakpoint -------------------------------- */
@media (max-width: 820px) {
  img,
  svg,
  video,
  canvas {
    max-width: 100%;
    height: auto;
  }

  .page-shell {
    padding: 20px 12px 56px;
  }

  .panel {
    padding: 12px;
  }
}
