/* Crux design system.
   Follows the Apple design principles: system type with size-specific tracking and leading,
   translucent materials for chrome, press feedback on pointer-down, springs for sheets,
   and full support for reduced motion, reduced transparency and increased contrast. */

:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #fbfbfd;
  --bg-alt: #f5f5f7;
  --elev: #ffffff;
  --fill: #f2f2f5;
  --fill-2: #e8e8ed;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #6e6e73;
  --hairline: rgba(0, 0, 0, 0.08);
  --hairline-2: rgba(0, 0, 0, 0.14);
  --field-border: #86868b;

  --accent: #0062c4;
  --accent-hover: #0068d1;
  --accent-fill: var(--accent); /* button and own-bubble fill: white text on it stays >= 4.5:1 */
  --accent-tint: rgba(0, 113, 227, 0.1);
  --on-accent: #ffffff;
  --green: #18702f;
  --green-tint: rgba(52, 199, 89, 0.16);
  --orange: #a84600;
  --orange-tint: rgba(255, 149, 0, 0.16);
  --red: #c4000f;
  --red-tint: rgba(255, 59, 48, 0.12);
  --purple: #7a3bd1;
  --purple-tint: rgba(175, 82, 222, 0.14);
  --teal: #006b82;
  --teal-tint: rgba(48, 176, 199, 0.16);

  --material: rgba(251, 251, 253, 0.72);
  --material-solid: #fbfbfd;
  --material-edge: rgba(255, 255, 255, 0.6);
  --scrim: rgba(0, 0, 0, 0.32);
  --bubble-them: #e9e9eb;
  --bubble-them-text: #1d1d1f;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(0, 0, 0, 0.05);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.05), 0 22px 60px rgba(0, 0, 0, 0.12);

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --pill: 980px;

  --max: 68rem;
  --narrow: 44rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --nav-h: 3.25rem;
  --focus: 0 0 0 4px rgba(0, 113, 227, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-alt: #0d0d0f;
    --elev: #1c1c1e;
    --fill: #1c1c1e;
    --fill-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #86868b;
    --hairline: rgba(255, 255, 255, 0.1);
    --hairline-2: rgba(255, 255, 255, 0.18);
    --field-border: #6e6e73;
    --seg-indicator: #6e6e73;
    --accent: #4da3ff;
    --accent-hover: #0068d1;
    --accent-fill: #0071e3;
    --accent-tint: rgba(41, 151, 255, 0.16);
    --green: #30d158;
    --green-tint: rgba(48, 209, 88, 0.16);
    --orange: #ff9f0a;
    --orange-tint: rgba(255, 159, 10, 0.16);
    --red: #ff6961;
    --red-tint: rgba(255, 69, 58, 0.16);
    --purple: #c77dff;
    --purple-tint: rgba(191, 90, 242, 0.18);
    --teal: #40c8e0;
    --teal-tint: rgba(64, 200, 224, 0.16);
    --material: rgba(22, 22, 23, 0.72);
    --material-solid: #161617;
    --material-edge: rgba(255, 255, 255, 0.08);
    --scrim: rgba(0, 0, 0, 0.55);
    --bubble-them: #26262a;
    --bubble-them-text: #f5f5f7;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.4), 0 22px 60px rgba(0, 0, 0, 0.55);
    --focus: 0 0 0 4px rgba(41, 151, 255, 0.45);
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 1rem); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  letter-spacing: -0.005em;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.15em; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: var(--accent-tint); }
[hidden] { display: none !important; }
.sr-only, .msg .who-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 200; padding: 0.6rem 1.1rem; border-radius: var(--pill); background: var(--elev); color: var(--text); font-weight: 500; box-shadow: var(--shadow-2); }
.skip-link:focus { top: 0.5rem; }

/* ---------- Type scale: tracking tightens and leading drops as size grows ---------- */

