/* === 18-ide/styles.css ===
 * IDE / code editor interface — devtools (linear-dark)
 */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
a { text-decoration-skip-ink: auto; color: inherit; }
:focus-visible { outline: 2px solid var(--syntax-keyword); outline-offset: 2px; }

/* --- Fluid Scales --- */
:root {
  --step--2: clamp(0.69rem, 0.66rem + 0.18vw, 0.80rem);
  --step--1: clamp(0.83rem, 0.78rem + 0.25vw, 1.00rem);
  --step-0:  clamp(1.00rem, 0.93rem + 0.33vw, 1.13rem);
  --step-1:  clamp(1.20rem, 1.10rem + 0.45vw, 1.41rem);
  --step-2:  clamp(1.44rem, 1.30rem + 0.63vw, 1.76rem);
  --step-3:  clamp(1.73rem, 1.54rem + 0.88vw, 2.20rem);

  --space-3xs: clamp(0.25rem, 0.23rem + 0.11vw, 0.31rem);
  --space-2xs: clamp(0.50rem, 0.46rem + 0.22vw, 0.63rem);
  --space-xs:  clamp(0.75rem, 0.69rem + 0.33vw, 0.94rem);
  --space-s:   clamp(1.00rem, 0.93rem + 0.33vw, 1.13rem);
  --space-m:   clamp(1.50rem, 1.39rem + 0.54vw, 1.69rem);
}

/* --- Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Devtools Domain Tokens --- */
:root {
  --color-bg: oklch(0.10 0.01 270);
  --color-sidebar: oklch(0.12 0.01 270);
  --color-editor: oklch(0.10 0.01 270);
  --color-terminal: oklch(0.08 0.01 270);
  --color-tab-bg: oklch(0.14 0.012 270);
  --color-tab-active: oklch(0.10 0.01 270);
  --color-text: oklch(0.90 0.005 260);
  --color-text-dim: oklch(0.60 0.008 260);
  --color-heading: oklch(0.95 0.003 260);
  --color-accent: oklch(0.70 0.25 290);
  --color-border: oklch(0.25 0.012 270);
  --color-line-num: oklch(0.40 0.008 260);
  --color-line-highlight: oklch(0.15 0.015 270);

  /* Syntax colors */
  --syntax-keyword: oklch(0.75 0.20 290);
  --syntax-string: oklch(0.75 0.15 150);
  --syntax-number: oklch(0.80 0.15 80);
  --syntax-comment: oklch(0.50 0.01 260);
  --syntax-function: oklch(0.80 0.18 210);
  --syntax-type: oklch(0.75 0.20 180);
  --syntax-property: oklch(0.85 0.10 60);

  --font-ui: 'Geist Sans', 'DM Sans', system-ui, sans-serif;
  --font-code: 'Geist Mono', 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Page --- */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-code);
  font-size: 13px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 220px 1fr;
  grid-template-areas:
    "tabs tabs"
    "sidebar editor"
    "status status";
}

/* --- Tab Bar --- */
.tab-bar {
  grid-area: tabs;
  background: var(--color-tab-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  overflow-x: auto;
}

.tab {
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--color-text-dim);
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  white-space: nowrap;
  transition: background 200ms, color 200ms;
  background: none;
}

.tab:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.tab.active {
  background: var(--color-tab-active);
  color: var(--color-heading);
  border-bottom: 2px solid var(--syntax-keyword);
}

/* --- Sidebar (File Tree) --- */
.sidebar {
  grid-area: sidebar;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  padding: 8px 0;
  overflow-y: auto;
  font-family: var(--font-ui);
  font-size: 12px;
}

.tree-header {
  padding: 4px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  margin-bottom: 4px;
}

.tree-item {
  padding: 3px 12px 3px 20px;
  cursor: pointer;
  color: var(--color-text-dim);
  transition: background 100ms;
  white-space: nowrap;
}

.tree-item:hover {
  background: var(--color-line-highlight);
  color: var(--color-text);
}

.tree-item.active {
  background: var(--color-line-highlight);
  color: var(--color-heading);
}

.tree-folder {
  padding: 3px 12px;
  color: var(--color-text);
  font-weight: 600;
  cursor: pointer;
}

.tree-folder::before {
  content: "▸ ";
  color: var(--color-text-dim);
}

.tree-folder.open::before {
  content: "▾ ";
}

.tree-indent {
  padding-left: 32px;
}

/* --- Editor Area --- */
.editor {
  grid-area: editor;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* --- Code Lines --- */
.code-line {
  display: flex;
  min-height: 20px;
  line-height: 20px;
  padding: 0 16px 0 0;
}

.code-line:hover {
  background: var(--color-line-highlight);
}

.line-num {
  display: inline-block;
  min-width: 48px;
  padding: 0 12px;
  text-align: right;
  color: var(--color-line-num);
  user-select: none;
  flex-shrink: 0;
}

.line-content {
  flex: 1;
  white-space: pre;
}

/* Syntax classes */
.kw { color: var(--syntax-keyword); }
.str { color: var(--syntax-string); }
.num { color: var(--syntax-number); }
.cmt { color: var(--syntax-comment); font-style: italic; }
.fn { color: var(--syntax-function); }
.type { color: var(--syntax-type); }
.prop { color: var(--syntax-property); }

/* --- Terminal Panel --- */
.terminal-panel {
  border-top: 1px solid var(--color-border);
  background: var(--color-terminal);
  padding: 8px 12px;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.terminal-title {
  font-family: var(--font-ui);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 4px;
}

.terminal-line {
  line-height: 1.6;
  color: var(--color-text-dim);
}

.terminal-prompt {
  color: var(--syntax-string);
}

.terminal-output {
  color: var(--color-text);
}

/* --- Status Bar --- */
.status-bar {
  grid-area: status;
  background: var(--syntax-keyword);
  color: white;
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 2px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-left, .status-right {
  display: flex;
  gap: 16px;
}

/* --- Mobile: Stack Layout --- */
@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tabs"
      "editor"
      "status";
    overflow-y: auto;
    height: auto;
  }
  html, body { overflow: auto; }
  .sidebar { display: none; }
  .editor { overflow: visible; }
  .editor-content { overflow: visible; }
}
