/* Charlotte studio design system · namespace: .cw-*
 *
 * Brainstorm (.bs-*) and Verb Quest (.cq-*) were designed as whole surfaces and
 * ended up being the two sections that read as one product. This sheet extracts
 * the grammar they share so every other section can speak it instead of inventing
 * a local dialect out of `.card` and inline margins.
 *
 * The grammar, in one place:
 *   accent      every page sets --page-color; primitives tint from it, so a section
 *               keeps its identity without redefining structure
 *   surface     panels/cards sit on a card mix of --surface-2, never a raw gradient
 *   radius      hero 18, panel 22, card 20, control 12, pill for chips
 *   control     38px tall, weight 800, .82rem, lifts 2px on hover; .btn in
 *               style.css is the same control for sections not migrated yet
 *   motion      surfaces enter once on mount; controls respond on interaction
 *
 * Feature sheets own their section's composition and may tune these; they must not
 * re-state a primitive's own properties, which is what the CSS duplicate audit
 * enforces across the loaded cascade.
 */

/* ------------------------------------------------------------ motion tokens
 *
 * One timing vocabulary for every surface. Springs overshoot slightly, which is
 * what makes a press or a reveal feel physical rather than faded. Reduced motion
 * collapses the durations, so a component written against these tokens is quiet
 * without its own media query. --press-depth is the travel of a tactile button.
 */

:root {
  --motion-fast: 120ms;
  --motion-base: 220ms;
  --motion-slow: 420ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --press-depth: 4px;
  --reward: #ffcf5a;
  --reward-ink: #ffcf5a;
  --info: #57c7ff;
  --info-ink: #57c7ff;
  --on-brand: #052414;
  --on-danger: #2a0a0e;
  --on-reward: #3a2600;
  --on-violet: #1a0b3d;
}

:root[data-theme="light"] {
  --on-danger: #ffffff;
  --reward-ink: #94650a;
  --info-ink: #0d6b9e;
  --on-violet: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0ms;
    --motion-base: 0ms;
    --motion-slow: 0ms;
  }
}

.cw-scope {
  /* Fallback is the Brainstorm/Verb Quest violet: an un-toned page still lands
   * inside the design language rather than on the raw brand green. */
  --cw-accent: var(--page-color, #7c8cff);
  --cw-accent-soft: color-mix(in srgb, var(--cw-accent) 14%, transparent);
  --cw-accent-line: color-mix(in srgb, var(--cw-accent) 42%, var(--line));
  --cw-card: color-mix(in srgb, var(--surface-2) 94%, var(--text) 2%);
  --cw-card-2: color-mix(in srgb, var(--surface-3) 88%, transparent);
  --cw-radius-hero: 18px;
  --cw-radius-panel: 22px;
  --cw-radius-card: 20px;
  --cw-radius-control: 12px;
  --cw-gap: 16px;
  min-width: 0;
  color: var(--text);
}

.cw-scope * {
  box-sizing: border-box;
}

/* ------------------------------------------------------------------ motion */

@keyframes cw-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes cw-card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes cw-pop {
  0% { transform: scale(0.94); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* A section is one composition: it enters as a unit and its rows stagger inside. */
.cw-app {
  display: grid;
  gap: var(--cw-gap);
  animation: cw-enter 0.42s var(--ease) both;
}

.cw-stagger > * {
  animation: cw-card-in 0.42s var(--ease) both;
}

.cw-stagger > :nth-child(2) { animation-delay: 0.05s; }
.cw-stagger > :nth-child(3) { animation-delay: 0.1s; }
.cw-stagger > :nth-child(4) { animation-delay: 0.15s; }
.cw-stagger > :nth-child(5) { animation-delay: 0.2s; }
.cw-stagger > :nth-child(n + 6) { animation-delay: 0.25s; }

@media (prefers-reduced-motion: reduce) {
  .cw-app,
  .cw-stagger > * {
    animation: none;
  }
}

/* -------------------------------------------------------------------- hero */

.cw-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  position: relative;
  /* Not hidden: a select inside the hero opens its menu past the hero's own box,
   * and the rounded corners already clip the background without it. */
  overflow: visible;
  border: 1px solid color-mix(in srgb, var(--cw-accent) 18%, var(--line));
  border-radius: var(--cw-radius-hero);
  background: linear-gradient(110deg,
    color-mix(in srgb, var(--cw-accent) 8%, var(--cw-card)) 0%,
    var(--cw-card) 54%,
    color-mix(in srgb, var(--cw-accent) 4%, var(--cw-card)) 100%);
}

.cw-hero-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cw-hero-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--cw-accent) 32%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--cw-accent) 16%, var(--surface-3));
  color: var(--cw-accent);
  font-size: 0.95rem;
}

