/* =============================================================
   PITCHKIT — Sports Graphic Generator
   Editorial / sportsbook aesthetic. Heavy display type +
   high-contrast surfaces. Team color treated as accent only.
   ============================================================= */

:root {
  --bg-0: #0a0a0c;
  --bg-1: #111114;
  --bg-2: #1a1a20;
  --bg-3: #25252e;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --ink-0: #f6f6f7;
  --ink-1: #c8c8d0;
  --ink-2: #8a8a96;
  --ink-3: #5a5a66;

  --accent: #ff5b1f;       /* hot orange — used sparingly */
  --accent-2: #f7d046;     /* warm yellow — chips, dividers */
  --accent-glow: rgba(255, 91, 31, 0.4);

  --good: #4ade80;
  --warn: #facc15;
  --bad:  #ef4444;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 22px;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 16px 40px -16px rgba(0,0,0,0.6);
  --shadow-2: 0 24px 60px -24px rgba(0,0,0,0.7);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: 'Archivo', system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 91, 31, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(247, 208, 70, 0.10), transparent 60%),
    var(--bg-0);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.85em; color: var(--ink-1); }

/* =============== TOPBAR =============== */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  position: relative;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--bg-2), var(--bg-1));
}
.brand-dot {
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 18px var(--accent-glow);
}
.brand-dot-alt {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--accent-2);
  border-radius: 50%;
  bottom: 6px; right: 6px;
  box-shadow: 0 0 10px rgba(247, 208, 70, 0.4);
}

.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-family: 'Archivo Black', sans-serif;
  font-size: 18px;
  letter-spacing: 0.04em;
}
.brand-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-2);
  margin-top: 4px;
}

.topbar-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-2);
}
.meta-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
}
.meta-dot-live {
  background: var(--good);
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

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

/* =============== SHELL =============== */
.shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  padding: 28px 32px;
  max-width: 1480px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 980px) {
  .topbar { padding: 18px 18px; }
  .shell {
    grid-template-columns: 1fr;
    padding: 18px 14px;
    gap: 16px;
  }
}

/* =============== PANELS =============== */
.panel {
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-1);
}

.panel-controls { display: flex; flex-direction: column; gap: 18px; }

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
}
.panel-head-mid { margin-top: 6px; padding-top: 16px; border-top: 1px dashed var(--line); }

.step-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.panel-title {
  margin: 0;
  font-family: 'Archivo Black', sans-serif;
  font-size: 17px;
  letter-spacing: 0.01em;
}

/* =============== CONTROLS =============== */
.control { display: flex; flex-direction: column; gap: 8px; }

.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-2);
  display: flex; justify-content: space-between; align-items: baseline;
}
.control-hint {
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  font-size: 11px;
}

.text-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-0);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 91, 31, 0.15);
}
.text-input-area { resize: vertical; min-height: 64px; line-height: 1.45; }

.text-input::placeholder { color: var(--ink-3); }

/* ===== Typeahead ===== */
.typeahead { position: relative; }

.typeahead-status {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.typeahead-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  max-height: 280px;
  overflow-y: auto;
  position: absolute;
  width: 100%;
  z-index: 10;
  box-shadow: var(--shadow-2);
}

.typeahead-results li {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.typeahead-results li:hover,
.typeahead-results li.is-active {
  background: var(--bg-3);
}
.typeahead-results img {
  width: 28px; height: 28px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
}
.typeahead-result-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.typeahead-result-name { font-size: 14px; font-weight: 600; color: var(--ink-0); }
.typeahead-result-sub { font-size: 11px; color: var(--ink-2); margin-top: 2px; }

/* ===== Selected team chip ===== */
.team-selected {
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
}
.team-selected img {
  width: 36px; height: 36px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
}
.team-selected-meta { display: flex; flex-direction: column; flex: 1; line-height: 1.2; min-width: 0; }
.team-selected-name {
  font-family: 'Archivo Black', sans-serif;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.team-selected-sub { font-size: 11px; color: var(--ink-2); margin-top: 2px; }

.ghost-btn {
  background: transparent;
  color: var(--ink-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.ghost-btn:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--ink-0);
}
.ghost-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.ghost-btn-primary {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
}

/* ===== Dropzone ===== */
.dropzone {
  display: block;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-0);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}
.dropzone:hover, .dropzone.is-dragging {
  border-color: var(--accent);
  background: rgba(255, 91, 31, 0.04);
}
.dropzone.has-image {
  border-style: solid;
  border-color: var(--line-strong);
}
.dropzone-inner {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.dropzone-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2);
  border-radius: 50%;
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 4px;
}
.dropzone-text { font-size: 13px; color: var(--ink-1); }
.dropzone-sub { font-size: 11px; color: var(--ink-3); }

