/*
 * Blind LLM Bridge — "Precision Optics"
 * An instrument for translating light into language.
 */

:root {
  /* Substrate */
  --paper: #fcfaf8;
  --surface: #f4f1ec;
  --surface-raised: #ede9e3;

  /* Ink */
  --ink: #1c1b18;
  --ink-dim: #6b6762;
  --ink-faint: #9e9992;

  /* Optics — primary lens blue */
  --lens: #1a5cd0;
  --lens-deep: #1347a8;
  --lens-pale: #eaf2fd;
  --lens-glow: rgba(26, 92, 208, 0.08);

  /* Signal — amber indicator light */
  --signal: #c2670a;
  --signal-pale: #fef8f0;

  /* Hairlines & dividers */
  --hairline: #e2ded6;
  --hairline-soft: #ede9e3;

  /* Feedback */
  --danger: #c9353b;
  --danger-pale: #fef5f5;
  --success: #2d8a4e;

  /* Scale */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --font-size: 14px;
  --font-size-sm: 13px;
  --font-size-xs: 11px;
  --radius: 8px;
  --radius-sm: 5px;
  --radius-full: 9999px;
  --spacing: 24px;
  --max-width: 600px;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  padding: var(--spacing);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body > * {
  width: 100%;
  max-width: var(--max-width);
}

.hidden {
  display: none !important;
}

/* ── Header ──────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--hairline);
}

.header-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 6px rgba(194, 103, 10, 0.35);
  flex-shrink: 0;
  animation: indicator-pulse 3s ease-in-out infinite;
}

@keyframes indicator-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .header-indicator {
    animation: none;
  }
}

.header-text {
  min-width: 0;
}

.header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.3;
}

.subtitle {
  font-size: var(--font-size-sm);
  color: var(--ink-dim);
  font-weight: 400;
  line-height: 1.4;
}

/* ── Drop Zone — The Lens ────────────────────────────── */

.drop-zone {
  position: relative;
  border: 2px dashed var(--hairline);
  border-radius: var(--radius);
  padding: 52px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s ease, background 0.3s ease;
  margin-bottom: var(--spacing);
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  overflow: hidden;
}

/*
 * Signature element: Lens coating shimmer.
 * A subtle iridescent reflection sweeps across the drop zone on hover,
 * evoking the anti-reflective coating on a precision optical lens.
 */
.drop-zone::after {
  content: '';
  position: absolute;
  inset: -50%;
  background: linear-gradient(
    135deg,
    transparent 40%,
    rgba(26, 92, 208, 0.03) 45%,
    rgba(194, 103, 10, 0.03) 50%,
    rgba(26, 92, 208, 0.03) 55%,
    transparent 60%
  );
  transform: translateX(-100%);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.drop-zone:hover::after,
.drop-zone.drag-over::after {
  transform: translateX(100%);
}

@media (prefers-reduced-motion: reduce) {
  .drop-zone::after {
    display: none;
  }
}

.drop-zone > * {
  position: relative;
  z-index: 1;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--lens);
  background: var(--lens-pale);
  border-style: solid;
}

.lens-icon {
  color: var(--ink-faint);
  margin-bottom: 16px;
  opacity: 0.55;
  transition: opacity 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

.drop-zone:hover .lens-icon,
.drop-zone.drag-over .lens-icon {
  opacity: 1;
  color: var(--lens);
  transform: scale(1.04);
}

@media (prefers-reduced-motion: reduce) {
  .drop-zone:hover .lens-icon,
  .drop-zone.drag-over .lens-icon {
    transform: none;
  }
}

.drop-zone-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.drop-zone-hint {
  font-size: var(--font-size-sm);
  color: var(--ink-dim);
  margin-bottom: 22px;
}

.drop-zone-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--hairline);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn-outline:hover {
  border-color: var(--lens);
  background: var(--lens-glow);
  color: var(--lens);
}

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

/* ── Image Preview State ─────────────────────────────── */

.drop-zone.has-image {
  padding: 10px;
  border-style: solid;
  border-color: var(--hairline);
  cursor: default;
  min-height: auto;
  background: transparent;
}

.drop-zone.has-image::after {
  display: none;
}

.drop-zone.has-image:hover {
  border-color: var(--hairline);
  background: transparent;
}

#image-preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: 6px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(28, 27, 24, 0.72);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 16px;
  line-height: 28px;
  text-align: center;
  z-index: 2;
  transition: background 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(4px);
}

