/* v140 Círculo extras: viagem acompanhada, rotina de horários e encontros (public/circle-extras.mjs and friends).
 * Loaded after v140-circle.css: reuses its --circle-* tokens (light/dark) and button/field/sheet classes. */
:root {
  --cx-radius: 16px;
  --cx-soft: var(--circle-raised, #f4f6fb);
  --cx-coral: var(--l360-coral-strong, #c4381f);
  --cx-coral-soft: var(--l360-coral-soft, #fff0eb);
  --cx-pin: var(--l360-coral, #ff6a4a);
}
:root[data-theme=dark] {
  --cx-coral: #ff9a82;
  --cx-coral-soft: #3a2019;
}

/* ---------- "Avisar meu círculo" (itinerary, Casa ↔ Trabalho results, travel sheet, guide) ---------- */
.cx-trip-slot { display: block; }
.cx-trip-slot:empty { display: none; }
.cx-trip-share {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--cx-soft);
  color: var(--circle-ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.cx-trip-share > span:last-child { display: grid; gap: 1px; min-width: 0; }
.cx-trip-share strong { font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.cx-trip-share small { color: var(--circle-muted); font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.cx-trip-share[data-state="on"] { background: var(--circle-live-soft); }
.cx-trip-share[data-state="on"] small { color: var(--circle-live-ink); }
.cx-trip-share[data-state="supervised"] { grid-template-columns: 22px minmax(0, 1fr); cursor: default; background: var(--circle-live-soft); }
.cx-trip-share[data-state="supervised"] > .ui-icon { width: 22px; height: 22px; color: var(--circle-live-ink); }
/* The native checkbox stays as the accessible control (role=switch) under a larger visual switch. */
.cx-trip-share input { position: absolute; top: 50%; left: 10px; width: 44px; height: 44px; margin: -22px 0 0; opacity: 0; cursor: pointer; }
.cx-switch { position: relative; display: block; width: 40px; height: 24px; flex: none; border-radius: 12px; background: color-mix(in srgb, var(--circle-muted) 45%, transparent); transition: background .18s ease; }
.cx-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 26, 46, .3); transition: transform .18s ease; }
.cx-trip-share input:checked + .cx-switch { background: var(--circle-live, #12b76a); }
.cx-trip-share input:checked + .cx-switch::after { transform: translateX(16px); }
.cx-trip-share:has(input:focus-visible) { outline: 3px solid var(--circle-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .cx-switch, .cx-switch::after { transition: none; } }
body.reduce-motion .cx-switch, body.reduce-motion .cx-switch::after { transition: none; }
/* Placement: itinerary hero (before "Acompanhar"), Casa ↔ Trabalho results, the trip sheets. */
.itinerary-travel-start .cx-trip-slot { margin-top: 10px; }
#commute-route-panel > .cx-trip-slot { margin: 0 0 12px; }
#results-region .journey-section-label + .cx-trip-slot { margin: 0 0 12px; }
#travel-sheet-body > .cx-trip-slot { margin: 2px 0 12px; }
#journey-guide .cx-trip-slot { margin: 8px 0 0; }
body.journey-guide-compact #journey-guide .cx-trip-slot { display: none; }

/* ---------- Cards in the member sheet (trip, routine) ---------- */
.cx-card { display: grid; gap: 12px; padding: 14px; border-radius: var(--cx-radius); background: var(--cx-soft); }
.cx-card-head { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.cx-card-head > div { min-width: 0; }
.cx-card-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--circle-surface); color: var(--circle-accent); }
.cx-card-icon svg { width: 20px; height: 20px; }
.cx-card h3, .cx-card h4, .cx-meet h4 { margin: 0; overflow-wrap: anywhere; font: 700 15px/1.3 'DM Sans', system-ui, sans-serif; }
.cx-card-head p { margin: 2px 0 0; color: var(--circle-muted); font-size: 13px; line-height: 1.4; }
.cx-card-head .circle-btn-text { align-self: center; }
.cx-card-note { margin: 0; color: var(--circle-muted); font-size: 12.5px; line-height: 1.45; }
.cx-trip[data-status="riding"] .cx-card-icon, .cx-trip[data-status="waiting"] .cx-card-icon { background: var(--circle-button); color: var(--circle-on-button); }
.cx-trip[data-status="arrived"] .cx-card-icon { background: var(--circle-live-soft); color: var(--circle-live-ink); }
.cx-trip[data-status="riding"] h3 { color: var(--circle-accent); }
.cx-trip[data-status="arrived"] h3 { color: var(--circle-live-ink); }

/* Saiu → Embarcou → Desceu */
.cx-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; counter-reset: none; }
.cx-steps li { position: relative; display: grid; justify-items: start; gap: 2px; padding-top: 16px; font-size: 12.5px; }
.cx-steps li i { position: absolute; top: 0; left: 0; width: 10px; height: 10px; border: 2px solid var(--circle-muted); border-radius: 50%; background: var(--circle-surface); }
.cx-steps li::before { content: ''; position: absolute; top: 5px; left: 12px; right: 2px; height: 2px; background: var(--circle-line); }
.cx-steps li:last-child::before { display: none; }
.cx-steps li[data-done="true"] i { border-color: var(--circle-live); background: var(--circle-live); }
.cx-steps li[data-done="true"]::before { background: color-mix(in srgb, var(--circle-live) 60%, var(--circle-line)); }
.cx-steps span { color: var(--circle-ink); font-weight: 700; }
.cx-steps li[data-done="false"] span { color: var(--circle-muted); font-weight: 600; }
.cx-steps time { color: var(--circle-muted); font-variant-numeric: tabular-nums; }
.cx-notify { justify-self: start; min-height: 44px; margin: -4px 0 -6px -6px; }

/* Routine */
.cx-routine-status { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.cx-routine-status li { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.cx-routine-status li::before { content: ''; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--circle-live); }
.cx-routine-status li[data-tone="done"] { color: var(--circle-live-ink); }
.cx-routine-status li[data-tone="late"] { color: var(--circle-warn-ink); }
.cx-routine-status li[data-tone="late"]::before { background: var(--circle-warn-ink); }
.cx-inline-action { display: flex; }
.cx-inline-action .circle-btn { flex: 1 1 auto; }

/* ---------- Casa ↔ Trabalho: "Meus horários" row joins the saved places card ---------- */
.saved-places .cx-routine-card { width: 100%; }
body.map-shell .control-panel .saved-places .cx-routine-card + .place-card,
body.map-shell .control-panel .saved-places .place-card + .cx-routine-card { border-top: 1px solid var(--line); }
.place-icon.cx-routine-icon { color: var(--cx-coral); background: var(--cx-coral-soft); }
.place-icon.cx-routine-icon svg { fill: none; stroke: currentColor; }
body.map-shell .control-panel .cx-routine-card .place-copy strong { white-space: normal; }

/* "Hora de sair" (app open, near the planned time) */
.cx-nudge {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto 44px;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
  padding: 10px 6px 10px 12px;
  border-radius: 16px;
  background: var(--circle-accent-soft);
  color: var(--circle-ink);
  font-family: 'DM Sans', system-ui, sans-serif;
}
.cx-nudge-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--circle-button); color: var(--circle-on-button); }
.cx-nudge-icon svg { width: 20px; height: 20px; }
.cx-nudge-text { display: grid; gap: 1px; min-width: 0; }
.cx-nudge-text strong { font-size: 14px; line-height: 1.25; }
.cx-nudge-text small { color: var(--circle-muted); font-size: 12.5px; line-height: 1.35; }
.cx-nudge .circle-btn { min-height: 44px; padding: 0 14px; font-size: 13px; }
.cx-nudge .circle-icon-btn { background: transparent; }
@media (max-width: 380px) {
  .cx-nudge { grid-template-columns: 36px minmax(0, 1fr) 44px; }
  .cx-nudge .circle-btn { grid-column: 2 / 4; grid-row: 2; justify-self: stretch; }
}
body:is(.travel-active, .journey-navigation-active) .cx-nudge { display: none; }

/* ---------- Extra sheet (routine and meet forms) ---------- */
dialog.circle-x-sheet { z-index: 2; }
.cx-time-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.circle-x-sheet .circle-field select,
.circle-x-sheet .circle-field input[type="time"] {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--circle-line);
  border-radius: 14px;
  background: var(--circle-surface);
  color: var(--circle-ink);
  font: 500 16px 'DM Sans', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme=dark] .circle-x-sheet .circle-field :is(select, input[type="time"]) { color-scheme: dark; }
.circle-x-sheet .circle-field select:focus-visible { outline: 3px solid color-mix(in srgb, var(--circle-accent) 40%, transparent); border-color: var(--circle-accent); }
.cx-days { margin: 0; padding: 0; border: 0; }
.cx-days legend { margin-bottom: 8px; padding: 0; color: var(--circle-muted); font-size: 13px; font-weight: 700; }
.cx-days > div { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
/* Narrow phones: weekdays on one row, the weekend below, every day still a 44 px target. */
@media (max-width: 380px) { .cx-days > div { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.cx-days label { position: relative; display: grid; place-items: center; min-height: 44px; border: 1px solid var(--circle-line); border-radius: 12px; font: 700 14px 'DM Sans', system-ui, sans-serif; cursor: pointer; }
.cx-days input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.cx-days label:has(input:checked) { border-color: var(--circle-button); background: var(--circle-button); color: var(--circle-on-button); }
.cx-days label:has(input:focus-visible) { outline: 3px solid var(--circle-accent); outline-offset: 2px; }
.cx-places label { padding: 10px 12px; }
.cx-places small { overflow-wrap: anywhere; }
.circle-x-sheet .circle-fineprint { align-items: flex-start; }
.circle-x-sheet .circle-form > .circle-btn-text { justify-self: center; }
.cx-days .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Encontros in the circle overview ---------- */
.cx-meets { display: grid; gap: 10px; }
.cx-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cx-section-head h3 { margin: 0; color: var(--circle-muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.cx-section-head .circle-btn-text { min-height: 44px; }
.cx-meets-empty { display: flex; }
.cx-meets-empty .circle-btn { flex: 1 1 auto; }
.cx-meet { display: grid; gap: 12px; padding: 14px; border-radius: var(--cx-radius); background: var(--cx-soft); }
.cx-meet:focus { outline: none; }
.cx-meet:focus-visible { outline: 3px solid var(--circle-accent); outline-offset: 2px; }
.cx-meet .cx-card-icon { color: var(--cx-coral); }
.cx-meet p { margin: 2px 0 0; color: var(--circle-ink); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.cx-meet p b { color: var(--circle-accent); }
.cx-meet small { display: block; margin-top: 2px; color: var(--circle-muted); font-size: 12.5px; line-height: 1.4; }
.cx-rsvp { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: 3px; border-radius: 14px; background: var(--circle-surface); box-shadow: inset 0 0 0 1px var(--circle-line); }
.cx-rsvp button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; margin: 0; padding: 0 6px; border: 0; border-radius: 11px; background: transparent; color: var(--circle-ink); font: 700 14px 'DM Sans', system-ui, sans-serif; cursor: pointer; }
.cx-rsvp button svg { width: 16px; height: 16px; }
.cx-rsvp button[aria-pressed="true"] { background: var(--circle-button); color: var(--circle-on-button); }
.cx-rsvp button:focus-visible { outline: 3px solid var(--circle-accent); outline-offset: 1px; }
@media (hover: hover) { .cx-rsvp button[aria-pressed="false"]:hover { background: var(--circle-accent-soft); } }
.cx-meet-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cx-meet-actions .circle-btn { padding: 0 10px; white-space: nowrap; }
@media (max-width: 359px) { .cx-meet-actions { grid-template-columns: 1fr; } }
.cx-meet-manage { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; margin: -6px -6px -8px; }

/* ---------- Map: meet pin and the long-press popup ---------- */
.cx-meet-pin { position: relative; display: grid; justify-items: center; min-width: 44px; min-height: 44px; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; }
.cx-meet-pin-dot { display: grid; place-items: center; width: 34px; height: 34px; border: 3px solid #fff; border-radius: 50% 50% 50% 4px; background: var(--cx-pin); color: #fff; box-shadow: 0 2px 8px rgba(15, 26, 46, .35); transform: rotate(-45deg); }
.cx-meet-pin-dot svg { width: 17px; height: 17px; transform: rotate(45deg); }
.cx-meet-pin-time { margin-top: 3px; padding: 1px 6px; border-radius: 8px; background: var(--circle-surface); color: var(--circle-ink); box-shadow: 0 1px 4px rgba(15, 26, 46, .25); font: 700 11px/1.3 'DM Sans', system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.cx-meet-pin:focus-visible { outline: 3px solid var(--circle-accent); outline-offset: 2px; border-radius: 12px; }
.cx-press-popup .maplibregl-popup-content { padding: 6px 36px 6px 6px; border-radius: 16px; background: var(--circle-surface); color: var(--circle-ink); box-shadow: var(--circle-shadow); }
.cx-press-popup .maplibregl-popup-tip { border-top-color: var(--circle-surface); border-bottom-color: var(--circle-surface); }
.cx-press-popup .maplibregl-popup-close-button { top: 50%; right: 2px; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%; color: var(--circle-muted); font-size: 20px; }
.cx-press-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: 0; padding: 0 14px; border: 0; border-radius: 12px; background: var(--circle-button); color: var(--circle-on-button); font: 700 14px 'DM Sans', system-ui, sans-serif; white-space: nowrap; cursor: pointer; }
.cx-press-btn svg { width: 18px; height: 18px; }
.cx-press-btn:focus-visible { outline: 3px solid var(--circle-accent); outline-offset: 2px; }
