/*
 * Confidence Coach — calm makeover (2026-05-26).
 *
 * Goals from the product anchor: calm, personal, authentic, uncluttered.
 * The hero AI presence visually mirrors the KouLi Coach modal voice mist:
 * bottom-origin glow, vertical mist columns, and playback-reactive energy.
 * Pills are kept but restyled toward a quieter glass aesthetic. The long
 * resources block is collapsed into a single subtle disclosure.
 */

/* Match the dark-shell pattern used by Home / Progress / Profile so the
   mist sits on the right background. */
html:has(body.confidence-coach-active) {
  background-color: #050507;
}

body.confidence-coach-active {
  background:
    radial-gradient(circle at 50% 28%, rgba(122, 153, 171, 0.3), rgba(74, 93, 110, 0.14) 30%, transparent 52%),
    linear-gradient(180deg, #08080c 0%, #060609 44%, #040407 100%);
  background-color: #050507;
  color: #fff;
}

body.confidence-coach-active #app-header {
  display: none;
}

body.confidence-coach-active #confidence-resources-page {
  padding: 0;
  min-height: calc(100vh - 78px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 14%);
  color: #fff;
}

/* While the redesigned shell is on screen, keep the legacy bright header /
   info / resources containers from peeking through anywhere outside our
   shell. */
body.confidence-coach-active #confidence-resources-page > :not(.cc-shell) {
  display: none !important;
}

/* ── Outer shell ────────────────────────────────────────────────────── */

.cc-shell {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px 96px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: #fff;
}

.cc-shell::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 72%);
}

/* ── Header ─────────────────────────────────────────────────────────── */

.cc-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
}

.cc-wordmark {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 0 22px rgba(255, 255, 255, 0.12);
}

.cc-topbar-back {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  flex: 0 0 auto;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.cc-topbar-back:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

.cc-header {
  text-align: left;
  margin-top: 6px;
}

.cc-title {
  margin: 0;
  font-size: clamp(1.9rem, 7.2vw, 2.6rem);
  line-height: 1.06;
  letter-spacing: -0.04em;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.96);
}

.cc-subtitle {
  margin: 10px 0 0;
  font-size: 0.98rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.7);
  max-width: 36ch;
}

/* ── Voice mist stage (same bottom-origin visual as KouLi Coach modal) ── */

.cc-mist-stage {
  position: relative;
  width: min(100%, 440px);
  height: clamp(260px, 44vh, 380px);
  margin: 4px auto -4px;
  isolation: isolate;
}

.cc-mist-stage .confidence-coach-animation {
  position: absolute;
  inset: 0;
  height: auto;
  min-height: 0;
  margin: 0;
  display: block;
  --voice-energy: 0.12;
}

.cc-mist-stage .kouli-coach-stage {
  width: 100%;
  min-height: 100%;
}

.cc-mist-stage:has(.cc-mist-pill:hover) .kouli-coach-stage {
  filter: saturate(1.14) brightness(1.04);
}

/* The two state stubs (pulse + breathing) are kept only so the existing
   confidence-coach JS keeps finding them by ID. They render nothing in
   the new layout. */
.cc-mist-stage .pulse-animation,
.cc-mist-stage .breathing-animation {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.cc-mist-stage .confidence-coach-animation.speaking .cc-mist-pill {
  text-shadow:
    0 0 22px rgba(255, 255, 255, 0.55),
    0 0 48px rgba(0, 196, 160, 0.6);
}

/* ── In-mist Start / End buttons ────────────────────────────────────── */

/* Shared pill geometry. Both buttons sit centred inside the mist and
   are mutually exclusive via the existing .hidden toggling that
   main.js does. We aggressively override the legacy bright teal /
   red gradient styles that live in index.html for these IDs. */
/* Shared pill geometry. Both buttons sit centred inside the mist.
   IMPORTANT: the legacy index.html rules for .start-coaching-btn /
   .stop-coaching-btn :hover apply transform: translateY(-2px) and a
   teal box-shadow. Because we use transform: translate(-50%, -50%)
   to centre, any hover transform would yank the button off-centre.
   We explicitly lock the transform on every interactive state and
   we don't transition transform at all — nothing moves when you
   hover, focus, or press. */
.cc-mist-stage .cc-mist-pill,
.cc-mist-stage .cc-mist-pill:hover,
.cc-mist-stage .cc-mist-pill:focus,
.cc-mist-stage .cc-mist-pill:focus-visible,
.cc-mist-stage .cc-mist-pill:active {
  transform: translate(-50%, -50%);
}

.cc-mist-stage .cc-mist-pill {
  position: absolute;
  left: 50%;
  top: 51%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  width: auto;
  max-width: calc(100% - 32px);
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);

  /* Cooldown wiring: when the button is visible (no .hidden) the
     0.32s delay on pointer-events keeps a freshly-appeared button
     non-clickable for a beat — see the .hidden variant below. We
     intentionally do NOT transition transform; it stays locked. */
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.32s ease, color 0.2s ease, border-color 0.2s ease,
              background-color 0.2s ease, box-shadow 0.2s ease,
              pointer-events 0s 0.32s;
}

