/* ── Segmented control (.segmented block) ──────
   Group of buttons where one is active. Variants:
     --pill   rounded-pill outer, ghost buttons; active = surface bg + soft shadow
     --solid  free-standing buttons with own borders; active = filled accent
     --tabs   no chrome on outer; active = bold accent text
   State on the active button: .is-active. */
.segmented {
  display: inline-flex;
  align-items: center;
}
.segmented[hidden] { display: none; }

.segmented__btn {
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

/* — pill (focus mode toggle) — */
.segmented--pill {
  gap: 2px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 4px 8px;
  background: var(--glass-medium);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.segmented--pill .segmented__btn {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  color: white;
  font-size: var(--text-lg);
  font-weight: var(--font-extrabold);
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.segmented--pill .segmented__btn:hover {
  color: white;
}
.segmented--pill .segmented__btn.is-active {
  background: var(--purple);
  color: white;
  box-shadow: none;
}

/* Mode toggle: sliding pill indicator. Two equal-width columns so the
   ::before slider can translate cleanly between the two buttons. */
#focus-mode-toggle {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
#focus-mode-toggle::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 8px;
  width: calc((100% - 18px) / 2); /* 16px padding + 2px gap */
  background: var(--purple);
  border-radius: var(--radius-pill);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 0;
}
#focus-mode-toggle:has(.segmented__btn[data-mode="pomodoro"].is-active)::before {
  transform: translateX(calc(100% + 2px));
}
#focus-mode-toggle .segmented__btn {
  position: relative;
  z-index: 1;
  padding-left: 38px; /* 14px left inset + 20px icon + 4px gap to text */
}
#focus-mode-toggle .segmented__btn.is-active {
  background: transparent;
}
#focus-mode-toggle .segmented__btn::before,
#focus-mode-toggle .segmented__btn::after {
  content: '';
  position: absolute;
  left: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transition: opacity 0.22s ease;
}
#focus-mode-toggle .segmented__btn[data-mode="stopwatch"]::before {
  background-image: url('../../img/icons/stopwatch.svg');
}
#focus-mode-toggle .segmented__btn[data-mode="stopwatch"]::after {
  background-image: url('../../img/icons/stopwatch-disabled.svg');
}
#focus-mode-toggle .segmented__btn[data-mode="pomodoro"]::before {
  background-image: url('../../img/icons/podmoro.svg');
}
#focus-mode-toggle .segmented__btn[data-mode="pomodoro"]::after {
  background-image: url('../../img/icons/podmoro-disabled.svg');
}
#focus-mode-toggle .segmented__btn::before { opacity: 0; }
#focus-mode-toggle .segmented__btn::after { opacity: 1; }
#focus-mode-toggle .segmented__btn.is-active::before { opacity: 1; }
#focus-mode-toggle .segmented__btn.is-active::after { opacity: 0; }

/* — solid (pomodoro phase buttons) — */
.segmented--solid {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 22px;
}
.segmented--solid .segmented__btn {
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 2.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-md);
  font-weight: var(--font-extrabold);
  letter-spacing: 0.2px;
}
.segmented--solid .segmented__btn:hover {
  color: var(--text);
  background: var(--neutral-100);
}
.segmented--solid .segmented__btn.is-active {
  background: var(--purple);
  color: var(--neutral-0);
  border-color: var(--purple-dark);
  box-shadow: var(--shadow-chunky-thin) var(--purple-dark);
}
.segmented--solid .segmented__btn.is-active:hover {
  background: var(--purple-hover);
}
/* Break phases tint the active button green */
.segmented--solid[data-active-phase="short"] .segmented__btn.is-active,
.segmented--solid[data-active-phase="long"] .segmented__btn.is-active {
  background: var(--green-dark);
  border-color: var(--green-dark);
  box-shadow: var(--shadow-chunky-thin) var(--green-shadow);
  color: var(--neutral-0);
}

/* — tabs (topbar nav) — */
.segmented--tabs {
  gap: 2px;
}
.segmented--tabs .segmented__btn {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 20px;
  font-weight: var(--font-bold);
  color: rgba(255,255,255,0.70);
  position: relative;
}
.segmented--tabs .segmented__btn:hover {
  color: white;
  background: transparent;
}
.segmented--tabs .segmented__btn.is-active {
  color: white;
  font-weight: var(--font-black);
}
.segmented--tabs .segmented__btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 14px;
  right: 14px;
  height: 2px;
  background: white;
  border-radius: var(--radius-pill);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.22s ease;
}
.segmented--tabs .segmented__btn.is-active::after {
  transform: scaleX(1);
}
