/* Spossity SOS: card button, 3-second hold ring and popups. */
.sos-button {
  /* Spossity violet mirror-glass lettering. No disc: the ring appears only while held. */
  --sos-violet: #9b6cff;      /* design/tokens.json colors.brand.violet */
  --sos-violet-deep: #7836ef; /* Home accent (light) */
  --sos-violet-edge: #4a1aa8;
  position: absolute;
  top: 6px;
  right: 16px;
  z-index: 3;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.sos-button:focus-visible { outline: 3px solid var(--sos-violet); outline-offset: 2px; }
.sos-button > span {
  position: relative;
  z-index: 1;
  font-family: inherit;
  font-size: 26px; /* same size at rest and during the countdown, on every platform */
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  color: transparent;
  /* Mirror: bright sheen top, brand violet body, dark reflection band, lit lower edge. */
  /* Shared with NativeSos.js: violet mirror, sheen at the top only, no white at the bottom. */
  background: linear-gradient(180deg, #fbf8ff 0%, #d9c8ff 18%, #9b6cff 40%, #7836ef 60%, #5b25d6 72%, #7a45f0 88%, #9b6cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  /* Raised: stacked edge layers plus a soft cast shadow. */
  filter: drop-shadow(0 1px 0 #6a34e6) drop-shadow(0 1px 0 #5a28cc) drop-shadow(0 1px 0 var(--sos-violet-edge)) drop-shadow(0 4px 5px rgba(74, 26, 168, 0.38));
  transition: transform 120ms ease;
}
.sos-button svg { position: absolute; inset: 0; width: 60px; height: 60px; transform: rotate(-90deg); pointer-events: none; opacity: 0; transition: opacity 120ms ease; }
.sos-button .sos-track { fill: rgba(255, 255, 255, 0.35); stroke: rgba(229, 56, 59, 0.22); stroke-width: 3.5; }
.sos-button .sos-progress {
  fill: none;
  stroke: #e5383b; /* the moving countdown ring is emergency red */
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 163.4;
  stroke-dashoffset: 163.4;
}
.sos-button:active > span, .sos-button.is-holding > span { transform: translateY(1px); }
.sos-button.is-holding svg { opacity: 1; }
.sos-button.is-holding .sos-progress { animation: sos-fill var(--sos-hold, 3s) linear forwards; }
.sos-button.is-active > span { animation: sos-glow 1.8s ease-in-out infinite; }
@keyframes sos-fill { to { stroke-dashoffset: 0; } }
@keyframes sos-glow {
  0%, 100% { filter: drop-shadow(0 1px 0 #6a34e6) drop-shadow(0 1px 0 #5a28cc) drop-shadow(0 1px 0 #4a1aa8) drop-shadow(0 4px 5px rgba(74, 26, 168, 0.38)); }
  50% { filter: drop-shadow(0 1px 0 #6a34e6) drop-shadow(0 1px 0 #5a28cc) drop-shadow(0 1px 0 #4a1aa8) drop-shadow(0 0 10px rgba(155, 108, 255, 0.9)); }
}
html[data-theme="dark"] .sos-button { --sos-violet-deep: #b17aff; }
html[data-theme="dark"] .sos-button .sos-track { fill: rgba(155, 108, 255, 0.14); stroke: rgba(240, 107, 107, 0.28); }
html[data-theme="dark"] .sos-button .sos-progress { stroke: #f06b6b; }
html[data-theme="dark"] .sos-button > span { background-image: linear-gradient(180deg, #ffffff 0%, #e6d9ff 18%, #b17aff 40%, #8a4dff 60%, #6a34e6 72%, #8a4dff 88%, #b17aff 100%); }
/* Leave room so the name never runs under the SOS button. */
.map-person[data-home-family-card] .person-line { padding-right: 74px; }

.sos-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.sos-layer {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 8, 16, 0.55);
  backdrop-filter: blur(6px);
}
.sos-layer[hidden] { display: none; }
.sos-panel {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 32px 24px 22px;
  border-radius: 24px;
  /* Spossity glass (design/tokens.json): dark glass by default, light glass below. */
  border: 1px solid var(--sp-glass-border-dark, rgba(145, 190, 255, 0.28));
  background: var(--sp-glass-dark, rgba(4, 15, 32, 0.92));
  -webkit-backdrop-filter: blur(var(--sp-glass-blur, 18px)) saturate(140%);
  backdrop-filter: blur(var(--sp-glass-blur, 18px)) saturate(140%);
  color: #52698f;
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  font-family: inherit;
}
.sos-panel:focus, .sos-panel:focus-visible { outline: none !important; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45) !important; }
.sos-panel h2 { margin: 6px 0 0; font-size: 26px; font-weight: 700; }
.sos-panel h3 { margin: 14px 0 0; font-size: 19px; font-weight: 600; }
.sos-panel p { margin: 0; font-size: 16px; line-height: 1.45; color: #52698f; }
.sos-panel .sos-note { font-size: 14px; color: #52698f; }
.sos-panel .sos-location { font-weight: 600; color: #fff; }
.sos-panel button, .sos-panel a.sos-outline {
  width: 100%;
  min-height: 52px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  display: grid;
  place-items: center;
}
.sos-outline-danger { border: 1.5px solid #8c2a2a; background: transparent; color: #f06b6b; }
.sos-solid-danger { border: 0; background: #e5383b; color: #fff; }
.sos-primary-safe { border: 0; background: #2f9e5a; color: #fff; }
.sos-panel a.sos-outline { border: 1.5px solid #3a4250; color: #52698f; }
.sos-panel .sos-link { min-height: 44px; border: 0; background: transparent; color: #52698f; font-size: 15px; }
.sos-panel button:focus-visible, .sos-panel a:focus-visible { outline: 3px solid #6aa3ff; outline-offset: 2px; }

.sos-icon { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; }
.sos-icon::before { content: ""; width: 44px; height: 44px; background: currentColor; -webkit-mask: var(--sos-glyph) center / contain no-repeat; mask: var(--sos-glyph) center / contain no-repeat; }
.sos-icon-sent { background: #17261c; color: #5cc97b; --sos-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8 12.5 2.7 2.7L16.5 9'/%3E%3C/svg%3E"); }
.sos-icon-active, .sos-icon-alert, .sos-icon-error, .sos-icon-question, .sos-icon-sending { background: #2a1416; color: #f06b6b; }
.sos-icon-active, .sos-icon-alert { --sos-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20L12 3Z'/%3E%3Cpath d='M12 10v4M12 17.5v.01'/%3E%3C/svg%3E"); }
.sos-icon-error, .sos-icon-question { --sos-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 7v6M12 16.5v.01'/%3E%3C/svg%3E"); }
.sos-icon-sending { --sos-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 3a9 9 0 1 1-9 9'/%3E%3C/svg%3E"); }
.sos-icon-sending::before { animation: sos-spin 0.9s linear infinite; }
@keyframes sos-spin { to { transform: rotate(360deg); } }

html:not([data-theme="dark"]) .sos-panel { background: var(--sp-vibe-glass-background, linear-gradient(155deg, rgba(250,252,255,0.97), rgba(229,239,255,0.96) 76%)); border: 2px solid var(--sp-glass-border-light, rgba(255,255,255,0.82)); color: #0b285b; }
html:not([data-theme="dark"]) .sos-panel:focus, html:not([data-theme="dark"]) .sos-panel:focus-visible { box-shadow: var(--sp-vibe-glass-shadow, 0 10px 24px rgba(23,58,115,0.13)), 0 30px 80px rgba(8,34,78,0.18) !important; }
html:not([data-theme="dark"]) .sos-panel p { color: #52698f; }
html:not([data-theme="dark"]) .sos-panel .sos-note { color: #52698f; }
html:not([data-theme="dark"]) .sos-panel .sos-location { color: #0b285b; }
html:not([data-theme="dark"]) .sos-icon-sent { background: #e6f6ec; color: #2f9e5a; }
html:not([data-theme="dark"]) .sos-icon-active, html:not([data-theme="dark"]) .sos-icon-alert,
html:not([data-theme="dark"]) .sos-icon-error, html:not([data-theme="dark"]) .sos-icon-question,
html:not([data-theme="dark"]) .sos-icon-sending { background: #fdeceb; color: #d22f32; }
html:not([data-theme="dark"]) .sos-outline-danger { border-color: #e9a3a3; color: #d22f32; }
html:not([data-theme="dark"]) .sos-panel a.sos-outline { border-color: #c9d3e3; color: #0b285b; }
html:not([data-theme="dark"]) .sos-panel .sos-link { color: #52698f; }

@media (prefers-reduced-motion: reduce) {
  .sos-button > span { transition: none; }
  .sos-button.is-active > span, .sos-icon-sending::before { animation: none; }
  .sos-button.is-holding .sos-progress { animation-timing-function: steps(3, end); }
}
