/* PT.fit Design Tokens — shared across all 22 screens */
/* Brand voice: "The Corner". Oxblood accent ≤10%. Fraunces headings only. Flat-by-default. */

/* === Cross-document page transitions (Chrome 111+, no-op elsewhere) === */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: 180ms;
  animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

:root {
  /* Color — cream surface, ink text, oxblood accent */
  --bg: #FDFAF8;
  --surface: #F0E9E1;
  --surface-2: #E8DFD3;
  --fg: #1A110C;
  --muted: #6B6358;
  --border: #E5DED3;
  --accent: #C54D2A;        /* oxblood */
  --accent-soft: #F3D5C8;
  --success: #2A7A4E;
  --warning: #A85C00;
  --error: #C22828;

  /* Recording / processing surfaces — only used in those states */
  --rec-bg: #14110F;
  --rec-fg: #F2EBE3;
  --rec-muted: #8A8378;
  --rec-accent: #C54D2A;

  /* Typography */
  --font-display: 'Fraunces', 'Iowan Old Style', 'Apple Garamond', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;

  /* Spacing — 4px base, 8px primary rhythm */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* Radius — flat by default */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.015em; }
h1 { font-size: 36px; line-height: 1.05; }
h2 { font-size: 24px; line-height: 1.15; }
h3 { font-size: 18px; line-height: 1.25; }

a { color: inherit; text-underline-offset: 3px; }

.index-back {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
  font-weight: 510;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.index-back:hover { background: var(--surface); }
.index-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* === Public web nav active state (audit fix #3) === */
.nav-links a.is-active { color: var(--accent); font-weight: 510; }
.nav-links a { text-decoration: none; }

/* === Breadcrumb current-page indicator (audit fix #7) === */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--fg); }
.breadcrumb [aria-current="page"] { color: var(--fg); font-weight: 510; }

/* === Confirm dialog (audit fix #13: AI Action Card discard) === */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(26, 17, 12, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.confirm-overlay[hidden] { display: none; }
/* Defensive: any element with hidden attribute should be hidden, even if CSS sets display */
[hidden] { display: none !important; }
.confirm-dialog {
  background: var(--bg);
  border-radius: 14px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(26, 17, 12, 0.3);
}
.confirm-dialog h3 {
  font-family: var(--font-display);
  font-weight: 500; font-size: 18px;
  margin-bottom: 8px;
}
.confirm-dialog p { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }
.confirm-dialog .actions { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-dialog .btn { padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 510; }
.confirm-dialog .btn.is-secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--border); }
.confirm-dialog .btn.is-danger { background: var(--error); color: #fff; }
@media (prefers-reduced-motion: reduce) { .confirm-overlay { transition: none; } }

/* === Voice-first: microphone as primary action === */
.mic-btn {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 0 var(--accent);
  transition: box-shadow 180ms ease, transform 120ms ease;
  font-size: 28px;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.mic-btn:active { transform: scale(0.97); }
.mic-btn.is-rec { animation: mic-pulse 1.2s ease-out infinite; background: var(--rec-bg); color: var(--rec-accent); }
.mic-btn-sm {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.mic-pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-weight: 510;
  letter-spacing: 0.01em;
  font-size: 14px;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(197, 77, 42, 0.55); }
  100% { box-shadow: 0 0 0 24px rgba(197, 77, 42, 0); }
}

/* === Recording state — dark surface === */
.is-recording { background: var(--rec-bg); color: var(--rec-fg); }
.is-recording h1, .is-recording h2 { color: var(--rec-fg); }

/* === Waveform animation === */
.waveform { display: inline-flex; align-items: center; gap: 4px; height: 56px; }
.waveform span {
  display: block; width: 4px; border-radius: 2px; background: var(--accent);
  animation: wave-bar 1.1s ease-in-out infinite;
}
.waveform.is-rec span { background: var(--rec-accent); }
.waveform span:nth-child(1) { height: 30%; animation-delay: -0.1s; }
.waveform span:nth-child(2) { height: 70%; animation-delay: -0.3s; }
.waveform span:nth-child(3) { height: 45%; animation-delay: -0.5s; }
.waveform span:nth-child(4) { height: 90%; animation-delay: -0.7s; }
.waveform span:nth-child(5) { height: 60%; animation-delay: -0.2s; }
.waveform span:nth-child(6) { height: 40%; animation-delay: -0.6s; }
.waveform span:nth-child(7) { height: 80%; animation-delay: -0.4s; }
.waveform span:nth-child(8) { height: 50%; animation-delay: -0.1s; }
.waveform span:nth-child(9) { height: 75%; animation-delay: -0.5s; }
.waveform span:nth-child(10) { height: 35%; animation-delay: -0.3s; }
.waveform span:nth-child(11) { height: 65%; animation-delay: -0.7s; }
.waveform span:nth-child(12) { height: 88%; animation-delay: -0.2s; }

@keyframes wave-bar {
  0%, 100% { transform: scaleY(0.4); }
  50%      { transform: scaleY(1.0); }
}

/* === Wireframe helpers === */
.ph-box {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; letter-spacing: 0.02em;
}
.ph-img {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  color: var(--muted); font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  min-height: 80px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
}
.card.is-tinted { background: var(--surface); }

.chip {
  display: inline-flex; align-items: center;
  padding: 2px var(--s-3);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--fg);
  font-size: 12px; font-weight: 510;
}
.chip.is-accent { background: var(--accent); color: #fff; }
.chip.is-warn   { background: var(--warning); color: #fff; }
.chip.is-success{ background: var(--success); color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-pill);
  background: var(--fg); color: var(--bg);
  font-weight: 510; letter-spacing: 0.01em;
  text-decoration: none;
}
.btn.is-secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--border); }
.btn.is-accent    { background: var(--accent); color: #fff; }
.btn.is-ghost     { background: transparent; color: var(--fg); }

/* === Toast notifications (NEW — UX analysis) === */
.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 510;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(26, 17, 12, 0.15);
  animation: toast-in 200ms ease-out, toast-out 200ms ease-in 2.8s forwards;
  max-width: 90%;
}
.toast .icon { color: var(--success); font-size: 16px; }
.toast .undo { color: var(--accent); font-size: 13px; font-weight: 510; }
@keyframes toast-in {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* === Empty state (NEW — UX analysis) === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-7) var(--s-4);
  text-align: center;
  min-height: 320px;
  gap: var(--s-3);
}
.empty-state .glyph {
  font-size: 48px;
  color: var(--muted);
  opacity: 0.4;
  margin-bottom: var(--s-2);
}
.empty-state .title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.empty-state .body {
  font-size: 14px;
  color: var(--muted);
  max-width: 280px;
  line-height: 1.5;
}
.empty-state .cta { margin-top: var(--s-3); }

