/* ───────────────────────────────────────────────────────────────────────
   Jane — for Brad   ·   CMA
   A calm, two-card page. Designed for legibility and ease (audience ~72,
   non-technical): large type, AAA contrast, generous space, gentle motion.
   ─────────────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --paper:      #F7F5F1;   /* warm near-white page background */
  --card:       #FFFFFF;   /* joke card surface */

  /* Ink — high contrast, near-black on near-white (WCAG AAA) */
  --ink:        #16191E;
  --ink-soft:   #44484E;   /* secondary text — still strong contrast */

  /* CMA navy — the single accent, used only on the Talk-to-Jane card */
  --navy:       #004B85;
  --navy-deep:  #00396A;
  --on-navy:    #FFFFFF;
  --on-navy-soft: #DCE6F0;

  /* CMA warm gold — the joke card's quiet identity (icon only) */
  --amber:      #DAA21B;
  --amber-deep: #9A6D0A;

  --line:       rgba(22, 25, 30, 0.14);
  --line-soft:  rgba(22, 25, 30, 0.08);

  --font: "Atkinson Hyperlegible", "Inter", system-ui, -apple-system,
          "Segoe UI", Roboto, sans-serif;

  --r-card:  24px;
  --r-inner: 14px;

  --shadow-rest:  0 14px 32px -22px rgba(22, 25, 30, 0.45);
  --shadow-navy:  0 20px 40px -20px rgba(0, 75, 133, 0.55);
  --shadow-lift:  0 26px 48px -20px rgba(22, 25, 30, 0.40);
  --shadow-navy-lift: 0 30px 56px -20px rgba(0, 75, 133, 0.62);
}

/* ─── Base ──────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 21px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.is-locked { overflow: hidden; }

button { font-family: inherit; }

.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;
}

/* ─── Page layout — one centered column, always ─────────────────────── */

.page {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(44px, 9vh, 104px) 24px clamp(48px, 9vh, 96px);
}

.column {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ─── Brand + greeting ──────────────────────────────────────────────── */

.brand {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}
.brand img {
  height: 62px;
  width: auto;
}

.greeting {
  margin: 0 0 10px;
  font-size: clamp(33px, 8.4vw, 42px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-align: center;
  color: var(--ink);
  text-wrap: balance;
}

.greeting-sub {
  margin: 0 0 40px;
  font-size: 20px;
  line-height: 1.5;
  text-align: center;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* ─── Cards ─────────────────────────────────────────────────────────── */

.cards {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* shared card button reset */
.card {
  display: block;
  width: 100%;
  margin: 0;
  border: 0;
  padding: 0;
  font-family: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--r-card);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.22s ease, box-shadow 0.22s ease,
              background-color 0.22s ease;
}
.card:focus-visible {
  outline: 4px solid var(--navy);
  outline-offset: 4px;
}

/* ── Card 1 — Talk to Jane (primary, navy, dominant) ── */

.card-jane {
  background: var(--navy);
  color: var(--on-navy);
  padding: 34px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow-navy);
}
.card-jane:focus-visible { outline-color: var(--amber); }

.card-jane .card-icon {
  background: rgba(255, 255, 255, 0.13);
  border: 1.5px solid rgba(255, 255, 255, 0.34);
  color: #FFFFFF;
}

.card-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.card-title {
  font-size: 31px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.card-sub {
  font-size: 19px;
  line-height: 1.4;
}
.card-jane .card-sub { color: var(--on-navy-soft); }

.card-arrow {
  margin-left: auto;
  flex: 0 0 auto;
  display: flex;
  color: var(--on-navy-soft);
  transition: transform 0.22s ease;
}

/* ── Card 2 — Joke of the Day (secondary, neutral, flips over) ── */

.card-joke {
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-rest);
  perspective: 1700px;
  overflow: hidden;
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 168px;                 /* set live by JS to the active face */
  transform-style: preserve-3d;
  transition: transform 0.62s cubic-bezier(0.4, 0.05, 0.2, 1),
              height 0.62s cubic-bezier(0.4, 0.05, 0.2, 1);
}
.card-joke.is-flipped .flip-inner { transform: rotateY(180deg); }

.flip-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 32px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip-back { transform: rotateY(180deg); }

/* resting / intro face — mirrors the Jane card's shape */
.joke-intro {
  display: flex;
  align-items: center;
  gap: 24px;
}
.joke-intro .card-icon {
  background: rgba(218, 162, 27, 0.14);
  border: 1.5px solid rgba(218, 162, 27, 0.45);
  color: var(--amber-deep);
}
.joke-sub { color: var(--ink-soft); }

/* the joke itself */
.joke-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.joke-eyebrow .joke-sun { color: var(--amber-deep); display: flex; }
.joke-text {
  margin: 0;
  font-size: 21px;
  line-height: 1.55;
  color: var(--ink);
  text-wrap: pretty;
}
.joke-hint {
  margin-top: 18px;
  font-size: 18px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.joke-hint svg { flex: 0 0 auto; }

/* ── shared big card icon ── */
.card-icon {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-icon svg { width: 34px; height: 34px; }

/* a slow, calm "ready" breath on the Jane card icon */
.card-jane .card-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  animation: breathe 3.6s ease-out infinite;
}

/* hover / active feedback (pointer devices only) */
@media (hover: hover) {
  .card-jane:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-navy-lift);
  }
  .card-jane:hover .card-arrow { transform: translateX(5px); }
  .card-joke:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lift);
  }
}
.card-jane:active { transform: translateY(-1px) scale(0.995); background: var(--navy-deep); }
.card-joke:active { transform: translateY(-1px) scale(0.995); }

