/* Comic Maker — base styles. Dark, playful, comic-forward. Mobile-first. */

:root {
  --bg:        #0f1226;
  --bg-2:      #14173100;
  --panel:     #1b1f42;
  --panel-2:   #232a55;
  --ink:       #f4f1e8;   /* comic-paper off-white */
  --muted:     #9aa2cf;
  --faint:     #6b73a6;
  --line:      rgba(255,255,255,0.10);
  --line-2:    rgba(255,255,255,0.18);
  --accent:    #ffd23f;   /* comic yellow — POW */
  --accent-ink:#1a1400;
  --pink:      #ff5c8a;
  --teal:      #4de3c1;
  --violet:    #a98bff;
  --danger:    #ff6b6b;
  --ok:        #4de3c1;
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px rgba(0,0,0,0.35);
  --panel-frame: 3px solid #0b0d1e;
  --maxw: 1120px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(169,139,255,0.16), transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, rgba(77,227,193,0.12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.45;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }

h1, h2, h3 {
  margin: 0 0 .4em;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-weight: 800;
}
h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); }
.cm-display {
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

/* ---------- layout ---------- */
.cm-container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.cm-row { display: flex; gap: 10px; align-items: center; }
.cm-wrap { flex-wrap: wrap; }
.cm-col { display: flex; flex-direction: column; }
.cm-grow { flex: 1 1 auto; min-width: 0; }
.cm-spacer { flex: 1 1 auto; }
.cm-muted { color: var(--muted); }
.cm-faint { color: var(--faint); }
.cm-small { font-size: 0.86rem; }
.cm-tiny  { font-size: 0.76rem; }
.cm-center { text-align: center; }

/* ---------- chrome ---------- */
.cm-appbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, rgba(15,18,38,0.96), rgba(15,18,38,0.82));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.cm-brand { display: flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: -0.02em; }
.cm-brand .mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); border: 2px solid #0b0d1e; font-size: 18px;
}
.cm-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.cm-tab {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 8px 12px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 0.92rem;
}
.cm-tab:hover { color: var(--ink); background: rgba(255,255,255,0.05); }
.cm-tab.active { color: var(--accent-ink); background: var(--accent); border-color: #0b0d1e; }

.cm-credits {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,210,63,0.12); border: 1px solid rgba(255,210,63,0.35);
  color: var(--accent); padding: 5px 10px; border-radius: 999px; font-weight: 800; font-size: 0.82rem;
}

/* ---------- cards / panels ---------- */
.cm-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cm-pad { padding: 18px; }
.cm-frame {
  /* the comic-panel look */
  border: var(--panel-frame);
  border-radius: 12px;
  background: #0b0d1e;
}

