/* ============================================================
   DRIVE // ARCHIVE TERMINAL
   Design language: a diegetic case-file / evidence terminal.
   Base is warm-cool graphite, not pure black. Labels behave like
   stamped document metadata. The two in-universe factions (SILAS
   / INMATE) carry their own accent, surfaced only where relevant.
   ============================================================ */

:root {
  /* --- surfaces --- */
  --bg: #0b0b0d;
  --bg-raised: #131316;
  --bg-inset: #0e0e10;
  --border: #2a2a2e;
  --border-soft: #1c1c20;

  /* --- text --- */
  --text: #ece9e2;
  --text-dim: #948f88;
  --text-faint: #55545a;

  /* --- utility accent (terminal brass, not the default terracotta) --- */
  --accent: #c9a45c;
  --accent-dim: #7c6a42;
  --good: #6fae7c;

  /* --- experience accents --- */
  --silas: #c1453a;
  --silas-soft: #e3b68c;
  --inmate: #5f72d9;
  --inmate-soft: #9fd8e8;

  /* --- type --- */
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius: 2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(193, 69, 58, 0.06), transparent 60%),
    radial-gradient(ellipse 900px 500px at 85% 110%, rgba(95, 114, 217, 0.07), transparent 60%);
  background-attachment: fixed;
}

::selection { background: var(--accent); color: #14120c; }

a, button, select { font-family: inherit; }

/* --- film grain overlay --- */
.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-soft);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.08em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin-top: 2px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.meta-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-dim);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.meta-dot.on {
  background: var(--good);
  box-shadow: 0 0 8px rgba(111, 174, 122, 0.6);
}

/* --- terminal grid --- */

.terminal {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  flex: 1;
}

@media (max-width: 860px) {
  .terminal { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
}

.panel-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

/* ============================================================
   CONTROLS PANEL
   ============================================================ */

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.select-wrap {
  position: relative;
  border: 1px solid var(--border);
  background: var(--bg-inset);
  border-radius: var(--radius);
  transition: border-color 0.2s ease;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--text-dim);
  border-bottom: 1px solid var(--text-dim);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select-wrap:focus-within { border-color: var(--accent); }

select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 34px 12px 14px;
  cursor: pointer;
}

select:focus { outline: none; }
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

select option { background: var(--bg-raised); color: var(--text); }

/* --- generate button --- */

.generate-btn {
  margin-top: 6px;
  width: 100%;
  background: var(--accent);
  color: #16130c;
  border: none;
  border-radius: var(--radius);
  padding: 16px 18px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 0 0 rgba(201, 164, 92, 0);
}

.generate-btn:hover { background: #d8b56b; }

.generate-btn:active { transform: scale(0.985); }

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

.generate-btn.working {
  background: var(--accent-dim);
  color: var(--text);
  cursor: progress;
}

.generate-btn-glyph {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.generate-btn.working .generate-btn-glyph {
  animation: pulseGlyph 1s ease-in-out infinite;
}

@keyframes pulseGlyph {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* --- status readout --- */

.status-readout {
  margin-top: 22px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.status-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  gap: 12px;
}

.status-key {
  color: var(--text-faint);
  letter-spacing: 0.1em;
}

.status-val {
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 190px;
}

.status-val.flash {
  animation: flashVal 0.5s ease;
}

@keyframes flashVal {
  0% { color: var(--accent); }
  100% { color: var(--text); }
}

.hint {
  margin-top: auto;
  padding-top: 18px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-faint);
}

/* ============================================================
   STAGE / PREVIEW PANEL
   ============================================================ */

.stage { align-items: stretch; }

.canvas-frame {
  position: relative;
  flex: 1;
  min-height: 360px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.canvas-frame canvas {
  width: 100%;
  height: auto;
  max-height: 640px;
  object-fit: contain;
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.canvas-frame canvas.visible {
  display: block;
  opacity: 1;
}

.bracket {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--border);
  opacity: 0.9;
  z-index: 2;
  pointer-events: none;
}

.bracket-tl { top: 10px; left: 10px; border-top: 1px solid var(--accent-dim); border-left: 1px solid var(--accent-dim); }
.bracket-tr { top: 10px; right: 10px; border-top: 1px solid var(--accent-dim); border-right: 1px solid var(--accent-dim); }
.bracket-bl { bottom: 10px; left: 10px; border-bottom: 1px solid var(--accent-dim); border-left: 1px solid var(--accent-dim); }
.bracket-br { bottom: 10px; right: 10px; border-bottom: 1px solid var(--accent-dim); border-right: 1px solid var(--accent-dim); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-align: center;
  padding: 20px;
}

.empty-state.hidden { display: none; }

.empty-glyph {
  font-size: 26px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.empty-sub {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: normal;
  color: var(--text-faint);
  max-width: 240px;
}

.download-btn {
  margin-top: 16px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.download-btn:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(201, 164, 92, 0.06);
}

.download-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

/* ============================================================
   FOOTER
   ============================================================ */

.app-footer {
  margin-top: 32px;
  display: flex;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  flex-wrap: wrap;
  text-align: center;
}

.footer-sep { opacity: 0.5; }

/* ============================================================
   REDUCED MOTION
   ============================================================ */

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