/*
 * Design System
 * =============
 *
 * Philosophy: Terminal/editor aesthetic. High contrast. Functional.
 *
 * All colors meet WCAG AA contrast requirements (4.5:1 for text).
 * Tested with Chrome DevTools contrast checker.
 *
 * Color roles:
 *   --bg           Main background
 *   --bg-alt       Inputs, code blocks, cards
 *   --fg           Primary text (high contrast)
 *   --fg-muted     Secondary text, labels (still readable)
 *   --border       Borders, dividers
 *   --accent       Links, primary actions
 *   --accent-fg    Text on accent background
 *   --success      Positive feedback
 *   --error        Errors, destructive
 *   --warning      Warnings (used in lint tool)
 */

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --line-height: 1.6;
  --max-width: 72ch;
  --radius: 3px;

  /* Light mode - dark text on light background */
  --bg: #ffffff;
  --bg-alt: #f4f4f4;
  --fg: #111111;
  --fg-muted: #555555;
  --border: #d0d0d0;
  --accent: #0055dd;
  --accent-hover: #0044aa;
  --accent-fg: #ffffff;
  --success: #007700;
  --error: #cc0000;
  --warning: #886600;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark mode - light text on dark background */
    --bg: #111111;
    --bg-alt: #1e1e1e;
    --fg: #e8e8e8;
    --fg-muted: #a0a0a0;
    --border: #3a3a3a;
    --accent: #6699ff;
    --accent-hover: #88aaff;
    --accent-fg: #111111;
    --success: #44bb44;
    --error: #ff6666;
    --warning: #ddaa33;
  }
}

/* Manual theme override classes */
html.light {
  --bg: #ffffff;
  --bg-alt: #f4f4f4;
  --fg: #111111;
  --fg-muted: #555555;
  --border: #d0d0d0;
  --accent: #0055dd;
  --accent-hover: #0044aa;
  --accent-fg: #ffffff;
  --success: #007700;
  --error: #cc0000;
  --warning: #886600;
}

html.dark {
  --bg: #111111;
  --bg-alt: #1e1e1e;
  --fg: #e8e8e8;
  --fg-muted: #a0a0a0;
  --border: #3a3a3a;
  --accent: #6699ff;
  --accent-hover: #88aaff;
  --accent-fg: #111111;
  --success: #44bb44;
  --error: #ff6666;
  --warning: #ddaa33;
}

/* Base */
html {
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: var(--line-height);
  background: var(--bg);
  color: var(--fg);
}

body {
  margin: 0;
  padding: 2rem;
  min-height: 100vh;
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 1rem 0;
}

h1 { font-size: 1.4rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 1rem 0; }

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

a:hover {
  text-decoration: underline;
}

ul {
  margin: 0;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Navigation */
nav {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav a {
  color: var(--fg-muted);
}

nav a:hover {
  color: var(--fg);
}

.controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.controls button {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
}

.controls button:hover {
  background: var(--border);
}

.controls button.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* Fullscreen/wide mode */
html.fullscreen .container {
  max-width: 100%;
}

html.fullscreen body {
  padding: 1rem;
}

@media (min-width: 1200px) {
  html.fullscreen body {
    padding: 1rem 2rem;
  }
}

/* Main content */
main {
  margin-bottom: 2rem;
}

/* Landing page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-header h1 {
  margin: 0;
}

/* Footer */
footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.875rem;
}

/* Forms */
textarea,
input[type="text"],
input[type="number"],
input[type="file"],
select {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.75rem;
  width: 100%;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

::placeholder {
  color: var(--fg-muted);
  opacity: 0.7;
}

label {
  display: block;
  margin-bottom: 0.375rem;
  color: var(--fg-muted);
  font-size: 0.875rem;
}

/* Buttons */
button {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.1s ease;
}

button:hover {
  background: var(--accent-hover);
}

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

button kbd {
  color: inherit;
  opacity: 0.7;
  font-size: 0.75rem;
}

/* Layout utilities */
.tool-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.col {
  flex: 1;
  min-width: 240px;
}

/* Status classes - semantic colors */
.muted {
  color: var(--fg-muted);
}

.success {
  color: var(--success);
}

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

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

/* Button group (toggle/tabs) */
.button-group {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
}

.button-group button {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--fg);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.button-group button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.button-group button:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.button-group button.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* Options row (checkboxes/settings) */
.options {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.875rem;
}

.options label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  color: var(--fg);
  margin: 0;
}

/* Row with top margin */
.row-spaced {
  margin-top: 1rem;
}

/* Drop zone */
.drop-zone {
  min-height: 120px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  cursor: pointer;
  transition: border-color 0.15s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 0.75rem;
  }

  html.fullscreen body {
    padding: 0.5rem;
  }

  .col {
    min-width: 100%;
  }

  .page-header,
  nav {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  nav .controls,
  .page-header .controls {
    order: 1;
    width: auto;
    justify-content: flex-end;
  }

  nav .controls button,
  .page-header .controls button {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  h1 {
    font-size: 1.2rem;
  }

  textarea {
    min-height: 150px;
  }

  .row {
    gap: 0.5rem;
  }
}
