/* ---- R3: the project cards and voice updates (pm-cards.js, pm-r3-voice.js, docs/r3.md).
   Cameron's "Alter Ego Deck": a grid of tall gradient cards, label + number on top, a big bold title,
   a one-line subtitle. Each card's gradient comes from its division's Map colour, deepened so white
   text reads on it in light and dark (like the poster tiles). Quiet Glass everywhere else: ink
   buttons, 44 px taps, 52 px primary buttons, bottom sheets on a phone. Loaded after quiet-glass.css. */

/* ---- the switch at the top: Cards · Board ---- */
.r3-switch { display: inline-flex; gap: 4px; margin: 0 0 14px; padding: 4px; border-radius: 999px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--line); }
.r3-switch-item { display: inline-flex; align-items: center; justify-content: center; min-width: 88px; min-height: 44px; padding: 0 18px; border-radius: 999px; color: var(--muted); font-size: 15px; font-weight: 600; text-decoration: none; }
.r3-switch-item.on { background: var(--primary); color: var(--on-primary); }
.r3-switch-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (hover: hover) { .r3-switch-item:not(.on):hover { color: var(--text); } }
/* a computer with Show everything has the tabs for this */
@media (min-width: 761px) { :root:not([data-view="simple"]) .r3-switch { display: none; } }

/* ---- the deck ---- */
.r3-page .pm-head { margin-bottom: 14px; }
.r3-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
@media (min-width: 761px) { .r3-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; } }
@media (min-width: 1200px) { .r3-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }

.r3-card {
  --c: #8c9bba;
  --top: color-mix(in srgb, var(--c) 60%, #0b0d12);
  --bottom: color-mix(in srgb, var(--c) 24%, #0b0d12);
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  min-width: 0; min-height: 214px; aspect-ratio: 3 / 4; padding: 14px 14px 16px;
  border: 0; border-radius: var(--r-lg); background: linear-gradient(165deg, var(--top) 0%, var(--bottom) 78%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08), 0 10px 26px rgb(0 0 0 / 0.28);
  color: #fff; font: inherit; text-align: left; cursor: pointer; overflow: hidden; isolation: isolate;
  transition: transform 180ms var(--ease-calm), box-shadow 180ms var(--ease-calm);
}
/* a soft light in the top corner, like the reference's glow */
.r3-card::before { content: ""; position: absolute; inset: -30% -30% auto auto; z-index: -1; width: 80%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--c) 55%, transparent), transparent); opacity: 0.7; }
:root[data-theme="light"] .r3-card { --top: color-mix(in srgb, var(--c) 66%, #10131a); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2), 0 8px 22px rgb(22 24 29 / 0.16); }
@media (min-width: 761px) { .r3-card { aspect-ratio: 4 / 5; min-height: 250px; padding: 18px 18px 20px; } }
@media (hover: hover) { button.r3-card:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.14), 0 16px 34px rgb(0 0 0 / 0.32); } }
button.r3-card:active { transform: scale(0.98); }
.r3-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

