/* =========================================================
   Sports Graphic Composer — editorial newsroom aesthetic
   Cream paper · ink black · single warm accent · serif display
   ========================================================= */

:root {
  --paper: #f3efe8;
  --paper-2: #ebe5db;
  --ink: #0d0c0a;
  --ink-2: #25221d;
  --rule: #1a1916;
  --muted: #6b6258;
  --hair: rgba(13, 12, 10, 0.12);
  --hair-strong: rgba(13, 12, 10, 0.28);
  --accent: #d9531e;   /* warm cinnabar — used VERY sparingly */
  --accent-ink: #fffaf2;
  --ok: #1f6b3a;
  --warn: #8a4a00;
  --err: #8a1f1f;

  --serif: "Fraunces", "Times New Roman", Georgia, serif;
  --sans: "Archivo", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* faint paper grain */
  background-image:
    radial-gradient(circle at 20% 10%, rgba(0,0,0,0.025) 0 1px, transparent 1.5px),
    radial-gradient(circle at 80% 70%, rgba(0,0,0,0.02) 0 1px, transparent 1.5px);
  background-size: 12px 12px, 18px 18px;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* =====  TOPBAR  ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar__mark {
  font-size: 24px;
  line-height: 1;
  color: var(--accent);
  transform: translateY(-1px);
}
.topbar__name {
  font-family: var(--serif);
  font-weight: 900;
  font-variation-settings: "opsz" 140;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.topbar__divider {
  width: 1px;
  height: 18px;
  background: var(--hair-strong);
}
.topbar__sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar__meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
@media (max-width: 640px) {
  .topbar__meta { display: none; }
}

/* =====  SHELL  ===== */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 0;
  max-width: 1480px;
  margin: 0 auto;
  min-height: calc(100dvh - 110px);
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
}
.panel {
  padding: 28px clamp(20px, 4vw, 40px);
  min-width: 0;
}
.panel--form {
  border-right: 1px solid var(--hair-strong);
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
}
@media (max-width: 960px) {
  .panel--form { border-right: 0; border-bottom: 1px solid var(--hair-strong); }
}
.panel--preview {
  background: var(--paper);
}

/* =====  STEP  ===== */
.step { margin-bottom: 28px; }
.step__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.step__num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.18em;
}
.step__title {
  font-family: var(--serif);
  font-weight: 700;
  font-variation-settings: "opsz" 60;
  font-size: 22px;
  letter-spacing: -0.005em;
}
.step__title small {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-left: 6px;
}

/* =====  TYPEAHEAD  ===== */
.typeahead { position: relative; }
.typeahead__input,
.textarea,
.refine__input {
  width: 100%;
  border: 1px solid var(--hair-strong);
  background: var(--paper);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.typeahead__input:focus,
.textarea:focus,
.refine__input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(13,12,10,0.08);
  background: #fff;
}
.typeahead__results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: 0 24px 64px -16px rgba(0,0,0,0.18), 0 2px 0 var(--ink);
}
.typeahead__results[hidden] { display: none; }
.typeahead__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair);
  background: transparent;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
}
.typeahead__row:last-child { border-bottom: 0; }
.typeahead__row:hover,
.typeahead__row:focus-visible {
  background: var(--paper-2);
}
.typeahead__row img {
  width: 28px; height: 28px; object-fit: contain;
  background: #fff; border-radius: var(--r-sm); padding: 2px;
  border: 1px solid var(--hair);
}
.typeahead__row .ta-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
}
.typeahead__row .ta-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1px;
}
.typeahead__loading,
.typeahead__empty {
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.team-selected {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-top: 10px;
  border: 1px solid var(--ink);
  border-radius: var(--r-md);
  background: #fff;
}
.team-selected__logo {
  width: 36px; height: 36px; object-fit: contain;
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm); padding: 2px;
}
.team-selected__body { flex: 1; min-width: 0; }
.team-selected__name {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 17px;
}
.team-selected__meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.team-selected__clear {
  background: none; border: 0; color: var(--muted);
  font-size: 16px; padding: 4px 8px;
  border-radius: var(--r-sm);
}
.team-selected__clear:hover { background: var(--paper-2); color: var(--ink); }

/* =====  TEXTAREA  ===== */
.textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
.textarea__count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  margin-top: 4px;
  letter-spacing: 0.1em;
}