.display {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 1.15rem + 5.4vw, 4.75rem);
  line-height: 1.05;
  letter-spacing: -0.032em;
  font-weight: 700;
  margin: 0;
  text-wrap: balance;
}
.title-1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.35rem + 2.7vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.026em;
  font-weight: 700;
  margin: 0;
  text-wrap: balance;
}
.title-2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  line-height: 1.14;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0;
  text-wrap: balance;
}
.title-3 { font-size: 1.3125rem; line-height: 1.24; letter-spacing: -0.012em; font-weight: 600; margin: 0; }
.headline { font-size: 1.0625rem; line-height: 1.35; letter-spacing: -0.01em; font-weight: 600; margin: 0; }
.lead {
  font-size: clamp(1.1875rem, 1.05rem + 0.6vw, 1.5rem);
  line-height: 1.38;
  letter-spacing: -0.014em;
  color: var(--text-2);
  margin: 0;
  text-wrap: pretty;
}
.footnote { font-size: 0.8125rem; line-height: 1.4; letter-spacing: 0.004em; color: var(--text-2); }
.caption { font-size: 0.75rem; line-height: 1.35; letter-spacing: 0.012em; color: var(--text-3); }
.eyebrow { font-size: 0.9375rem; line-height: 1.3; letter-spacing: -0.004em; font-weight: 600; color: var(--orange); margin: 0 0 0.75rem; }
.muted { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
p { margin: 0 0 1em; text-wrap: pretty; }

/* ---------- Layout ---------- */

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-narrow { width: 100%; max-width: var(--narrow); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(4rem, 3rem + 5vw, 7.5rem); }
.section-alt { background: var(--bg-alt); }
.section-head { max-width: 42rem; margin: 0 auto clamp(2.5rem, 2rem + 2vw, 3.75rem); text-align: center; }
.section-head .lead { margin-top: 1rem; }
.stack > * + * { margin-top: var(--stack, 1rem); }
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.center { text-align: center; }
.grid { display: grid; gap: clamp(0.875rem, 0.6rem + 1vw, 1.25rem); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(16.5rem, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); }

/* ---------- Buttons: feedback on pointer-down ---------- */

.btn {
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 2.75rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: var(--pill);
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none !important;
  user-select: none;
  touch-action: manipulation;
  transition: transform 100ms ease-out, background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--accent-tint); color: var(--accent); }
.btn-quiet { background: var(--fill); color: var(--text); }
.btn-quiet:hover:not(:disabled) { background: var(--fill-2); }
.btn-plain { background: transparent; color: var(--accent); padding-inline: 0.5rem; }
.btn-plain:hover { text-decoration: underline !important; text-underline-offset: 0.15em; }
.btn-danger { background: var(--red-tint); color: var(--red); }
.btn-sm { min-height: 2rem; padding: 0 0.875rem; font-size: 0.875rem; font-weight: 500; letter-spacing: -0.004em; }
.btn-lg { min-height: 3.25rem; padding: 0 1.75rem; font-size: 1.125rem; }
.btn-block { width: 100%; }
.btn-icon { width: 2.75rem; padding: 0; }
.btn-icon.btn-sm { width: 2rem; }
.link-arrow { white-space: normal; text-align: center; line-height: 1.3; }
.link-arrow::after { content: " ›"; }