/* While .hidden is on the button, override the global
   `.hidden { display: none }` and fade it out + lock it from
   pointer events immediately. We keep it in layout so the swap is
   smooth and the cooldown timing is stable. */
.cc-mist-stage .cc-mist-pill.hidden {
  display: inline-flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, pointer-events 0s 0s;
}

.cc-mist-stage .cc-mist-pill:focus-visible {
  outline: 3px solid rgba(0, 196, 160, 0.85);
  outline-offset: 4px;
}

.cc-mist-stage .cc-mist-pill svg {
  flex: 0 0 auto;
}

/* Idle invitation: "Talk to KouLi". White outline, white text — the
   one to gravitate toward. We override the legacy teal background +
   shadow that lives in index.html on .start-coaching-btn :hover. */
.cc-mist-stage .cc-mist-pill-start.start-coaching-btn,
.cc-mist-stage .cc-mist-pill-start.start-coaching-btn:hover,
.cc-mist-stage .cc-mist-pill-start.start-coaching-btn:focus,
.cc-mist-stage .cc-mist-pill-start.start-coaching-btn:active {
  background: rgba(8, 8, 18, 0.18);
  color: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 6px 24px rgba(8, 8, 18, 0.32);
}

.cc-mist-stage .cc-mist-pill-start.start-coaching-btn {
  font-size: 0.72rem;
  letter-spacing: 0.27em;
  text-shadow:
    0 0 18px rgba(255, 255, 255, 0.45),
    0 0 42px rgba(0, 196, 160, 0.55);
}

.cc-mist-stage .cc-mist-pill-start.start-coaching-btn:hover {
  background: rgba(8, 8, 18, 0.28);
  border-color: rgba(255, 255, 255, 0.85);
}

/* Active exit: "End session". Muted outline, dim text — distinctly
   quieter. Override legacy red gradient + shadow on
   .stop-coaching-btn :hover. */
.cc-mist-stage .cc-mist-pill-stop.stop-coaching-btn,
.cc-mist-stage .cc-mist-pill-stop.stop-coaching-btn:hover,
.cc-mist-stage .cc-mist-pill-stop.stop-coaching-btn:focus,
.cc-mist-stage .cc-mist-pill-stop.stop-coaching-btn:active {
  background: rgba(8, 8, 18, 0.36);
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    0 6px 24px rgba(8, 8, 18, 0.32);
  text-shadow: none;
}

.cc-mist-stage .cc-mist-pill-stop.stop-coaching-btn {
  font-size: 0.66rem;
  letter-spacing: 0.22em;
}

.cc-mist-stage .cc-mist-pill-stop.stop-coaching-btn svg {
  width: 9px;
  height: 9px;
  color: currentColor;
}

.cc-mist-stage .cc-mist-pill-stop.stop-coaching-btn:hover {
  background: rgba(8, 8, 18, 0.5);
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.45);
}

/* ── Suggestion pills (quieter, glass) ──────────────────────────────── */

/* Pulled tight under the mist. The old action-row is gone, so the
   negative margin just trims the parent's flex gap so the pills feel
   anchored to the mist. */
.cc-shell .coaching-suggestions {
  margin: -10px 0 0;
  padding: 14px 14px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.cc-shell .coaching-suggestions.hidden {
  display: none;
}

.cc-shell .suggestions-header {
  margin: 0 0 8px;
}

.cc-shell .suggestions-label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cc-shell .suggestion-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Reset the loud gradient pill style only inside the new shell — other
   modes (Podcast, Daily Challenge, Draft Zero…) keep their own styles.
   Every category (breathing / delivery / psychology / general) now
   looks identical: a quiet frosted-glass chip. No teal/purple/orange
   category accents — calm and uncluttered wins over visual coding. */
.cc-shell .suggestion-pill,
.cc-shell .suggestion-pill.breathing,
.cc-shell .suggestion-pill.delivery,
.cc-shell .suggestion-pill.psychology,
.cc-shell .suggestion-pill.general {
  background: rgba(255, 255, 255, 0.045);
  color: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  cursor: pointer;
  max-width: 100%;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
  box-shadow: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  animation: cc-pill-emerge 0.6s ease-out forwards;
  opacity: 0;
  transform: translateY(8px);
}

.cc-shell .suggestion-pill::before {
  content: none;
}

.cc-shell .suggestion-pill:hover,
.cc-shell .suggestion-pill:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
  outline: none;
  animation: cc-pill-emerge 0.6s ease-out forwards;
}

.cc-shell .suggestion-pill:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.06);
}

.cc-shell .suggestion-pill:nth-child(1) { animation-delay: 0.05s; }
.cc-shell .suggestion-pill:nth-child(2) { animation-delay: 0.18s; }
.cc-shell .suggestion-pill:nth-child(3) { animation-delay: 0.31s; }
.cc-shell .suggestion-pill:nth-child(4) { animation-delay: 0.44s; }
.cc-shell .suggestion-pill:nth-child(5) { animation-delay: 0.57s; }

