/*
 * Wave N — iOS native chrome (mocks 28–32)
 *
 * Strongly namespaced under .ios-shell so it cannot regress the existing
 * 27 desktop mocks. Reuses tokens from showcase.css; does NOT redefine
 * brand colours, :root, body[data-showcase], .card, .mock-chrome, .shell,
 * .container, or any pre-existing class.
 *
 * Frame: iPhone 15 (393 × 852 logical pixels — we use 390 × 844 as the
 * baseline because the Showcase tokens calibrate cleanly at 16px body).
 *
 * Honours iOS HIG basics: status-bar safe area, home-indicator safe area,
 * 44pt minimum tap targets, Large Title heading hierarchy, grouped lists
 * with inset margins, no hover-only interactions, no shadow-driven depth.
 */

/* =========================================================================
 * iOS device frame — sits in the centre of the page on a soft canvas
 * ========================================================================= */
.ios-canvas {
  min-height: calc(100vh - 48px); /* leaves room for the .mock-chrome strip */
  background:
    radial-gradient(60% 50% at 50% 30%,
      color-mix(in oklch, var(--color-brand) 6%, var(--color-bg)) 0%,
      var(--color-bg) 70%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-7) var(--space-5);
}

.ios-shell {
  /* Logical iPhone frame */
  width: 390px;
  min-height: 844px;
  background: var(--color-surface);
  border-radius: 44px;
  border: 1px solid var(--color-line);
  /* 0 1px 2px is at the showcase shadow ceiling — nothing deeper. */
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  position: relative;
  overflow: hidden;
  font-family: var(--font-sans); /* SF Pro fallback stack */
  color: var(--color-ink);
  display: flex;
  flex-direction: column;

  /* iOS safe areas — reserve, never paint into. */
  --ios-safe-top: 47px;     /* dynamic island region */
  --ios-safe-bottom: 34px;  /* home indicator region */
  --ios-tabbar: 83px;       /* tab bar incl. label + safe-bottom */
}

/* =========================================================================
 * Status bar (top of frame)
 * ========================================================================= */
.ios-statusbar {
  position: relative;
  height: var(--ios-safe-top);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: var(--weight-semi) 15px / 1 var(--font-sans);
  color: var(--color-ink);
  z-index: 5;
}
.ios-statusbar .time {
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  padding-top: 12px;
}
.ios-statusbar .island {
  position: absolute;
  left: 50%;
  top: 11px;
  transform: translateX(-50%);
  width: 120px;
  height: 36px;
  border-radius: 20px;
  background: #000;
}
.ios-statusbar .icons {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 12px;
  color: var(--color-ink);
}
.ios-statusbar .icons svg { display: block; }

/* =========================================================================
 * Navigation bar — title + optional leading/trailing buttons
 * ========================================================================= */
.ios-navbar {
  display: grid;
  grid-template-columns: 60px 1fr 60px;
  align-items: center;
  padding: 4px 8px 6px;
  min-height: 44px;
  position: relative;
}
.ios-navbar .nav-leading,
.ios-navbar .nav-trailing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: var(--weight-regular) 17px / 1 var(--font-sans);
  color: var(--color-accent);
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
  padding: 0 4px;
}
.ios-navbar .nav-leading { justify-content: flex-start; }
.ios-navbar .nav-trailing { justify-content: flex-end; }
.ios-navbar .nav-title {
  font: var(--weight-semi) 17px / 1 var(--font-sans);
  text-align: center;
  letter-spacing: -.01em;
  color: var(--color-ink);
}

/* Large Title — iOS pattern. Use ONLY at the top of a scroll view. */
.ios-largetitle {
  padding: 4px 20px 12px;
  font: var(--weight-bold) 34px / 1.05 var(--font-sans);
  letter-spacing: -.02em;
  color: var(--color-ink);
}

/* =========================================================================
 * Scroll body — main content area between navbar and tab bar
 * ========================================================================= */
.ios-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--ios-tabbar) + 8px);
  background: var(--color-bg);
  color: var(--color-ink);
}
.ios-content.with-statusbg {
  background: var(--color-surface);
}

/* Section header — small uppercase iOS list group label. */
.ios-section-header {
  padding: 16px 20px 8px;
  font: var(--weight-medium) 13px / 1.2 var(--font-sans);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-ink-muted);
}

/* =========================================================================
 * Grouped list — iOS inset list pattern.
 * Cards inset by 16px from the screen edge with 10px corner radius.
 * ========================================================================= */
