/* ===================================================================
   Interview Coach — Mobile-First Styles
   =================================================================== */

/* --- CSS Variables (extend existing design tokens) --- */
:root {
  --coach-max-width: 640px;
  --coach-min-tap: 44px;
  --coach-safe-bottom: env(safe-area-inset-bottom, 0px);
  --coach-radius: 12px;
}

/* --- Body override for full-height mobile layout --- */
.coach-body {
  background: #0d1321;
  color: #e8e8e8;
  font-family: Lato, system-ui, sans-serif;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
}

/* --- Main container --- */
.coach {
  max-width: var(--coach-max-width);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* --- Header --- */
.coach__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
  flex-shrink: 0;
}

.coach__back {
  color: #C9A84C;
  text-decoration: none;
  font-size: 0.95rem;
  min-height: var(--coach-min-tap);
  display: flex;
  align-items: center;
}

.coach__save-btn {
  background: none;
  border: 1px solid #C9A84C;
  color: #C9A84C;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: var(--coach-min-tap);
}

.coach__save-btn:focus-visible {
  outline: 2px solid #C9A84C;
  outline-offset: 2px;
}

/* --- Screen area --- */
.coach__screen {
  flex: 1;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}

/* --- Screen cards --- */
.coach-card {
  background: #1a2744;
  border-radius: var(--coach-radius);
  padding: 24px 20px;
  margin-bottom: 16px;
}

.coach-card__title {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  color: #C9A84C;
  margin: 0 0 12px 0;
}

.coach-card__text {
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 12px 0;
  color: #ccc;
}

/* --- Polish text (question / answer display) --- */
.coach-polish {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 8px 0;
  line-height: 1.5;
}

/* --- Buttons --- */
.coach__btn {
  min-height: var(--coach-min-tap);
  min-width: var(--coach-min-tap);
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.coach__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.coach__btn--primary {
  background: #DC143C;
  color: #fff;
}

.coach__btn--primary:active {
  background: #A50E2D;
}

.coach__btn--secondary {
  background: #263660;
  color: #C9A84C;
  border: 1px solid #C9A84C;
}

.coach__btn--ghost {
  background: transparent;
  color: #C9A84C;
  text-decoration: underline;
}

/* Sticky bottom action */
.coach__actions {
  position: sticky;
  bottom: 0;
  background: #0d1321;
  padding: 12px 16px calc(12px + var(--coach-safe-bottom));
  margin: 0 -16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.coach__actions--row {
  flex-direction: row;
  justify-content: stretch;
}

.coach__actions--row .coach__btn {
  flex: 1;
}

.coach-control-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px -16px -12px;
  padding: 12px 16px calc(12px + var(--coach-safe-bottom));
  background: #0d1321;
}

.coach-control-bar .coach__btn {
  flex: 1 1 140px;
}

.coach-speed-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 4px;
}

.coach-speed-toggle .coach__btn {
  width: 100%;
}

.coach-speed-toggle .coach__btn.is-selected {
  background: #C9A84C;
  color: #152440;
  box-shadow: 0 0 18px rgba(201, 168, 76, 0.25);
}

.coach-guided-card {
  overflow: hidden;
  background:
    radial-gradient(circle at 100% 0%, rgba(201, 168, 76, 0.1), transparent 240px),
    #1a2744;
}

.coach-step-label,
.coach-panel-label {
  margin: 0 0 8px;
  color: #C9A84C;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.coach-step-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coach-step-label::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #C9A84C;
  box-shadow: 0 0 12px rgba(201, 168, 76, 0.8);
  content: "";
}

.coach-question-stage,
.coach-sentence-stage {
  position: relative;
  overflow: hidden;
  margin: 18px 0;
  padding: 20px;
  border: 1px solid rgba(201, 168, 76, 0.24);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(38, 54, 96, 0.95), rgba(20, 35, 63, 0.95));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
}

.coach-question-stage::after,
.coach-sentence-stage::after {
  position: absolute;
  right: -44px;
  bottom: -66px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(201, 168, 76, 0.12);
  border-radius: 50%;
  content: "";
}