@keyframes cc-pill-emerge {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── Meta row (headphones tip + how-this-works) ─────────────────────── */

.cc-meta {
  margin: 6px 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.58);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px 14px;
}

.cc-meta-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  color: rgba(184, 205, 216, 0.92);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(122, 153, 171, 0.45);
  text-underline-offset: 3px;
}

.cc-meta-link:hover {
  text-decoration-color: rgba(122, 153, 171, 0.9);
}

/* ── Collapsed resources ────────────────────────────────────────────── */

.cc-resources {
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.cc-resources[open] {
  background: rgba(255, 255, 255, 0.035);
}

.cc-resources-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease;
}

.cc-resources-summary::-webkit-details-marker {
  display: none;
}

.cc-resources-summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.cc-resources-hint {
  margin-left: auto;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.5);
}

.cc-resources-chevron {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.55);
  transition: transform 0.25s ease;
}

.cc-resources[open] .cc-resources-chevron {
  transform: rotate(180deg);
}

.cc-resources-body {
  padding: 4px 12px 18px;
}

/* ── Technique cards inside the collapsible (calm rewrite) ──────────── */

.cc-shell .confidence-grid.cc-techniques-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.cc-shell .confidence-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: none;
  color: rgba(255, 255, 255, 0.88);
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.cc-shell .confidence-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(122, 153, 171, 0.4);
  transform: none;
  box-shadow: none;
}

.cc-shell .confidence-card .card-header {
  margin-bottom: 0;
  gap: 12px;
}

.cc-shell .confidence-card .card-icon {
  display: none;
}

.cc-shell .confidence-card .card-title h3 {
  color: rgba(255, 255, 255, 0.96);
  font-size: 0.98rem;
  margin: 0 0 2px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.cc-shell .confidence-card .card-title p {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.84rem;
  margin: 0;
  line-height: 1.4;
}

.cc-shell .confidence-card .card-arrow {
  color: rgba(255, 255, 255, 0.45);
}

.cc-shell .confidence-card .card-preview {
  display: none;
}

.cc-shell .confidence-card .card-content {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.88rem;
  line-height: 1.55;
}

.cc-shell .confidence-card .card-content h4 {
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.92rem;
  margin: 12px 0 4px;
}

.cc-shell .confidence-card .card-content p,
.cc-shell .confidence-card .card-content li {
  color: rgba(255, 255, 255, 0.78);
}

.cc-shell .confidence-card .card-content ul {
  margin: 0;
  padding-left: 1.1rem;
}

.cc-shell .confidence-card .card-content .technique-tip {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(74, 93, 110, 0.2);
  border: 1px solid rgba(122, 153, 171, 0.28);
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.85);
}

.cc-shell .confidence-card .card-content .technique-tip strong {
  color: #fff;
}

.cc-shell .confidence-card .strategy-card,
.cc-shell .confidence-card .body-tip,
.cc-shell .confidence-card .building-step {
  margin-top: 10px;
}

.cc-shell .confidence-card .step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(74, 93, 110, 0.28);
  border: 1px solid rgba(122, 153, 171, 0.4);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  margin-right: 8px;
}

/* ── Mobile tightening ──────────────────────────────────────────────── */

@media (max-width: 380px) {
  .cc-shell {
    gap: 14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .cc-mist-stage {
    height: 230px;
  }

  .cc-title {
    font-size: 1.7rem;
  }
}

@media (min-width: 760px) {
  .cc-shell {
    padding-top: 24px;
  }
}

/* ── Tier 1: memory strip, audio HUD, handoff ─────────────────────── */

.cc-memory-strip {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 14px;
}

.cc-memory-strip.hidden {
  display: none;
}

.cc-memory-label {
  margin: 0 0 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mist, #7a99ab);
}

.cc-memory-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cc-memory-item {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--halo, #b8cdd8);
}

.cc-memory-item strong {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
}

.cc-handoff {
  margin-top: 4px;
}

.cc-handoff.hidden {
  display: none;
}

.cc-handoff-inner {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  padding: 16px 16px 14px;
}

.cc-handoff-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

.cc-handoff-note {
  margin: 0 0 14px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--halo, #b8cdd8);
}

.cc-handoff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.cc-handoff-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.cc-handoff-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.22);
}

.cc-handoff-btn.is-primary {
  border-color: rgba(0, 196, 160, 0.45);
  background: rgba(0, 196, 160, 0.12);
  color: var(--teal-glow, #00e5c0);
}

.cc-handoff-btn.is-primary:hover {
  background: rgba(0, 196, 160, 0.18);
  border-color: rgba(0, 229, 192, 0.55);
}

.cc-handoff-dismiss {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--mist, #7a99ab);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cc-handoff-dismiss:hover {
  color: var(--halo, #b8cdd8);
}

@media (prefers-reduced-motion: reduce) {
  .cc-shell .suggestion-pill,
  .cc-resources-chevron,
  .cc-mist-stage .cc-mist-pill {
    transition: none !important;
    animation: none !important;
  }
}