.ios-list {
  margin: 0 16px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 12px;
  overflow: hidden;
}
.ios-list-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  min-height: 44px;
  text-decoration: none;
  color: var(--color-ink);
  position: relative;
}
.ios-list-row + .ios-list-row::before {
  content: "";
  position: absolute;
  left: 56px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--color-line);
}
.ios-list-row .leading {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--color-surface-muted);
  color: var(--color-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ios-list-row .leading.tone-warn { background: var(--color-warn-soft); color: var(--color-warn); }
.ios-list-row .leading.tone-ok { background: var(--color-ok-soft); color: var(--color-ok); }
.ios-list-row .leading.tone-alert { background: var(--color-alert-soft); color: var(--color-alert); }
.ios-list-row .leading.tone-brand { background: color-mix(in oklch, var(--color-brand) 10%, var(--color-surface)); color: var(--color-brand); }

.ios-list-row .body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ios-list-row .title {
  font: var(--weight-semi) 17px / 1.2 var(--font-sans);
  color: var(--color-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ios-list-row .subtitle {
  font: var(--weight-regular) 13px / 1.3 var(--font-sans);
  color: var(--color-ink-muted);
}
.ios-list-row .trailing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-ink-subtle);
  font: var(--weight-regular) 15px / 1 var(--font-sans);
}
.ios-list-row .chev { color: var(--color-ink-subtle); }

/* Status chip — pill on list rows or cards. */
.ios-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font: var(--weight-bold) 11px / 1 var(--font-sans);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ios-chip.draft  { background: var(--color-warn-soft); color: var(--color-warn); }
.ios-chip.review { background: color-mix(in oklch, var(--color-accent) 14%, var(--color-surface)); color: var(--color-accent); }
.ios-chip.sent   { background: var(--color-ok-soft); color: var(--color-ok); }
.ios-chip.alert  { background: var(--color-alert-soft); color: var(--color-alert); }
.ios-chip.brand  { background: color-mix(in oklch, var(--color-brand) 10%, var(--color-surface)); color: var(--color-brand); }

/* =========================================================================
 * Tab bar — bottom navigation (iOS standard 5 items max; we use 4)
 * ========================================================================= */
.ios-tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: color-mix(in oklch, var(--color-surface) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--color-line);
  padding-bottom: var(--ios-safe-bottom);
}
.ios-tabbar-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px 0;
}
.ios-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--color-ink-muted);
  font: var(--weight-medium) 10px / 1 var(--font-sans);
  min-height: 44px;
  cursor: pointer;
}
.ios-tab.active {
  color: var(--color-accent);
}
.ios-tab svg { display: block; }

.ios-home-indicator {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  border-radius: 999px;
  background: var(--color-ink);
  opacity: .85;
  pointer-events: none;
  z-index: 6;
}

/* =========================================================================
 * Sticky bottom action bar — fixed CTA above the tab bar (used on
 * letter result + case detail).
 * ========================================================================= */
.ios-action-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--ios-tabbar);
  padding: 12px 16px calc(8px + var(--ios-safe-bottom) - var(--ios-safe-bottom));
  background: color-mix(in oklch, var(--color-surface) 92%, transparent);
  border-top: 1px solid var(--color-line);
  display: flex;
  gap: 10px;
}
.ios-action-bar.no-tabbar {
  bottom: 0;
  padding-bottom: calc(12px + var(--ios-safe-bottom));
}

/* =========================================================================
 * Buttons
 * ========================================================================= */
.ios-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font: var(--weight-semi) 17px / 1 var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  transition: filter var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}
.ios-btn.primary {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}
.ios-btn.primary:hover { filter: brightness(1.05); }
.ios-btn.secondary {
  background: var(--color-surface-muted);
  color: var(--color-ink);
}
.ios-btn.tertiary {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid color-mix(in oklch, var(--color-accent) 30%, var(--color-line));
}
.ios-btn.danger {
  background: var(--color-alert);
  color: #fff;
}

/* =========================================================================
 * Hero card — voice mic, big iconographic CTA at top of dashboard.
 * ========================================================================= */
.ios-hero-card {
  margin: 0 16px 12px;
  padding: 24px 20px 28px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.ios-hero-card::before {
  content: "";
  position: absolute;
  inset: -10% 5% auto 5%;
  height: 75%;
  background: var(--gradient-halo);
  pointer-events: none;
  z-index: 0;
}
.ios-hero-card > * { position: relative; z-index: 1; }
.ios-hero-card .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: var(--weight-bold) 11px / 1 var(--font-sans);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-accent);
}
.ios-hero-card .mic {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--gradient-accent-soft);
  color: var(--color-accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  min-height: 44px;
}
.ios-hero-card .helper {
  font: var(--weight-semi) 17px / 1.3 var(--font-sans);
  color: var(--color-ink);
}
.ios-hero-card .sub {
  font: var(--weight-regular) 14px / 1.45 var(--font-sans);
  color: var(--color-ink-muted);
  margin: 0;
}

/* =========================================================================
 * Voice waveform — used on resolve intake. Calm 5-bar pseudo-EQ.
 * ========================================================================= */