.coach-question-stage .coach-polish,
.coach-sentence-stage .coach-polish {
  position: relative;
  z-index: 1;
  margin: 0;
}

.coach-sound-cue {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  margin-top: 12px;
}

.coach-sound-cue span {
  width: 3px;
  height: 7px;
  border-radius: 3px;
  background: #C9A84C;
}

.coach-question-stage.is-playing .coach-sound-cue span {
  animation: coach-sound-wave 0.7s ease-in-out infinite alternate;
}

.coach-question-stage.is-playing .coach-sound-cue span:nth-child(2) {
  animation-delay: 0.15s;
}

.coach-question-stage.is-playing .coach-sound-cue span:nth-child(3) {
  animation-delay: 0.3s;
}

.coach-teaching-reveal {
  animation: coach-reveal 0.35s ease both;
}

.coach-teaching-reveal[hidden] {
  display: none;
}

.coach-meaning-panel,
.coach-next-step {
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.coach-next-step {
  margin-top: 10px;
  border-left: 3px solid #C9A84C;
}

.coach-next-step .coach-card__text {
  margin-bottom: 0;
}

.coach-keyword-chip {
  display: inline-flex;
  margin: 4px 6px 0 0;
  padding: 7px 10px;
  border: 1px solid rgba(201, 168, 76, 0.34);
  border-radius: 999px;
  color: #e7c96f;
  font-size: 0.88rem;
}

.coach-sentence-stage {
  display: grid;
  min-height: 180px;
  place-content: center;
  text-align: center;
}

.coach-rehearsal-sentence {
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.coach-sentence-stage.is-playing .coach-rehearsal-sentence {
  animation: coach-speaking 1.4s ease-in-out infinite;
}

.coach-hidden-answer-cue {
  position: relative;
  z-index: 1;
  margin: 8px 0 0;
  color: #aeb7cb;
  font-size: 0.95rem;
}

@keyframes coach-sound-wave {
  to { height: 19px; }
}

@keyframes coach-reveal {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes coach-speaking {
  50% {
    transform: translateY(-7px) scale(1.025);
    text-shadow: 0 0 24px rgba(201, 168, 76, 0.35);
  }
}

.coach-answer-options {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
}

.coach-answer-option {
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-radius: 10px;
  padding: 12px;
  margin: 0 0 12px;
}

.coach-answer-option__choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: var(--coach-min-tap);
  padding: 9px 10px;
  border-radius: 8px;
  background: #263660;
  color: #e8e8e8;
}

.coach-answer-option__choice input {
  margin-top: 4px;
}

.coach-answer-input {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--coach-min-tap);
  margin: 8px 0 4px;
  padding: 11px 12px;
  border: 1px solid rgba(201, 168, 76, 0.35);
  border-radius: 8px;
  background: #0d1321;
  color: #e8e8e8;
  font: inherit;
}

textarea.coach-answer-input {
  min-height: 96px;
  resize: vertical;
}

.coach-saved-suggestion {
  padding: 12px;
  margin: 6px 0 10px;
  border-left: 3px solid #C9A84C;
  border-radius: 0 8px 8px 0;
  background: rgba(201, 168, 76, 0.1);
}

.coach-saved-suggestion .coach__btn {
  margin: 4px 6px 0 0;
}

.coach-answer-level {
  padding: 12px;
  margin: 14px 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.coach-answer-level__label {
  margin: 0;
  color: #C9A84C;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.coach-chunk-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.coach-chunk-nav .coach__btn {
  width: 100%;
  min-width: 0;
  padding-inline: 8px;
}

.coach-recording-status {
  min-height: 24px;
  color: #C9A84C;
  font-weight: 700;
}

.coach-recording-playback {
  display: block;
  width: 100%;
  margin: 12px 0;
}

.coach-feedback-outcome,
.coach-feedback-fuller {
  padding: 14px;
  margin: 12px 0;
  border-radius: 10px;
}

.coach-feedback-outcome {
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid rgba(201, 168, 76, 0.3);
}

.coach-feedback-fuller {
  background: rgba(38, 54, 96, 0.8);
}

/* --- Hint display --- */
.coach-hint {
  background: rgba(201, 168, 76, 0.1);
  border-left: 3px solid #C9A84C;
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
  animation: coach-fade-in 0.3s ease;
}

.coach-hint__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #C9A84C;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

@keyframes coach-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Microphone button --- */
.coach-mic {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid #DC143C;
  background: #1a2744;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: background 0.2s, border-color 0.2s;
  margin: 16px auto;
}

.coach-mic--recording {
  background: #DC143C;
  border-color: #DC143C;
  animation: coach-pulse 1.5s infinite;
}

@keyframes coach-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 20, 60, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(220, 20, 60, 0); }
}