.dropzone-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.dropzone-preview img {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 8px;
}
.dropzone-preview-meta { display: flex; flex-direction: column; flex: 1; line-height: 1.2; min-width: 0; }
.dropzone-preview-name { font-size: 13px; color: var(--ink-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-preview-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ===== Aspect toggle ===== */
.aspect-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px;
}
.aspect-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.aspect-btn:hover { color: var(--ink-0); }
.aspect-btn.is-active {
  background: var(--bg-3);
  color: var(--ink-0);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.aspect-label {
  display: flex; flex-direction: column; gap: 2px; align-items: center; line-height: 1.1;
}
.aspect-label small {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.aspect-icon {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.aspect-icon-square { width: 20px; height: 20px; }
.aspect-icon-landscape { width: 24px; height: 14px; }
.aspect-icon-vertical { width: 14px; height: 24px; }

/* ===== Primary button ===== */
.primary-btn {
  margin-top: 4px;
  background: linear-gradient(180deg, #ff7a3f 0%, var(--accent) 100%);
  color: #1a0a00;
  border: none;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-family: 'Archivo Black', sans-serif;
  font-size: 15px;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.2) inset,
    0 -2px 0 rgba(0,0,0,0.15) inset,
    0 12px 32px -12px var(--accent-glow);
  transition: transform 0.1s, filter 0.15s;
}
.primary-btn:hover:not(:disabled) { filter: brightness(1.08); }
.primary-btn:active:not(:disabled) { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.primary-btn-arrow { font-size: 18px; }
.primary-btn-sm {
  padding: 12px 16px;
  font-size: 13px;
  width: auto;
}

.form-error {
  margin-top: 4px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #fda4a4;
  font-size: 13px;
}

/* =============== PREVIEW =============== */
.panel-preview { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.preview-status { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--ink-1);
  border: 1px solid var(--line-strong);
  white-space: nowrap;
}
.status-pill.is-busy { background: rgba(247, 208, 70, 0.15); color: var(--accent-2); border-color: rgba(247, 208, 70, 0.3); }
.status-pill.is-ok   { background: rgba(74, 222, 128, 0.12); color: var(--good); border-color: rgba(74, 222, 128, 0.3); }
.status-pill.is-err  { background: rgba(239, 68, 68, 0.12); color: #fda4a4; border-color: rgba(239, 68, 68, 0.3); }
.status-text {
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Canvas ===== */
.canvas-wrap {
  position: relative;
  background:
    repeating-conic-gradient(rgba(255,255,255,0.025) 0% 25%, transparent 0% 50%) 50% / 24px 24px,
    var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

#previewCanvas {
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  display: block;
  background: #000;
  border-radius: 4px;
  box-shadow: var(--shadow-2);
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-2);
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.canvas-empty-mark {
  font-size: 36px;
  color: var(--ink-3);
  margin-bottom: 8px;
  transform: rotate(45deg);
}
.canvas-empty p { margin: 0; font-size: 14px; }
.canvas-empty-sub { color: var(--ink-3); font-size: 12px !important; }

.canvas-loading {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ink-0);
  font-size: 13px;
  letter-spacing: 0.04em;
  z-index: 4;
}
.canvas-loading[hidden] { display: none; }
.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Refine ===== */
.refine { display: flex; flex-direction: column; gap: 10px; }
.refine-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
}
@media (max-width: 540px) {
  .refine-row { grid-template-columns: 1fr; }
}
.refine-helper {
  font-size: 12px;
  color: var(--ink-2);
  min-height: 16px;
}
.refine-helper.is-err { color: #fda4a4; }

/* =============== FOOTER =============== */
.footnote {
  position: relative;
  z-index: 2;
  text-align: center;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 24px 16px 40px;
}