.r3-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.r3-card-label { min-width: 0; overflow: hidden; padding: 4px 9px; border-radius: 999px; background: rgb(0 0 0 / 0.28); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; line-height: 1.2; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.r3-card-num { flex: none; min-width: 30px; padding: 3px 9px; border-radius: 999px; background: rgb(0 0 0 / 0.28); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
.r3-card-title { margin-top: auto; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.12; overflow-wrap: anywhere; text-shadow: 0 1px 12px rgb(0 0 0 / 0.25); }
.r3-card-sub { overflow: hidden; color: rgb(255 255 255 / 0.86); font-size: 14px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 761px) { .r3-card-title { font-size: 26px; } .r3-card-sub { font-size: 15px; } }
@media (max-width: 350px) { .r3-card-title { font-size: 19px; } .r3-card { padding: 12px 12px 14px; } }

.r3-empty { margin: 8px 0 18px; }

/* ---- the one voice button: top on a computer, docked above the tab bar on a phone ---- */
.r3-say { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: var(--btn-h-lg); padding: 0 24px; }
.r3-say svg { width: 22px; height: 22px; }
#r3-say-top { margin: 0 0 18px; }
#r3-say-dock { display: none; }
@media (max-width: 760px) {
  #r3-say-top { display: none; }
  #r3-say-dock { position: sticky; z-index: 3; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); display: flex; width: 100%; box-shadow: 0 10px 28px rgb(0 0 0 / 0.3); }
}

/* ---- one project: a sheet with the card as its header band ---- */
dialog.panel.r3-project { width: min(720px, calc(100vw - 32px)); max-height: min(88dvh, 900px); padding: 0; border: 0; border-radius: var(--r-sheet); overflow: hidden; }
dialog.panel.r3-project[open] { display: flex; flex-direction: column; }
.r3-p-band { --c: #8c9bba; position: relative; flex: none; display: flex; flex-direction: column; gap: 8px; padding: 20px 64px 20px 22px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--c) 60%, #0b0d12), color-mix(in srgb, var(--c) 24%, #0b0d12)); color: #fff; }
.r3-p-band .r3-card-top { justify-content: flex-start; }
.r3-p-title { margin: 6px 0 0; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; overflow-wrap: anywhere; }
.r3-p-sub { margin: 0; color: rgb(255 255 255 / 0.88); font-size: 16px; line-height: 1.4; }
dialog.panel .r3-p-x.icon-btn { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; background: rgb(0 0 0 / 0.28); color: #fff; }
.r3-p-body { flex: 1 1 auto; overflow-y: auto; padding: 6px 22px 12px; }
.r3-p-sec { padding: 16px 0; border-bottom: 1px solid var(--line); }
.r3-p-sec:last-child { border-bottom: 0; }
.r3-p-sec h3, .r3-p-history summary { margin: 0 0 10px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.r3-p-history summary { display: flex; align-items: center; min-height: 44px; margin: 0; cursor: pointer; }
.r3-u { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.r3-u dt { color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.5; }
.r3-u dd { margin: 0; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.r3-u dd.r3-u-status { font-size: 17px; font-weight: 600; }
@media (max-width: 520px) { .r3-u { grid-template-columns: 1fr; gap: 2px; } .r3-u dd { margin-bottom: 8px; } }
.r3-p-meta { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.r3-p-none { margin: 0; color: var(--muted); font-size: 16px; }
.r3-p-old { padding: 10px 0; border-top: 1px solid var(--line); }
.r3-p-old .r3-p-meta { margin: 0 0 6px; }
.r3-p-list, .r3-p-dates { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.r3-tile { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 14px; border: 0; border-radius: var(--r-row); background: var(--raised); box-shadow: inset 0 0 0 1px var(--glass-edge); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.r3-tile.focus { box-shadow: inset 0 0 0 2px var(--primary); }
.r3-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.r3-tile-title { flex: 1; min-width: 0; font-size: var(--fs-item); font-weight: 600; overflow-wrap: anywhere; }
.r3-tile-due { flex: none; color: var(--muted); font-size: 14px; }
.r3-tile-st { flex: none; display: inline-flex; align-items: center; gap: 6px; min-width: 84px; color: var(--muted); font-size: 13px; font-weight: 600; }
.r3-tile-st::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--st, #8c9bba); }
.r3-tile-st.s-moving { --st: #5ab0ff; } .r3-tile-st.s-waiting { --st: #ffb547; } .r3-tile-st.s-done { --st: #34d399; }
.r3-p-dates li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 2px; font-size: 16px; }
.r3-p-dates li.done span { color: var(--muted); }
.r3-p-goal { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.r3-p-note { margin: 0; white-space: pre-wrap; font-size: 16px; line-height: 1.5; }
.r3-p-foot { flex: none; display: flex; padding: 12px 22px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.r3-p-foot:empty { display: none; }
.r3-p-foot .r3-say { flex: 1; }

/* ---- Say an update: the sheet ---- */
dialog.panel.r3-voice { width: min(580px, calc(100vw - 32px)); padding: 22px 24px 24px; border: 0; border-radius: var(--r-sheet); }
dialog.panel.r3-voice[open] { display: flex; flex-direction: column; gap: 12px; }
.r3-v-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.r3-v-head h2 { margin: 0; font-size: 1.8125rem; font-weight: 500; letter-spacing: -0.03em; }
dialog.panel .r3-v-head .icon-btn { width: 44px; height: 44px; flex: none; }
.r3-v-about { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; font-weight: 600; }
.r3-v-pick { flex: 1; min-width: 0; height: 44px; padding: 0 12px; font-size: 16px; }
.r3-v-that { margin: 0; color: var(--muted); font-size: 14px; }
.r3-v-that b { color: var(--text); }
.r3-v-row { display: flex; align-items: flex-start; gap: 12px; }
.r3-v-mic { flex: none; display: grid; place-items: center; width: 64px; height: 64px; border: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); cursor: pointer; }
.r3-v-mic[hidden] { display: none; }
.r3-v-mic svg { width: 26px; height: 26px; }
.r3-v-mic.on { animation: pm-voice-ring 1.6s ease-out infinite; }
.r3-v-mic:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.r3-v-text { flex: 1; min-width: 0; min-height: 112px; font-size: 16px; line-height: 1.45; resize: vertical; }
.r3-v-hint, .r3-v-privacy { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.r3-v-privacy { font-size: 13px; }
.r3-v-err { margin: 0; color: var(--amber); font-size: 15px; font-weight: 600; }
.r3-v-err:empty { display: none; }
.r3-v-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.r3-v-foot .btn.primary { min-width: 140px; }

/* ---- end of the week: card by card ---- */
dialog.panel.r3-walk { width: min(440px, calc(100vw - 32px)); padding: 18px 22px 24px; border: 0; border-radius: var(--r-sheet); }
dialog.panel.r3-walk[open] { display: flex; flex-direction: column; gap: 14px; }
.r3-w-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
dialog.panel .r3-w-head .icon-btn { width: 44px; height: 44px; }
.r3-w-card { cursor: default; aspect-ratio: auto; min-height: 240px; }
.r3-w-btns { display: flex; gap: 10px; }
.r3-w-btns .btn { flex: 1; height: var(--btn-h-lg); }
.r3-w-btns .btn.primary { flex: 2; }
.r3-w-done { margin: 8px 0 0; font-size: 1.8125rem; font-weight: 500; letter-spacing: -0.03em; }
.r3-w-cheer { margin: 0; color: var(--muted); }
.r3-week-voice { display: inline-flex; align-items: center; gap: 8px; }
.r3-week-voice svg { width: 20px; height: 20px; }

/* ---- phone: bottom sheets, buttons in thumb reach ---- */
@media (max-width: 760px) {
  dialog.panel:is(.r3-project, .r3-voice, .r3-walk) { width: 100%; max-width: none; height: auto; margin: auto 0 0; max-height: 90dvh; border-radius: var(--r-sheet) var(--r-sheet) 0 0; }
  dialog.panel:is(.r3-voice, .r3-walk) { padding: 18px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
  dialog.panel.r3-project { overflow: hidden; }
  .r3-p-band { padding: 22px 60px 18px 16px; }
  .r3-p-title { font-size: 28px; }
  .r3-p-body { padding: 4px 16px 12px; }
  .r3-p-foot { padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .r3-v-foot { margin-top: auto; }
  .r3-v-foot .btn { flex: 1; height: var(--btn-h-lg); }
  .r3-switch { display: flex; }
  .r3-switch-item { flex: 1; }
  .pm-week-btns:has(.r3-week-voice) { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .r3-card, .r3-v-mic.on { transition: none; animation: none; }
  button.r3-card:hover, button.r3-card:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .r3-card-label, .r3-card-num { background: rgb(0 0 0 / 0.5); }
}