/* === Error state (NEW — UX analysis) === */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--s-7) var(--s-4);
  text-align: center;
  min-height: 320px;
  gap: var(--s-3);
}
.error-state .icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--error);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: var(--s-3);
}
.error-state .title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--fg);
}
.error-state .body {
  font-size: 14px;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.5;
}
.error-state .actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

/* === Skeleton loader (NEW — UX analysis) === */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.full { width: 100%; }
.skeleton-card { height: 80px; margin-bottom: 12px; border-radius: var(--r-md); }

/* === Offline banner (NEW — UX analysis) === */
.offline-banner {
  background: var(--warning);
  color: #fff;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 510;
  text-align: center;
  letter-spacing: 0.02em;
}

/* === Permission denied (NEW — UX analysis) === */
.permission-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--s-6) var(--s-4);
  text-align: center;
  gap: var(--s-3);
}
.permission-denied .icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.permission-denied .body {
  font-size: 14px;
  color: var(--muted);
  max-width: 280px;
  line-height: 1.5;
}

/* === Voice-first composer (NEW — mic is PRIMARY) === */
.composer {
  padding: 12px 16px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.composer .mic-primary {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(197, 77, 42, 0.25);
  transition: transform 120ms ease, box-shadow 180ms ease;
}
.composer .mic-primary:active { transform: scale(0.96); }
.composer .text-input {
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--muted);
  background: var(--bg);
  text-align: center;
}
.composer .icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: none;
  cursor: pointer;
}

.row { display: flex; align-items: center; gap: var(--s-3); }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.stack > * + * { margin-top: var(--s-4); }
.stack-sm > * + * { margin-top: var(--s-2); }
.stack-lg > * + * { margin-top: var(--s-6); }

.divider { border-top: 1px solid var(--border); }

.label-xs { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 510; }

@media (prefers-reduced-motion: reduce) {
  .mic-btn.is-rec, .waveform span, .mic-btn { animation: none !important; }
  .mic-btn.is-rec { box-shadow: 0 0 0 6px var(--rec-accent); }
}