.ios-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 60px;
}
.ios-waveform .bar {
  width: 6px;
  border-radius: 3px;
  background: var(--color-accent);
  opacity: .7;
}
@media (prefers-reduced-motion: no-preference) {
  .ios-waveform .bar { animation: ios-wave 1.1s var(--ease) infinite; }
  .ios-waveform .bar:nth-child(1) { animation-delay: 0ms; }
  .ios-waveform .bar:nth-child(2) { animation-delay: 90ms; }
  .ios-waveform .bar:nth-child(3) { animation-delay: 180ms; }
  .ios-waveform .bar:nth-child(4) { animation-delay: 270ms; }
  .ios-waveform .bar:nth-child(5) { animation-delay: 360ms; }
  .ios-waveform .bar:nth-child(6) { animation-delay: 450ms; }
  .ios-waveform .bar:nth-child(7) { animation-delay: 540ms; }
}
@keyframes ios-wave {
  0%, 100% { height: 12px; }
  50%      { height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .ios-waveform .bar { height: 28px; animation: none; }
}

/* =========================================================================
 * Transcribed bubble — chat-style speech log on resolve intake.
 * ========================================================================= */
.ios-bubble {
  margin: 6px 16px;
  padding: 10px 14px;
  border-radius: 18px;
  font: var(--weight-regular) 15px / 1.4 var(--font-sans);
  max-width: 80%;
  word-wrap: break-word;
}
.ios-bubble.user {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  margin-left: auto;
  border-bottom-right-radius: 6px;
}
.ios-bubble.assistant {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  color: var(--color-ink);
  margin-right: auto;
  border-bottom-left-radius: 6px;
}

/* =========================================================================
 * Timeline (case detail, submission tracker) — vertical with you-are-here
 * pulse. Mirrors the desktop submission-tracker pattern but compact.
 * ========================================================================= */
.ios-timeline {
  margin: 0 16px;
  padding: 4px 0 4px 8px;
  position: relative;
}
.ios-timeline::before {
  content: "";
  position: absolute;
  left: 19px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: var(--color-line);
}
.ios-timeline-step {
  position: relative;
  padding: 8px 0 16px 36px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ios-timeline-step .marker {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ink-muted);
  z-index: 1;
}
.ios-timeline-step.done .marker {
  border-color: var(--color-ok);
  color: var(--color-ok);
  background: var(--color-ok-soft);
}
.ios-timeline-step.current .marker {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: color-mix(in oklch, var(--color-accent) 12%, var(--color-surface));
}
.ios-timeline-step.current .marker::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid color-mix(in oklch, var(--color-accent) 40%, transparent);
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .ios-timeline-step.current .marker::after {
    animation: ios-pulse 2.4s var(--ease) infinite;
  }
}
@keyframes ios-pulse {
  0%, 100% { opacity: .8; transform: scale(1); }
  50%      { opacity: 0;  transform: scale(1.5); }
}
.ios-timeline-step .step-title {
  font: var(--weight-semi) 15px / 1.3 var(--font-sans);
  color: var(--color-ink);
}
.ios-timeline-step .step-meta {
  font: var(--weight-regular) 13px / 1.3 var(--font-sans);
  color: var(--color-ink-muted);
}
.ios-timeline-step.pending .step-title { color: var(--color-ink-subtle); }

/* =========================================================================
 * Citation card — used on letter result. Mirrors the desktop pattern.
 * ========================================================================= */
.ios-citation {
  margin: 8px 16px;
  padding: 14px;
  background: var(--surface-depth-1);
  border: 1px solid var(--color-line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ios-citation .ref {
  font: var(--weight-bold) 11px / 1 var(--font-mono);
  letter-spacing: .04em;
  color: var(--color-brand);
  text-transform: uppercase;
}
.ios-citation .quote {
  font: var(--weight-regular) 14px / 1.45 var(--font-sans);
  color: var(--color-ink);
}

/* =========================================================================
 * Letter preview body — paper-look rendering of the draft letter.
 * ========================================================================= */
.ios-letter {
  margin: 8px 16px 16px;
  padding: 18px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 12px;
  font: var(--weight-regular) 14px / 1.55 var(--font-sans);
  color: var(--color-ink);
}
.ios-letter h4 {
  font: var(--weight-semi) 14px / 1.3 var(--font-sans);
  margin: 12px 0 4px;
}
.ios-letter p { margin: 6px 0; }
.ios-letter .meta {
  font: var(--weight-regular) 12px / 1.3 var(--font-mono);
  color: var(--color-ink-muted);
  margin-bottom: 10px;
}

/* =========================================================================
 * Reduced motion fallback — already mostly handled via class-level guards
 * in showcase.css. This stops the bottom-bar glassy shimmer for vestibular
 * sensitivity (no animation; just keep the translucent backdrop).
 * ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .ios-tabbar { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