.cw-hero-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cw-hero-copy {
  min-width: 0;
}

.cw-hero-copy h2 {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 1.5vw, 1.45rem);
  letter-spacing: -0.03em;
}

.cw-hero-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.cw-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cw-kicker {
  display: block;
  color: var(--cw-accent);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ----------------------------------------------------------------- controls */

.cw-btn,
.cw-icon-btn {
  appearance: none;
  border: 1px solid transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.16s var(--ease), border-color 0.16s var(--ease),
    background 0.16s var(--ease), box-shadow 0.16s var(--ease), color 0.16s var(--ease);
}

.cw-btn {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--cw-radius-control);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.cw-icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--text-soft);
}

.cw-btn:hover:not(:disabled),
.cw-icon-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  text-decoration: none;
}

.cw-btn:active:not(:disabled),
.cw-icon-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

.cw-btn:disabled,
.cw-icon-btn:disabled,
.cw-btn[aria-disabled="true"] {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.cw-btn-primary {
  background: var(--cw-accent);
  color: #fff;
  box-shadow: 0 10px 22px -13px color-mix(in srgb, var(--cw-accent) 80%, transparent);
}

.cw-btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cw-accent) 88%, white);
  box-shadow: 0 14px 28px -13px color-mix(in srgb, var(--cw-accent) 95%, transparent);
}

.cw-btn-secondary {
  background: var(--surface-3);
  border-color: var(--line);
  color: var(--text);
}

.cw-btn-secondary:hover:not(:disabled) {
  border-color: var(--cw-accent-line);
}

.cw-btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-soft);
}

.cw-btn-ghost:hover:not(:disabled) {
  border-color: var(--cw-accent-line);
  background: var(--cw-accent-soft);
  color: var(--text);
}

.cw-btn-sm {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 0.74rem;
}

.cw-icon-btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 0.8rem;
}

.cw-icon-btn-accent {
  border-color: var(--cw-accent-line);
  background: var(--cw-accent-soft);
  color: var(--cw-accent);
}

.cw-btn:focus-visible,
.cw-icon-btn:focus-visible,
.cw-seg-btn:focus-visible,
.cw-field:focus-visible,
.cw-search:focus-within {
  border-color: var(--cw-accent);
  box-shadow: 0 0 0 3px var(--cw-accent-soft);
  outline: none;
}

/* segmented switch — the Verb Quest mode picker, generalized */

.cw-seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.cw-seg::-webkit-scrollbar {
  display: none;
}

.cw-seg-btn {
  appearance: none;
  min-height: 34px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease);
}

.cw-seg-btn:hover {
  color: var(--text);
  background: var(--surface-3);
}

.cw-seg-btn.is-active {
  border-color: color-mix(in srgb, var(--cw-accent) 38%, transparent);
  background: var(--cw-accent-soft);
  color: var(--text);
}

.cw-seg-btn .cw-seg-count {
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  font-size: 0.68rem;
  font-weight: 800;
}

.cw-seg-btn.is-active .cw-seg-count {
  background: color-mix(in srgb, var(--cw-accent) 24%, transparent);
  color: var(--cw-accent);
}

/* ------------------------------------------------------------------ inputs */

.cw-search {
  height: 38px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--cw-radius-control);
  background: var(--cw-card-2);
  color: var(--muted);
}

.cw-search > i {
  flex: 0 0 auto;
  font-size: 0.85rem;
}

.cw-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
}

.cw-search:focus-within > i {
  color: var(--cw-accent);
}

.cw-field {
  width: 100%;
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--text);
  font: 600 0.84rem/1.4 inherit;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

/* ------------------------------------------------------------------ panels */

.cw-panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--cw-radius-panel);
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
}

.cw-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.cw-panel-head h3 {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  letter-spacing: -0.02em;
}

.cw-panel-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.cw-panel-head-copy {
  min-width: 0;
}

.cw-card {
  min-width: 0;
  position: relative;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--cw-radius-card);
  background: var(--cw-card);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.cw-card-lift:hover {
  transform: translateY(-4px);
  border-color: var(--cw-accent-line);
  box-shadow: 0 18px 40px -30px color-mix(in srgb, var(--cw-accent) 80%, transparent);
}

