/* Editor-style layout: explorer, tabs, editor and terminal in Dark+ colours. */

:root {
  --bg: #1e1e1e;
  --side: #252526;
  --tabs: #2d2d2d;
  --term: #181818;
  --border: #3c3c3c;
  --text: #cccccc;
  --muted: #8b8b8b;
  --hover: #2a2d2e;
  --selected: #37373d;
  --accent: #0078d4;
  --link: #4fc1ff;
  --status: #007acc;
  --mono: "Cascadia Code", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, sans-serif;
  display: grid;
  grid-template-rows: 1fr 22px;
}

.workbench {
  position: relative;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 0;
}

/* The drawer toggle only exists for narrow screens. */
.drawer-toggle { display: none; }

/* ---- Explorer ---- */

.explorer {
  background: var(--side);
  border-right: 1px solid var(--border);
  overflow: auto;
  min-height: 0;
}
.section-title {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 10px 14px 6px;
  color: #bbbbbb;
}
.row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding-right: 8px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.row:hover { background: var(--hover); }
.row.selected { background: var(--selected); color: #ffffff; }
.row .chev { width: 12px; text-align: center; font-size: 10px; color: var(--muted); }
.row.dir.cwd .name { color: #ffffff; font-weight: 600; }
.row .icon { color: var(--muted); font-size: 12px; }

/* ---- Editor column ---- */

.editor-col {
  display: grid;
  grid-template-rows: 35px 1fr minmax(170px, 30%);
  min-height: 0;
  min-width: 0;
}

.tabs {
  display: flex;
  background: var(--side);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 35px;
  padding: 0 10px 0 14px;
  background: var(--tabs);
  color: var(--muted);
  border-right: 1px solid var(--side);
  border-top: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg); color: #ffffff; border-top-color: var(--accent); }
.tab .close {
  border: 0;
  background: none;
  color: inherit;
  font-size: 15px;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  cursor: pointer;
  opacity: .6;
}
.tab .close:hover { background: var(--border); opacity: 1; }

.editor {
  background: var(--bg);
  padding: 14px 44px 32px;
  overflow: auto;
  min-height: 0;
}
.crumbs { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
#doc { max-width: 760px; line-height: 1.65; font-size: 14px; }
#doc h1 { font-size: 30px; font-weight: 600; margin-bottom: 10px; color: #ffffff; }
#doc h2 { font-size: 18px; font-weight: 600; margin: 26px 0 6px; color: #ffffff; }
#doc p { margin-bottom: 12px; }
#doc ul { margin: 0 0 12px 22px; }
#doc li { margin-bottom: 4px; }
#doc a { color: var(--link); text-decoration: none; }
#doc a:hover { text-decoration: underline; }
#doc .meta { color: var(--muted); font-size: 12px; margin-bottom: 20px; }
#doc code { font-family: var(--mono); background: #2d2d2d; padding: 1px 5px; border-radius: 3px; font-size: 12.5px; }

/* ---- Terminal ---- */

.terminal {
  background: var(--term);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 26px 1fr auto;
  min-height: 0;
}
.term-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 6px 14px 0;
  color: #bbbbbb;
  border-bottom: 1px solid var(--border);
}
.term-out {
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 14px;
  overflow: auto;
  min-height: 0;
  white-space: pre-wrap;
  line-height: 1.5;
}
.term-out .cmd { color: #ffffff; }
.term-out .err { color: #f48771; }
.term-out .dir { color: var(--link); }
.term-in {
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 13px;
  padding: 0 14px 8px;
}
.term-in .prompt { color: #6a9955; white-space: pre; }
.term-in input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: #ffffff;
  font: inherit;
  caret-color: #ffffff;
}

/* ---- Status bar ---- */

.statusbar {
  background: var(--status);
  color: #ffffff;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}

/* Narrow screens: the explorer becomes a drawer. It starts open, and a strip stays visible when closed. */
@media (max-width: 768px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }

  .explorer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(260px, 82vw);
    z-index: 10;
    box-shadow: 4px 0 12px rgba(0, 0, 0, .5);
    transform: translateX(0);
    transition: transform .2s ease;
  }
  .explorer:not(.open) { transform: translateX(calc(-100% + 34px)); }

  .drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 34px;
    background: var(--side);
    border: 0;
    border-right: 1px solid var(--border);
    color: #bbbbbb;
    cursor: pointer;
  }
  .drawer-toggle span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .drawer-toggle:hover, .drawer-toggle:focus-visible { color: #ffffff; outline: none; }
  .explorer .section-title { padding-right: 44px; }

  /* Gutter for the closed explorer strip, so it never covers content. */
  .editor-col {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 35px 1fr minmax(150px, 34%);
    padding-left: 34px;
    overflow: hidden;
  }
  body { grid-template-columns: minmax(0, 1fr); }
  .term-in .prompt { max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .editor { padding: 12px 18px 24px; }
  #doc h1 { font-size: 24px; }
  .term-out { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
