/* First-visit terms sheet (app.terms.js): a sheet over the map with a reading
   ring, a two-second "Scroll for me" and a locked I Agree. Desktop: anchored
   to the bottom centre. Phones: inset with round corners. */

.tsRoot {
  position: fixed;
  inset: 0;
  z-index: 5000;
}
.tsScrim {
  position: absolute;
  inset: 0;
  background: rgba(23, 27, 28, 0.22);
  animation: tsFade 0.3s ease both;
}
.tsSheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  margin: 0 auto;
  width: min(640px, calc(100% - 32px));
  height: min(570px, calc(100% - 110px));
  box-sizing: border-box;
  padding: 10px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 28px;
  box-shadow: var(--shadow-2), 0 0 0 1px rgba(20, 28, 26, 0.04);
  font-family: var(--font-text);
  animation: tsRise 0.45s var(--ease-out) both;
}
.tsRoot.isLeaving .tsScrim {
  opacity: 0;
  transition: opacity 0.24s ease;
}
.tsRoot.isLeaving .tsSheet {
  opacity: 0;
  transform: translateY(50px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
@keyframes tsFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tsRise { from { opacity: 0; transform: translateY(70px); } to { opacity: 1; transform: none; } }

.tsGrab {
  flex: none;
  width: 44px;
  height: 5px;
  margin: 0 auto 2px;
  border-radius: var(--pill);
  background: var(--line);
}
.tsHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 4px 0;
}
.tsHeadText {
  min-width: 0;
}
.tsHead h2 {
  margin: 0;
  font: 800 22px/1.15 var(--font-display);
  letter-spacing: -0.01em;
}
.tsSub {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-quiet);
}

/* reading ring */
.tsRing {
  position: relative;
  flex: none;
  width: 50px;
  height: 50px;
}
.tsRing > svg {
  display: block;
  width: 50px;
  height: 50px;
  transform: rotate(-90deg);
}
.tsRing circle {
  fill: none;
  stroke-width: 4.5;
}
.tsRingBg {
  stroke: var(--line-soft);
}
.tsRingFg {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.12s linear, stroke 0.3s;
}
.tsRing .tsIc {
  position: absolute;
  inset: 0;
  margin: auto;
  color: var(--ink-quiet);
}
.tsSheet.isDone .tsRingFg {
  stroke: var(--ok);
}
.tsSheet.isDone .tsRing .tsIc {
  color: var(--ok);
}

/* the terms */
.tsTerms {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  border-radius: 20px;
  padding: 20px 22px 24px;
  scrollbar-width: thin;
  scrollbar-color: #c3cbc7 transparent;
}
.tsTerms:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.tsLegalHead {
  margin-bottom: 18px;
}
.tsLegalTitle {
  margin: 0;
  font: 800 15px/1.35 var(--font-display);
  letter-spacing: 0.02em;
}
.tsLegalSub {
  margin: 6px 0 0;
  font: 700 11.5px/1.45 var(--font-text);
  letter-spacing: 0.05em;
  color: var(--ink-quiet);
}
.tsSec + .tsSec {
  margin-top: 20px;
}
.tsSec h3 {
  margin: 0 0 8px;
  font: 700 16px/1.3 var(--font-display);
}
.tsSec p,
.tsSec li {
  font-size: 14.5px;
  line-height: 1.62;
  color: var(--ink-soft);
}
.tsSec p {
  margin: 0 0 10px;
}
.tsSec ul {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: grid;
  gap: 8px;
}
.tsSec li {
  position: relative;
  padding-left: 20px;
}
.tsSec li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: var(--pill);
  background: var(--accent);
  opacity: 0.5;
}
.tsSec strong {
  color: var(--ink);
  font-weight: 650;
}

/* buttons */
.tsFoot {
  flex: none;
  display: flex;
  gap: 10px;
}
.tsPill {
  position: relative;
  height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: 700 15.5px/1 var(--font-text);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.12s;
}
.tsPill:active {
  transform: scale(0.98);
}
.tsPill[hidden] {
  display: none;
}
.tsIc {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
}
.tsIc svg {
  display: block;
  width: 100%;
  height: 100%;
}
.tsPill--soft {
  background: var(--accent-wash);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--accent-wash-line);
}
.tsPill--soft:hover {
  background: #dbeaef;
}
.tsPill--primary {
  flex: 1;
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(0, 79, 97, 0.2), 0 6px 16px rgba(0, 103, 127, 0.22);
}
.tsPill--primary:hover {
  background: var(--accent-strong);
}
.tsPill--primary[aria-disabled="true"] {
  background: var(--line-soft);
  color: var(--ink-quiet);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: not-allowed;
}
.tsPill.isNudge {
  animation: tsNudge 0.4s ease;
}
.tsPill.isPop {
  animation: tsPop 0.45s var(--ease-out);
}
@keyframes tsNudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes tsPop { 0% { transform: scale(0.96); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }
.tsTip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 13px;
  border-radius: var(--pill);
  background: var(--ink);
  color: #ffffff;
  font: 600 12.5px/1 var(--font-text);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-1);
  animation: tsTip 2.2s var(--ease-out) both;
}
@keyframes tsTip {
  0% { opacity: 0; transform: translate(-50%, 4px); }
  12%, 80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; }
}

/* phones: inset sheet, most of the screen, map still peeking above */
@media (max-width: 600px) {
  .tsSheet {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    width: auto;
    height: 74dvh;
    border-radius: 38px;
    padding: 10px 14px 14px;
  }
  .tsHead h2 {
    font-size: 20px;
  }
  .tsTerms {
    padding: 16px 16px 20px;
  }
  .tsAuto {
    padding: 0 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tsScrim,
  .tsSheet,
  .tsPill.isNudge,
  .tsPill.isPop,
  .tsTip {
    animation: none;
  }
  .tsRoot.isLeaving .tsScrim,
  .tsRoot.isLeaving .tsSheet {
    transition: none;
  }
}