/* ---------- Navigation: translucent material with a scroll edge (no hard divider) ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  background: var(--material);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}
.nav::after {
  content: "";
  position: absolute;
  inset: 100% 0 auto;
  height: 14px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0));
  opacity: 0;
  transition: opacity 200ms ease;
}
.nav.is-scrolled::after { opacity: 1; }
.nav-inner { height: 100%; display: flex; align-items: center; gap: 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); font-weight: 650; font-size: 1.125rem; letter-spacing: -0.02em; text-decoration: none !important; }
.brand-mark { width: 1.625rem; height: 1.625rem; flex: none; }
.nav-links { display: flex; gap: 1.75rem; margin-left: 0.75rem; }
.nav-links a { color: var(--text-2); font-size: 0.875rem; letter-spacing: -0.004em; text-decoration: none; transition: color 160ms ease; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
@media (max-width: 760px) { .nav-links { display: none; } }

/* ---------- Tags ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  height: 1.5rem;
  padding: 0 0.625rem;
  border-radius: var(--pill);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--fill);
  color: var(--text-2);
  white-space: nowrap;
}
.tag-rca { background: var(--accent-tint); color: var(--accent); }
.tag-quick { background: var(--teal-tint); color: var(--teal); }
.tag-design { background: var(--purple-tint); color: var(--purple); }
.tag-strategy { background: var(--orange-tint); color: var(--orange); }
.tag-mixed { background: var(--green-tint); color: var(--green); }

/* ---------- Cards ---------- */

.card {
  position: relative;
  background: var(--elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: clamp(1.25rem, 1rem + 1vw, 1.75rem);
}
.card-flat { background: var(--fill); box-shadow: none; }
.card-press {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  text-align: left;
  border: 0;
  width: 100%;
  transition: transform 100ms ease-out, box-shadow 200ms ease;
}
.card-press:hover { box-shadow: var(--shadow-2); }
.card-press:active { transform: scale(0.985); }

.case-card { display: flex; flex-direction: column; gap: 0.75rem; min-height: 13rem; }
.case-card .meta { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.case-card h3 { margin: 0; }
.case-card .company { color: var(--text-2); font-size: 0.875rem; }
.case-card .teaser { color: var(--text-2); font-size: 0.9375rem; line-height: 1.45; margin: 0; }
.case-card .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; color: var(--text-3); font-size: 0.8125rem; }
.case-card .go { color: var(--accent); font-weight: 500; font-size: 0.9375rem; }

/* ---------- Segmented control (indicator moves on a spring) ---------- */

.segmented {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: var(--pill);
  background: var(--fill);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }

/* Industry chips: one scrollable row of toggle pills */
.chips { display: flex; gap: 0.5rem; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 0;
  height: 2rem;
  padding: 0 0.85rem;
  border-radius: var(--pill);
  background: var(--fill);
  color: var(--text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  transition: transform 100ms ease-out, background-color 150ms ease-out, color 150ms ease-out;
}
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.segmented button {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  padding: 0.4rem 0.95rem;
  border-radius: var(--pill);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  transition: color 160ms ease;
}
.segmented button[aria-pressed="true"] { color: var(--text); }
.segmented button:focus-visible { outline-offset: 0; } /* fits inside the 3px track padding, so overflow does not clip it */
.segmented .indicator {
  position: absolute;
  z-index: 0;
  top: 3px;
  left: 0;
  height: calc(100% - 6px);
  border-radius: var(--pill);
  background: var(--seg-indicator, var(--elev));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  will-change: transform, width;
}
/* Narrow screens: rows wrap instead of scrolling sideways (reflow at 320px); the selected pill is drawn on the button */
@media (max-width: 640px) {
  .chips, .segmented { flex-wrap: wrap; overflow-x: visible; }
  .segmented { border-radius: var(--r-md); }
  .segmented .indicator { display: none; }
  .segmented button[aria-pressed="true"] { background: var(--seg-indicator, var(--elev)); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
}

/* ---------- Forms ---------- */

.field { display: block; }
.field-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--text-2); margin-bottom: 0.375rem; }
.input {
  width: 100%;
  min-height: 2.875rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--field-border);
  background: var(--elev);
  font-size: 1.0625rem;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input:focus { border-color: var(--accent); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--red); }
.hint { font-size: 0.8125rem; margin-top: 0.4rem; color: var(--text-2); min-height: 1.1em; }
.hint.error { color: var(--red); }
.hint.ok { color: var(--green); }
.divider-text { display: flex; align-items: center; gap: 0.75rem; color: var(--text-3); font-size: 0.8125rem; margin: 1.25rem 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }

/* ---------- Sheet / dialog (driven by a spring in JS) ---------- */

.sheet-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: var(--gutter); }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; }
.sheet {
  position: relative;
  width: min(30rem, 100%);
  max-height: min(85vh, 46rem);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--elev);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  padding: 1.75rem;
  will-change: transform, opacity;
}
.sheet-wide { width: min(40rem, 100%); }
.sheet-grabber { display: none; }
.sheet-close { position: absolute; top: 0.875rem; right: 0.875rem; }
.sheet h2 { padding-right: 2rem; }
@media (max-width: 640px) {
  .sheet-root { align-items: flex-end; padding: 0; }
  .sheet {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 0.75rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  }
  .sheet-grabber {
    display: block;
    width: 2.25rem;
    height: 0.3125rem;
    border-radius: var(--pill);
    background: var(--fill-2);
    margin: 0 auto 1rem;
    touch-action: none;
  }
}

/* ---------- Toast (status/completion feedback) ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--nav-h) + 0.75rem);
  z-index: 120;
  transform: translate(-50%, -0.5rem);
  opacity: 0;
  padding: 0.65rem 1.1rem;
  border-radius: var(--pill);
  background: var(--material);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-2);
  font-size: 0.9375rem;
  font-weight: 500;
  pointer-events: none;
  transition: opacity 200ms ease, transform 300ms cubic-bezier(0.2, 0.9, 0.25, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Footer ---------- */

.footer { background: var(--bg-alt); color: var(--text-2); font-size: 0.8125rem; padding-block: 2.5rem 3rem; }
.footer a { color: var(--text-2); }
.footer a:hover { color: var(--text); }
.footer-row { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.footer-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.footer .fine { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--hairline); color: var(--text-3); }

/* ---------- Spinner (status) ---------- */

.spinner { width: 1.1em; height: 1.1em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: -0.15em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Accessibility preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .btn:active:not(:disabled), .card-press:active { transform: none; }
  .toast { transition: opacity 200ms ease; transform: translate(-50%, 0); }
  .spinner { animation-duration: 2.4s; }
}
@media (prefers-reduced-transparency: reduce) {
  .nav, .toast, .composer { background: var(--material-solid) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}
@media (prefers-contrast: more) {
  :root { --hairline: rgba(0, 0, 0, 0.35); --hairline-2: rgba(0, 0, 0, 0.55); --text-2: #3a3a3c; --text-3: #48484a; --material: var(--material-solid); }
  .card, .sheet { box-shadow: none; border: 1px solid var(--hairline-2); }
  .nav { border-bottom: 1px solid var(--hairline-2); }
  .tag { outline: 1px solid currentColor; }
}
@media (forced-colors: active) {
  /* backgrounds are dropped, so mark the selected filter without colour */
  .segmented button[aria-pressed="true"], .chip[aria-pressed="true"] { text-decoration: underline 2px; text-underline-offset: 0.25em; }
}

/* ---------- Typing indicator (status feedback while the interviewer replies) ---------- */

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 0.9rem;
  border-radius: 1.15rem;
  border-bottom-left-radius: 0.4rem;
  background: var(--bubble-them);
  align-self: flex-start;
}
.typing-bubble span { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--text-3); animation: typing 1.2s ease-in-out infinite; }
.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.35; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing-bubble span { animation: none; opacity: 0.6; } }

/* ---------- Legal and 404 pages ---------- */

.doc { padding-block: clamp(2.5rem, 2rem + 3vw, 4.5rem) 5rem; }
.doc h1 { margin-bottom: .5rem; }
.doc h2 { margin: 2.25rem 0 .6rem; }
.doc p, .doc li { color: var(--text); }
.doc ul { padding-left: 1.2rem; }
.doc li + li { margin-top: .35rem; }
.draft { margin: 1.25rem 0 0; padding: .9rem 1rem; border-radius: var(--r-sm); background: var(--orange-tint); font-size: .9375rem; }
