/* Bird Frit Pattern Generator - Main Styles */
/* Aesthetic: Architectural drafting tool — precise, utilitarian, refined */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Instrument+Sans:wght@400;500;600;700&display=swap');

/* --- Design Tokens --- */
:root {
  --font-display: 'Instrument Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --ink: #1a1e24;
  --ink-light: #3d4450;
  --ink-muted: #6b7280;
  --paper: #f4f3f0;
  --paper-warm: #eae8e3;
  --paper-cool: #e9ecf0;
  --surface: #ffffff;
  --border: #d1cfc9;
  --border-light: #e4e2dc;
  --accent: #2563b0;
  --accent-hover: #1d4f8a;
  --success: #1a7a4c;
  --success-bg: #e8f5ee;
  --danger: #b03025;
  --danger-bg: #fceae9;
  --warning-bg: #fef6e7;
  --warning-text: #92650a;

  --radius-sm: 3px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-display);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  line-height: 1.5;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 3px solid var(--accent);
}

.header-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title .rule {
  display: inline-block;
  width: 2px;
  height: 18px;
  background: var(--accent);
  margin: 0 4px;
}

.header-subtitle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 300;
  color: #8a919c;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* --- App Layout --- */
.app-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 58px);
}

/* --- Sidebar --- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* --- Section groups --- */
.control-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

/* --- Radio group (pattern type) --- */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.9rem;
  font-weight: 500;
}

.radio-option:hover {
  background: var(--paper-warm);
}

.radio-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.radio-option input[type="radio"]:checked {
  border-color: var(--accent);
}

.radio-option input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.radio-option input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Checkbox option --- */
.checkbox-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.9rem;
  font-weight: 500;
}

.checkbox-option:hover {
  background: var(--paper-warm);
}

.checkbox-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.checkbox-option input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.checkbox-option input[type="checkbox"]:checked::after {
  content: '\2713';
  position: absolute;
  top: -1px;
  left: 1px;
  font-size: 12px;
  color: white;
  font-weight: bold;
}

/* --- Inline radio group --- */
.radio-group-inline {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 2px;
}

.radio-option-sm {
  padding: 4px 8px;
  font-size: 0.82rem;
}

/* --- Slider controls --- */
.slider-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.slider-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-light);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.1s;
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.slider-row input[type="number"] {
  width: 72px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: right;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color 0.15s;
}

.slider-row input[type="number"]:focus {
  border-color: var(--accent);
}

.slider-unit {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  min-width: 16px;
}

/* --- Surface toggle --- */
.surface-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.surface-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: var(--paper);
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.surface-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.surface-btn.active {
  background: var(--accent);
  color: white;
}

.surface-btn:hover:not(.active) {
  background: var(--paper-warm);
}

.surface-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* --- Color picker --- */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-row input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  cursor: pointer;
  background: none;
}

.color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.color-hex {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* --- Divider --- */
.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 4px 0;
}

/* --- Results panel --- */
.results-panel {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tf-display {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.tf-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.tf-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1;
}

.tf-pass { color: var(--success); }
.tf-fail { color: var(--danger); }

.classification-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.badge-pass {
  background: var(--success-bg);
  color: var(--success);
}

.badge-fail {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-neutral {
  background: var(--paper-warm);
  color: var(--ink-muted);
}

.indicators {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
}

.indicator-icon {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  width: 18px;
  text-align: center;
}

.indicator-pass .indicator-icon { color: var(--success); }
.indicator-fail .indicator-icon { color: var(--danger); }
.indicator-pass .indicator-text { color: var(--ink-light); }
.indicator-fail .indicator-text { color: var(--danger); }

.coverage-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
}

.coverage-label {
  color: var(--ink-muted);
  font-weight: 500;
}

.coverage-value {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
}

/* --- Warnings --- */
#warnings {
  display: none;
}

.warning-item {
  padding: 7px 10px;
  background: var(--warning-bg);
  border-left: 3px solid #d4a017;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.78rem;
  color: var(--warning-text);
  margin-bottom: 4px;
  line-height: 1.4;
}

.warning-item:last-child {
  margin-bottom: 0;
}

/* --- Export buttons --- */
.export-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-export {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-light);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-export:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn-export:active {
  transform: scale(0.98);
}

.btn-export:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-export svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
  }

  .header {
    padding: 12px 16px;
  }

  .header-title {
    font-size: 1rem;
  }
}