/* =====  DROPZONE  ===== */
.dropzone {
  display: block;
  border: 1.5px dashed var(--hair-strong);
  border-radius: var(--r-md);
  padding: 22px 16px;
  text-align: center;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
  position: relative;
}
.dropzone:hover,
.dropzone.is-drag {
  background: #fff;
  border-color: var(--ink);
}
.dropzone__icon {
  font-size: 22px; color: var(--muted); margin-bottom: 6px;
}
.dropzone__text {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}
.dropzone__text em { font-style: normal; text-decoration: underline; text-underline-offset: 3px; }
.dropzone__preview {
  position: relative;
  margin-top: 12px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--hair-strong);
  max-height: 200px;
}
.dropzone__preview img { width: 100%; height: 100%; max-height: 200px; object-fit: cover; }
.dropzone__clear {
  position: absolute; top: 6px; right: 6px;
  background: rgba(13,12,10,0.85); color: #fff;
  border: 0; border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 14px; line-height: 1;
}

/* =====  RATIO TOGGLE  ===== */
.ratio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ratio__opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--hair-strong);
  padding: 12px 6px; border-radius: var(--r-md);
  transition: border-color 120ms ease, background 120ms ease;
  color: var(--ink);
}
.ratio__opt:hover { border-color: var(--ink-2); background: #fff; }
.ratio__opt.is-active {
  border-color: var(--ink); background: #fff;
  box-shadow: inset 0 0 0 1px var(--ink);
}
.ratio__icon { display: block; background: var(--ink); border-radius: 1px; }
.ratio__icon--sq { width: 22px; height: 22px; }
.ratio__icon--ls { width: 30px; height: 17px; }
.ratio__icon--vt { width: 14px; height: 25px; }
.ratio__lab {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  text-align: center; line-height: 1.2;
}
.ratio__lab small { display: block; color: var(--muted); font-size: 9px; margin-top: 2px; }

/* =====  BUTTONS  ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--sans); font-weight: 700;
  font-size: 14px; letter-spacing: 0.04em;
  padding: 14px 20px;
  border-radius: var(--r-md);
  border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper);
  transition: transform 80ms ease, background 120ms ease, color 120ms ease;
  text-transform: uppercase;
  min-height: 48px;
  width: 100%;
}
.btn:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn__arrow { font-size: 16px; }
.btn--primary { margin-top: 6px; }
.btn--ghost {
  background: transparent; color: var(--ink);
  border-color: var(--ink);
  width: auto;
  padding: 10px 16px; min-height: 40px;
}
.btn--ghost:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.btn--mini {
  width: auto; padding: 10px 16px; min-height: 44px;
  font-size: 12px;
}

.form-status {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  min-height: 18px;
}
.form-status.is-err { color: var(--err); }
.form-status.is-ok { color: var(--ok); }

/* =====  PREVIEW  ===== */
.preview {
  display: flex; flex-direction: column; gap: 16px;
}
.preview__frame {
  position: relative;
  background: #1a1916;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 12px);
  border: 1px solid var(--ink);
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 70dvh;
}
.preview__frame canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
.preview__empty,
.preview__loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  color: var(--paper);
  text-align: center;
  padding: 20px;
}
.preview__empty-icon { font-size: 36px; opacity: 0.5; }
.preview__empty-title {
  font-family: var(--serif); font-weight: 700; font-size: 20px;
}
.preview__empty-sub {
  font-family: var(--mono); font-size: 12px;
  color: rgba(243,239,232,0.6); letter-spacing: 0.06em;
}
.preview__loading {
  background: rgba(13,12,10,0.78); backdrop-filter: blur(2px);
}
.preview__loading-text {
  font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preview__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.preview__meta {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  letter-spacing: 0.06em;
}

/* =====  REFINE  ===== */
.refine {
  margin-top: 20px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-md);
}
.refine__head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--serif); font-weight: 700; font-size: 18px;
  margin-bottom: 10px;
}
.refine__dot { color: var(--accent); font-size: 12px; }
.refine__row {
  display: flex; gap: 8px;
}
.refine__row .refine__input { flex: 1; }
.refine__hint {
  margin-top: 8px;
  font-family: var(--mono); font-size: 11px;
  color: var(--muted); letter-spacing: 0.04em;
  min-height: 16px;
  line-height: 1.4;
}
.refine__hint.is-err { color: var(--err); }
.refine__hint.is-ok { color: var(--ok); }

@media (max-width: 520px) {
  .refine__row { flex-direction: column; }
  .refine__row .btn--mini { width: 100%; }
}

/* =====  FOOTER  ===== */
.footer {
  text-align: center;
  padding: 24px 16px 36px;
  font-family: var(--mono); font-size: 11px;
  color: var(--muted); letter-spacing: 0.08em;
}
.footer__sep { margin: 0 8px; opacity: 0.5; }
