/* ==========================================================================
   VoiceNX mockup — Home screen
   Three columns (30 / 40 / 30). All interaction is CSS-only: a hidden
   checkbox (#rec) is the "recording" state. Any <label for="rec"> toggles it.
   When checked: the button flips to Stop, the mic pulses, the waveform and
   timer run, transcript lines stream in on a schedule, then the score fills.
   Unchecking resets everything to idle.
   ========================================================================== */

@property --sec   { syntax: "<integer>"; inherits: false; initial-value: 0; }
@property --score { syntax: "<number>";  inherits: false; initial-value: 0; }

.main--fixed { overflow: hidden; }

.home {
  height: 100%;
  display: grid;
  grid-template-columns: 3fr 4fr 3fr;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-6);
}

.col { display: flex; flex-direction: column; gap: var(--s-5); min-height: 0; }

/* Panel header shared by the cards */
.panel__head { display: flex; gap: var(--s-3); align-items: flex-start; }
.panel__title { font-size: var(--fs-md); font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.panel__sub { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; line-height: 1.35; }
.panel__head .tile { width: 42px; height: 42px; border-radius: 12px; }
.panel__head .tile svg { width: 20px; height: 20px; }

/* ==========================================================================
   Column 1 — recorder
   ========================================================================== */

.rec-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rec-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  min-height: 0;
}

/* Mic orb with pulse rings */
.orb {
  position: relative;
  width: 168px; height: 168px;
  display: grid; place-items: center;
}
.orb__ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: var(--teal-soft);
  transition: background var(--t-base) var(--ease);
}
.orb__ring--2 { inset: 14px; background: rgba(20, 150, 138, .18); }
.orb__core {
  position: relative;
  width: 112px; height: 112px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #22b3a4, var(--teal) 55%, var(--teal-deep));
  color: #fff;
  box-shadow: 0 12px 28px -10px rgba(13, 111, 102, .6), 0 1px 0 rgba(255, 255, 255, .25) inset;
  transition: transform var(--t-base) var(--ease);
}
.orb__core svg { width: 44px; height: 44px; stroke: currentColor; }

.orb__label { font-weight: 700; font-size: var(--fs-base); text-align: center; }
.orb__label span { display: none; }
.orb__label .idle { display: inline; }

/* Toggle button: one label, two faces */
.rec-btn {
  width: 100%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.rec-btn .btn { width: 100%; height: 52px; font-size: var(--fs-md); pointer-events: none; }
.rec-btn .rec-btn__stop { display: none; }

/* Waveform: 28 bars, animated while recording */
.wave {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 56px;
}
.wave i {
  display: block;
  width: 5px; height: 10px;
  border-radius: 3px;
  background: var(--teal);
  opacity: .45;
  --h: 10px;
}
.wave i:nth-child(odd)  { --h: 18px; }
.wave i:nth-child(3n)   { --h: 28px; }
.wave i:nth-child(5n)   { --h: 40px; }
.wave i:nth-child(7n)   { --h: 22px; }
.wave i:nth-child(13n)  { --h: 46px; }
.wave i { height: calc(var(--h) * .35); }

.rec-status { text-align: center; }
.rec-status__text { font-size: var(--fs-sm); color: var(--ink-3); }
.rec-status__text span { display: none; }
.rec-status__text .idle { display: inline; }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-2);
  margin-top: 2px;
  counter-reset: sec var(--sec);
}
.timer::after { content: "00:" counter(sec, decimal-leading-zero); }