.cw-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* --------------------------------------------------------------- stat strip */

/* -------------------------------------------------------------- chips, meta */

.cw-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--cw-card-2);
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.cw-chip-accent {
  border-color: var(--cw-accent-line);
  background: var(--cw-accent-soft);
  color: var(--cw-accent);
}

.cw-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.cw-meta {
  color: var(--muted-2);
  font-size: 0.7rem;
}

.cw-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}

.cw-toolbar-spacer {
  flex: 1 1 auto;
  min-width: 0;
}

.cw-divider {
  width: 1px;
  align-self: stretch;
  min-height: 24px;
  background: var(--line);
}

/* ------------------------------------------------------------ empty / state */

.cw-empty {
  grid-column: 1 / -1;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 28px 22px;
  text-align: center;
}

.cw-empty-art {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border: 1px dashed var(--cw-accent-line);
  border-radius: 50%;
  background: var(--cw-accent-soft);
  color: var(--cw-accent);
  font-size: 1.7rem;
}

.cw-empty h3 {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: 1.24rem;
}

.cw-empty p {
  margin: 6px 0 16px;
  max-width: 520px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* A section's first-run moment: orbiting art, a kicker, one line of why, and the
 * action that fills it. Brainstorm's library was the model. */
.cw-empty.is-rich {
  animation: cw-enter 0.42s var(--ease) both;
}

.cw-empty-art.is-orbit {
  position: relative;
}

.cw-empty-art.is-orbit > span {
  position: absolute;
  top: -6px;
  left: calc(50% - 6px);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cw-accent);
  transform-origin: 6px 48px;
  animation: cw-orbit 6s linear infinite;
}

.cw-empty-art.is-orbit > span:nth-of-type(2) {
  background: #55e69c;
  animation-delay: -2s;
}

.cw-empty-art.is-orbit > span:nth-of-type(3) {
  background: #f277a1;
  animation-delay: -4s;
}

.cw-empty-kicker {
  color: var(--cw-accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

.cw-empty-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.cw-empty-hint {
  appearance: none;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: 700 0.8rem var(--font-sans);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--line-strong);
  transition: transform 0.12s var(--ease), border-color 0.12s var(--ease);
}

.cw-empty-hint:hover {
  border-color: var(--cw-accent-line);
}

.cw-empty-hint:active {
  transform: translateY(2px);
  box-shadow: none;
}

@keyframes cw-orbit {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .cw-empty.is-rich,
  .cw-empty-art.is-orbit > span {
    animation: none;
  }
}

.cw-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 13px;
  border: 1px solid var(--cw-accent-line);
  border-radius: 13px;
  background: var(--cw-accent-soft);
  color: var(--text-soft);
  font-size: 0.79rem;
}

.cw-note > i {
  margin-top: 2px;
  color: var(--cw-accent);
}

.cw-note[hidden] {
  display: none;
}

/* -------------------------------------------------------------- scroll area */

.cw-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--cw-accent) 42%, var(--line)) transparent;
}

.cw-scroll::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.cw-scroll::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--cw-accent) 42%, var(--line));
  background-clip: content-box;
}

.cw-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* ------------------------------------------------------------------- dialog */

.cw-dialog-scrim {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  animation: cw-enter 0.18s var(--ease) both;
}

.cw-dialog-scrim[hidden] {
  display: none;
}

.cw-dialog {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  padding: 24px;
  position: relative;
  border: 1px solid color-mix(in srgb, var(--cw-accent) 28%, var(--line));
  border-radius: 26px;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}

.cw-dialog-close {
  position: absolute;
  inset-inline-end: 13px;
  top: 13px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--muted);
  cursor: pointer;
}

.cw-dialog-close:hover {
  color: var(--text);
}

.cw-dialog h3 {
  margin: 4px 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
}

/* ------------------------------------------------------------------- mobile */

@media (max-width: 900px) {
  .cw-scope {
    --cw-gap: 12px;
    --cw-radius-hero: 16px;
    --cw-radius-panel: 18px;
    --cw-radius-card: 16px;
  }

  .cw-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
  }

  .cw-hero-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .cw-hero-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 0.9rem;
  }

  .cw-panel {
    padding: 14px;
  }

  .cw-dialog {
    padding: 18px;
    border-radius: 20px;
  }
}