/* ─── Footer — a single quiet line ──────────────────────────────────── */

.foot {
  margin-top: 38px;
  text-align: center;
  font-size: 16px;
  color: var(--ink-soft);
}

/* ─── Voice modal — talking with Jane ───────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(22, 25, 30, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.24s ease;
}

.dialog {
  width: 100%;
  max-width: 520px;
  max-height: 92svh;
  background: var(--paper);
  border-radius: 26px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 90px -30px rgba(22, 25, 30, 0.65);
  animation: rise 0.34s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.dialog:focus { outline: none; }

.dialog-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1.5px solid var(--line-soft);
}
.jane-mark {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--navy);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jane-mark svg { width: 28px; height: 28px; }
.dialog-name { font-size: 23px; font-weight: 700; line-height: 1.2; }
.dialog-status { font-size: 18px; color: var(--ink-soft); line-height: 1.3; }

.dialog-body {
  flex: 1;
  min-height: 220px;
  overflow-y: auto;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dialog-empty {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  color: var(--ink-soft);
  padding: 20px 0;
}
.dialog-empty p { margin: 0; font-size: 19px; max-width: 320px; }

.pulse {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  position: relative;
  background: radial-gradient(circle, rgba(0,75,133,0.18), transparent 68%);
}
.pulse::before,
.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--navy);
  opacity: 0;
  animation: ripple 2.6s ease-out infinite;
}
.pulse::after { animation-delay: 1.3s; }
.pulse[data-state="speaking"]::before,
.pulse[data-state="speaking"]::after { border-color: var(--amber-deep); }

/* transcript bubbles */
.msg {
  max-width: 86%;
  padding: 13px 17px;
  border-radius: 16px;
  font-size: 19px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.msg-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 3px;
  opacity: 0.72;
}
.msg-jane {
  align-self: flex-start;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--ink);
}
.msg-you {
  align-self: flex-end;
  background: var(--navy);
  color: var(--on-navy);
}

.dialog-error {
  margin: auto;
  text-align: center;
  color: var(--ink);
  background: rgba(218, 162, 27, 0.12);
  border: 1.5px solid rgba(218, 162, 27, 0.45);
  border-radius: var(--r-inner);
  padding: 16px 18px;
  font-size: 18px;
  line-height: 1.5;
}

.dialog-foot {
  border-top: 1.5px solid var(--line-soft);
  padding: 16px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.type-row { display: flex; gap: 10px; }
.field {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 19px;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--r-inner);
  padding: 13px 16px;
}
.field::placeholder { color: var(--ink-soft); }
.field:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 1px;
  border-color: var(--navy);
}
.field:disabled { opacity: 0.55; }

.send-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-inner);
  background: var(--card);
  color: var(--navy);
  cursor: pointer;
  transition: background-color 0.18s ease;
}
.send-btn svg { width: 24px; height: 24px; }
.send-btn:disabled { opacity: 0.45; cursor: default; }
@media (hover: hover) {
  .send-btn:not(:disabled):hover { background: #EEF2F6; }
}

.done-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 17px 20px;
  font-size: 21px;
  font-weight: 700;
  color: var(--on-navy);
  background: var(--navy);
  border: 0;
  border-radius: var(--r-inner);
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.18s ease;
}
.done-btn svg { width: 22px; height: 22px; }
@media (hover: hover) {
  .done-btn:hover { background: var(--navy-deep); }
}
.done-btn:active { transform: scale(0.99); }

/* focus rings inside the dialog */
.send-btn:focus-visible,
.done-btn:focus-visible {
  outline: 4px solid var(--amber);
  outline-offset: 3px;
}

/* ─── Animations ────────────────────────────────────────────────────── */

@keyframes breathe {
  0%   { transform: scale(1);    opacity: 0.55; }
  70%  { transform: scale(1.28); opacity: 0;    }
  100% { transform: scale(1.28); opacity: 0;    }
}
@keyframes ripple {
  0%   { transform: scale(0.55); opacity: 0.85; }
  100% { transform: scale(1.5);  opacity: 0;    }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* ─── Calm motion — honour reduced-motion preference ────────────────── */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .flip-inner { transition: none; }
}

/* ─── Small screens ─────────────────────────────────────────────────── */

@media (max-width: 560px) {
  body { font-size: 20px; }
  .page { padding-left: 22px; padding-right: 22px; }
  .card-jane { padding: 28px 24px; gap: 18px; }
  .flip-face { padding: 28px 24px; }
  .joke-intro { gap: 18px; }
  .card-icon { width: 60px; height: 60px; }
  .card-icon svg { width: 28px; height: 28px; }
  .card-title { font-size: 27px; }
  .card-arrow { display: none; }
  .brand img { height: 56px; }
  .dialog-head { padding: 18px 20px; }
  .dialog-body { padding: 20px; }
  .dialog-foot { padding: 14px 20px 20px; }
}