/* ---- Recording state ---- */
.app:has(#rec:checked) .rec-btn .rec-btn__start { display: none; }
.app:has(#rec:checked) .rec-btn .rec-btn__stop  { display: inline-flex; }

.app:has(#rec:checked) .orb__core { transform: scale(1.06); }
.app:has(#rec:checked) .orb__ring   { animation: pulse 2.2s var(--ease) infinite; }
.app:has(#rec:checked) .orb__ring--2 { animation-delay: .4s; }
@keyframes pulse {
  0%   { transform: scale(1);    opacity: 1; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

.app:has(#rec:checked) .orb__label span,
.app:has(#rec:checked) .rec-status__text span { display: none; }
.app:has(#rec:checked) .orb__label .live,
.app:has(#rec:checked) .rec-status__text .live { display: inline; }

.app:has(#rec:checked) .wave i {
  opacity: 1;
  animation: bar 1.1s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -0.09s);
}
@keyframes bar {
  from { height: calc(var(--h) * .35); }
  to   { height: var(--h); }
}

.app:has(#rec:checked) .timer { animation: tick 59s linear forwards; }
@keyframes tick { from { --sec: 0; } to { --sec: 59; } }

/* ==========================================================================
   Column 2 — live transcript + score
   ========================================================================== */

.transcript-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: var(--s-4);
}
.transcript-card .panel__head { align-items: center; }
.transcript-card .panel__head .grow { flex: 1; }

.transcript {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: var(--s-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;   /* newest at the bottom, auto-pinned */
  gap: var(--s-3);
  scrollbar-width: thin;
  position: relative;
  padding-top: var(--s-4);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px);
          mask-image: linear-gradient(to bottom, transparent, #000 28px);
}

.transcript__empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
  color: var(--ink-3);
  font-size: var(--fs-sm);
  padding: var(--s-6);
}
.transcript__empty .t-h3 { color: var(--ink-2); margin-bottom: 4px; }
.app:has(#rec:checked) .transcript__empty { display: none; }

/* Message rows collapse to zero height until their scheduled time */
.msg {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  flex: none;
}
.msg > div { min-height: 0; overflow: hidden; }
.msg__bubble {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.msg__meta { display: flex; align-items: center; gap: var(--s-2); margin-bottom: 4px; }
.msg__who { font-weight: 700; font-size: var(--fs-sm); }
.msg__time { font-size: var(--fs-xs); color: var(--ink-3); }

.msg--you .msg__bubble { background: #e8eef7; border-top-left-radius: 4px; }
.msg--va  .msg__bubble { background: var(--teal-soft); border-top-left-radius: 4px; }
.msg--va .msg__who { display: inline-flex; align-items: center; gap: 6px; color: var(--teal-ink); }
.msg__mark {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
}
.msg__mark svg { width: 10px; height: 10px; }

/* Typing indicator */
.msg--typing .msg__bubble { display: inline-flex; gap: 5px; padding: 12px 14px; }
.msg--typing .msg__bubble i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal-deep); opacity: .4;
}

.app:has(#rec:checked) .msg {
  animation: msgIn .55s var(--ease) both;
  animation-delay: var(--at, 0s);
}
@keyframes msgIn {
  0%   { grid-template-rows: 0fr; opacity: 0; transform: translateY(8px); }
  45%  { grid-template-rows: 1fr; opacity: 0; transform: translateY(8px); }
  100% { grid-template-rows: 1fr; opacity: 1; transform: none; }
}
/* typing bubble shows briefly, then collapses before the answer lands */
.app:has(#rec:checked) .msg--typing {
  animation: msgIn .4s var(--ease) both, msgOut .3s var(--ease) forwards;
  animation-delay: var(--at), var(--until);
}
@keyframes msgOut { to { grid-template-rows: 0fr; opacity: 0; } }
.app:has(#rec:checked) .msg--typing i { animation: blink 1s ease-in-out infinite; }
.app:has(#rec:checked) .msg--typing i:nth-child(2) { animation-delay: .15s; }
.app:has(#rec:checked) .msg--typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: 1; transform: translateY(-2px); } }

/* ---- Score ---- */
.score-card { flex: none; }
.score-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-6);
  align-items: center;
  margin-top: var(--s-4);
}

.score-ring {
  --size: 124px; --thick: 12px;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(closest-side, var(--white) calc(100% - var(--thick)), transparent calc(100% - var(--thick) + 1px)),
    conic-gradient(var(--moss) calc(var(--score) * 1%), rgba(17, 25, 54, .08) 0);
  counter-reset: score var(--score);
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
  color: var(--ink);
}
.score-ring::after { content: "–"; color: var(--ink-4); }
.app:has(#rec:checked) .score-ring { animation: fill 1.4s var(--ease) 13.2s both; }
.app:has(#rec:checked) .score-ring::after {
  content: counter(score) "%";
  color: var(--ink);
  animation: fadeIn .4s 13.2s both;
}
@keyframes fill   { from { --score: 0; } to { --score: 95; } }
@keyframes fadeIn { from { opacity: 0; } }

.checks { display: flex; flex-direction: column; gap: 10px; }
.check {
  display: flex; align-items: center; gap: 10px;
  font-size: var(--fs-sm); font-weight: 500;
  color: var(--ink-4);
}
.check i {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
  color: transparent;
}
.check i svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 3; }
.app:has(#rec:checked) .check { animation: checkOn .4s var(--ease) both; animation-delay: calc(13.4s + var(--n) * .18s); }
.app:has(#rec:checked) .check i { animation: checkIcon .4s var(--ease) both; animation-delay: calc(13.4s + var(--n) * .18s); }
@keyframes checkOn   { to { color: var(--ink-2); } }
@keyframes checkIcon { to { background: var(--moss); border-color: var(--moss); color: #fff; } }

.score-note { display: none; }

/* ==========================================================================
   Column 3 — offer, POS, training
   ========================================================================== */
.col--aside .card { padding: var(--s-4) var(--s-5); }
.col--aside .panel__head .tile { width: 40px; height: 40px; }
.col--aside .panel__title { font-size: var(--fs-base); }
.col--aside .panel__sub { font-size: var(--fs-xs); }
.tile--rose { background: var(--rose-soft); color: var(--rose); }

.offer-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.qr {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 200px;
  margin: var(--s-2) auto;
  background: url("../assets/qr-offer.svg") center / contain no-repeat;
}
.offer-note { padding: 10px 14px; font-size: var(--fs-xs); }
.offer-note b { font-size: var(--fs-sm); }

.action-card { flex: none; }
.action-card .btn { margin-top: var(--s-3); height: 46px; }

.btn--deep {
  background: linear-gradient(180deg, var(--teal-deep), #0b5d56);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 14px -8px rgba(13, 111, 102, .7);
}
.btn--deep:hover { background: #0b5d56; }
.btn__ext { margin-left: auto; opacity: .7; display: inline-flex; }
.btn__ext svg { width: 16px; height: 16px; }

/* ==========================================================================
   Top bar status pill reacts to recording
   ========================================================================== */
.status-pill .live { display: none; }
.app:has(#rec:checked) .status-pill .idle { display: none; }
.app:has(#rec:checked) .status-pill .live { display: inline; }
.app:has(#rec:checked) .status-pill { background: var(--rose-soft); color: #9b2a3f; }
.app:has(#rec:checked) .status-pill::before { background: var(--rose); animation: blink 1s infinite; }