.coach-mic:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

/* --- Confidence buttons --- */
.coach-confidence {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.coach-confidence__btn {
  flex: 1;
  min-height: var(--coach-min-tap);
  background: #263660;
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 8px;
  color: #ccc;
  font-size: 0.9rem;
  cursor: pointer;
}

.coach-confidence__btn--selected {
  background: rgba(201, 168, 76, 0.15);
  border-color: #C9A84C;
  color: #C9A84C;
}

/* --- Onboarding choices --- */
.coach-choice-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.coach-choice {
  min-height: var(--coach-min-tap);
  padding: 12px 16px;
  background: #263660;
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 8px;
  color: #ccc;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}

.coach-choice--selected {
  background: rgba(201, 168, 76, 0.15);
  border-color: #C9A84C;
  color: #C9A84C;
}

/* --- Plan preview --- */
.coach-plan {
  background: linear-gradient(135deg, #1a2744 0%, #263660 100%);
  border-radius: var(--coach-radius);
  padding: 20px;
  margin: 16px 0;
}

.coach-plan__stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(201, 168, 76, 0.1);
}

.coach-plan__stat:last-child {
  border-bottom: none;
}

.coach-plan__label {
  color: #888;
  font-size: 0.9rem;
}

.coach-plan__value {
  color: #C9A84C;
  font-weight: 700;
  font-size: 0.9rem;
}

/* --- Paywall --- */
.coach-paywall {
  text-align: center;
  padding: 32px 20px;
}

.coach-paywall__icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

/* --- Profile prompt --- */
.coach-profile-prompt {
  margin: 8px 0;
}

.coach-profile-prompt__benefit {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 12px;
}

/* --- Dialog --- */
.coach-dialog {
  background: #1a2744;
  color: #e8e8e8;
  border: 1px solid #C9A84C;
  border-radius: var(--coach-radius);
  padding: 24px;
  max-width: 400px;
  width: 90vw;
}

.coach-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.coach-dialog input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(201, 168, 76, 0.3);
  background: #0d1321;
  color: #e8e8e8;
  font-size: 1rem;
  margin: 8px 0;
  box-sizing: border-box;
}

.coach-dialog input:focus {
  border-color: #C9A84C;
  outline: none;
}

/* --- Accessible screen-reader-only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .coach-hint,
  .coach-mic--recording {
    animation: none;
  }
}

/* --- 320px minimum --- */
@media (max-width: 320px) {
  .coach {
    padding: 0 8px;
  }

  .coach__actions {
    margin: 0 -8px;
    padding: 8px 8px calc(8px + var(--coach-safe-bottom));
  }
}

@media (max-width: 480px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .coach-card {
    padding: 20px 14px;
  }

  .coach-control-bar {
    flex-direction: column;
    align-items: stretch;
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .coach-control-bar .coach__btn {
    flex: 0 0 auto;
    width: 100%;
    min-height: 44px;
  }

  .coach-control-bar .coach__btn--primary {
    order: 20;
  }

  .coach-speed-toggle,
  .coach-answer-options {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .coach-answer-option__choice,
  .coach-answer-input {
    min-height: 44px;
  }

  .coach-chunk-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .coach-chunk-nav .coach__btn {
    min-height: 44px;
    font-size: 0.82rem;
  }
}