/* ---------- controls ---------- */
.cm-btn {
  --b: var(--panel-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--b); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 14px; font-weight: 800; cursor: pointer; font-size: 0.94rem;
  transition: transform .06s ease, filter .12s ease, background .12s ease;
}
.cm-btn:hover:not(:disabled) { filter: brightness(1.08); }
.cm-btn:active:not(:disabled) { transform: translateY(1px); }
.cm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cm-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: #0b0d1e; }
.cm-btn.pink    { background: var(--pink); color: #22030f; border-color: #0b0d1e; }
.cm-btn.ghost   { background: transparent; }
.cm-btn.danger  { background: rgba(255,107,107,0.14); color: var(--danger); border-color: rgba(255,107,107,0.4); }
.cm-btn.block   { width: 100%; }
.cm-btn.lg      { padding: 14px 20px; font-size: 1.05rem; border-radius: 12px; }

.cm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-2); background: rgba(255,255,255,0.04); color: var(--ink);
  padding: 8px 12px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 0.88rem;
  transition: background .12s ease, border-color .12s ease;
}
.cm-chip:hover { background: rgba(255,255,255,0.09); }
.cm-chip.on { background: var(--accent); color: var(--accent-ink); border-color: #0b0d1e; }
.cm-chip.locked { opacity: 0.7; }
.cm-chip.disabled { opacity: 0.45; cursor: not-allowed; }

.cm-input, .cm-textarea, .cm-select {
  width: 100%; background: #10132b; color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 11px 12px;
  font-size: 0.98rem; font-family: inherit; outline: none;
}
.cm-input:focus, .cm-textarea:focus, .cm-select:focus { border-color: var(--accent); }
.cm-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.cm-label { display: block; font-weight: 800; margin-bottom: 8px; font-size: 0.92rem; }
.cm-hint { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }

.cm-seg { display: inline-flex; padding: 4px; gap: 4px; background: #10132b; border: 1px solid var(--line-2); border-radius: 999px; }
.cm-seg button { border: none; background: transparent; color: var(--muted); font-weight: 800; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 0.9rem; }
.cm-seg button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- gallery ---------- */
.cm-gallery {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.cm-gcard {
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  transition: transform .1s ease, border-color .12s ease;
}
.cm-gcard:hover { transform: translateY(-2px); border-color: var(--line-2); }
.cm-gimg { display: block; width: 100%; height: auto; background: #0b0d1e; }
.cm-gmeta {
  padding: 8px 10px; font-size: 0.78rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cm-gtitle {
  padding: 8px 10px 0; font-weight: 800; font-size: 0.9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- modal ---------- */
.cm-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(6,7,18,0.72); backdrop-filter: blur(3px);
}
.cm-modal {
  width: 100%; max-width: 860px; max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column; cursor: default;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow);
}
.cm-modal.narrow { max-width: 440px; }

/* the wide-strip fit: image scales DOWN, action row never scrolls off */
.cm-stripwrap { overflow: auto; padding: 14px; }
.cm-stripimg {
  display: block; width: auto; height: auto; max-width: 100%;
  max-height: calc(100dvh - 220px); margin: 0 auto; object-fit: contain;
  border-radius: 10px; background: #0b0d1e; border: 2px solid #0b0d1e;
}
.cm-modal-actions { flex-shrink: 0; }

/* ---------- misc ---------- */
.cm-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; }
.cm-badge.pending { background: rgba(255,210,63,0.16); color: var(--accent); }
.cm-badge.approved { background: rgba(77,227,193,0.16); color: var(--teal); }
.cm-badge.rejected { background: rgba(255,107,107,0.16); color: var(--danger); }

.cm-note { border-left: 3px solid var(--accent); padding: 8px 12px; background: rgba(255,210,63,0.06); border-radius: 8px; color: var(--muted); font-size: 0.84rem; }
.cm-error { border-left: 3px solid var(--danger); padding: 10px 12px; background: rgba(255,107,107,0.08); border-radius: 8px; color: #ffbdbd; font-size: 0.9rem; }
.cm-ok { color: var(--ok); font-weight: 700; }

.cm-divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }

.cm-placeholder {
  display: grid; place-items: center; width: 100%; aspect-ratio: 3/1;
  background: repeating-linear-gradient(45deg, #12152e, #12152e 10px, #171b38 10px, #171b38 20px);
  color: var(--faint); font-weight: 800; border-radius: 10px;
}

/* per-panel dialogue readout */
.cm-panels { display: flex; flex-direction: column; gap: 8px; }
.cm-panelrow { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; background: rgba(255,255,255,0.03); border-radius: 8px; }
.cm-panelno { flex: 0 0 auto; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 0.8rem; border: 2px solid #0b0d1e; }
.cm-panelbody { min-width: 0; }
.cm-speak { font-weight: 800; }
.cm-cap { color: var(--muted); font-style: italic; }

/* loading spinner — EXEMPT from reduced-motion (a frozen spinner reads as hung) */
.cm-spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.25); border-top-color: var(--accent);
  animation: cm-rot 0.8s linear infinite; display: inline-block;
}
.cm-spin.lg { width: 34px; height: 34px; border-width: 4px; }
@keyframes cm-rot { to { transform: rotate(360deg); } }

.cm-toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 200;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2);
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 700; font-size: 0.9rem;
}

.cm-hero {
  display: grid; gap: 8px; padding: 8px 0 18px;
}

.cm-tierhead { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cm-price { font-size: 1.5rem; font-weight: 900; }

@media (max-width: 640px) {
  .cm-pad { padding: 14px; }
  .cm-gallery { grid-template-columns: repeat(auto-fill, minmax(46%, 1fr)); }
  .cm-nav { gap: 2px; }
  .cm-tab { padding: 7px 9px; font-size: 0.84rem; }
}

/* Respect reduced motion — collapse decorative motion, KEEP the spinner. */
@media (prefers-reduced-motion: reduce) {
  *:not(.cm-spin), *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cm-spin { animation-duration: 0.8s !important; animation-iteration-count: infinite !important; }
}