.remove-image:hover {
  background: var(--danger);
  transform: scale(1.1);
}

.remove-image:focus-visible {
  outline: 2px solid var(--lens);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .remove-image:hover {
    transform: none;
  }
}

/* ── Context Section ─────────────────────────────────── */

.context-section {
  margin-bottom: var(--spacing);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.section-label label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--ink);
}

.badge {
  font-size: var(--font-size-xs);
  color: var(--ink-dim);
  background: var(--surface-raised);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 76px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: var(--font-family);
  font-size: var(--font-size);
  line-height: 1.55;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea::placeholder {
  color: var(--ink-faint);
}

textarea:focus {
  border-color: var(--lens);
  box-shadow: 0 0 0 3px var(--lens-glow);
}

/* ── Send Section ────────────────────────────────────── */

.send-section {
  margin-bottom: var(--spacing);
  display: flex;
}

.btn-primary {
  background: var(--lens);
  color: #fff;
  border: none;
  padding: 10px 26px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--font-size);
  font-family: inherit;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--lens-deep);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(26, 92, 208, 0.22);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary:hover:not(:disabled) {
    transform: none;
  }
}

/* ── Loading ─────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--ink-dim);
  font-size: var(--font-size-sm);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--hairline-soft);
  border-top-color: var(--lens);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.5s;
  }
}

/* ── Response ────────────────────────────────────────── */

.response-section {
  margin-top: var(--spacing);
  border-top: 1px solid var(--hairline);
  padding-top: var(--spacing);
  animation: fade-up 0.35s ease;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .response-section {
    animation: none;
  }
}

.response-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.response-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.response-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--hairline);
  padding: 5px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-family: inherit;
  font-weight: 500;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn-action:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
  background: var(--surface);
}

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

#response-content {
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 18px 22px;
  font-size: var(--font-size);
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--ink);
}

/* ── Markdown rendered styles ────────────────────────── */

#response-content h1,
#response-content h2,
#response-content h3,
#response-content h4 {
  margin: 18px 0 8px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

#response-content h1 { font-size: 18px; }
#response-content h2 { font-size: 16px; }
#response-content h3 { font-size: 14px; }
#response-content h4 { font-size: 13px; }

#response-content p {
  margin: 8px 0;
}

#response-content ul,
#response-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

#response-content li {
  margin: 4px 0;
}

#response-content code {
  background: var(--surface-raised);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: var(--font-size-sm);
  font-family: var(--font-mono);
  color: var(--lens-deep);
}

#response-content pre {
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
  overflow-x: auto;
}

#response-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: var(--font-size-sm);
  color: var(--ink);
}

#response-content strong {
  font-weight: 600;
}

#response-content a {
  color: var(--lens);
  text-decoration: underline;
  text-underline-offset: 2px;
}

#response-content a:hover {
  color: var(--lens-deep);
}

#response-content blockquote {
  border-left: 3px solid var(--lens);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--ink-dim);
}

#response-content hr {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 16px 0;
}

/* ── Error ───────────────────────────────────────────── */

.error {
  color: var(--danger);
  padding: 10px 14px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  background: var(--danger-pale);
  border: 1px solid rgba(201, 53, 59, 0.16);
  border-radius: var(--radius);
  margin-bottom: var(--spacing);
}

/* ── VS Code integration ─────────────────────────────── */

.vscode-only {
  display: none;
}

body.vscode-mode .vscode-only {
  display: inline-block;
}

/* ── Focus ring (global) ─────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--lens);
  outline-offset: 2px;
}

/* ── Selection ───────────────────────────────────────── */

::selection {
  background: var(--lens-pale);
  color: var(--ink);
}
