/* ═══════════════════════════════════════════════════════════════════════
   css/guard.css — Focus Guard (owner: W4; v2-guard §4.3, §4.5, §6.6, §7)
   Tokens only. Calm: one glass banner at most, never red, never shaming.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── the check-in banner (#nudge-layer is a body child at z 90) ── */
.nudge {
  position: absolute;
  left: 50%;
  top: 72px;
  width: min(420px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 16px;
  border-radius: 22px;
  background: var(--surface-1, #1a1a19);
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.1));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  color: var(--text-primary);
  font-family: var(--font, system-ui);
  transform: translateX(-50%);
  animation: pf-nudge-in var(--dur-smooth, 610ms) var(--ease-smooth, cubic-bezier(.22, 1, .36, 1)) both;
}
:root[data-theme="light"] .nudge {
  background: #fff;
  border-color: rgba(11, 11, 11, 0.08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
}
.nudge.is-leaving {
  animation: pf-nudge-out var(--dur-exit, 180ms) var(--ease-exit, cubic-bezier(.4, 0, 1, 1)) both;
}
@keyframes pf-nudge-in {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes pf-nudge-out {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, -6px); }
}
@keyframes pf-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pf-fade-out { from { opacity: 1; } to { opacity: 0; } }

.nudge-head { display: flex; align-items: center; gap: 10px; }
.nudge-glyph { width: 20px; height: 20px; flex: none; color: var(--tint-text, var(--focus-tint)); }
.nudge-title { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.nudge-close {
  appearance: none; border: 0; background: transparent; color: var(--text-muted);
  width: 24px; height: 24px; display: grid; place-items: center; border-radius: 12px; cursor: pointer; flex: none;
}
.nudge-close svg { width: 11px; height: 11px; }
.nudge-close:hover { background: var(--fill-inset, rgba(255, 255, 255, 0.08)); color: var(--text-secondary); }
.nudge-body { margin: 6px 0 0 30px; font-size: 12.5px; font-weight: 500; line-height: 1.45; color: var(--text-secondary); }
.nudge-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0 30px; }
.nudge-btn {
  appearance: none;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.1));
  background: var(--fill-inset, rgba(255, 255, 255, 0.08));
  color: var(--text-primary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-quick, 160ms), transform var(--dur-quick, 160ms);
}
.nudge-btn:hover { background: color-mix(in srgb, var(--text-primary) 12%, transparent); }
.nudge-btn.is-primary {
  background: var(--btn-bg, var(--focus-tint));
  color: var(--btn-fg, #fff);
  border-color: transparent;
}
.nudge-btn.is-primary:hover { filter: brightness(1.08); }
.nudge-btn:active { transform: scale(0.97); }
.nudge-btn:focus-visible, .nudge-close:focus-visible { outline: 2px solid var(--tint-text, var(--focus-tint)); outline-offset: 2px; }

/* ── end-of-session stat in the rating zone (≥ 80 % only) ── */
#rating-extra-root { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
/* The rating zone is content-sized; the check-in gets a calm fixed width and scrolls its chips inside it. */
#rating-extra-root:has(> .factor-checkin) { width: 100%; max-width: 420px; padding-top: 6px; }
.rating:has(.factor-checkin) { align-self: stretch; }
.guard-zone-stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--tint-text, var(--text-secondary));
  font-variant-numeric: tabular-nums;
}
.guard-zone-stat svg { width: 12px; height: 12px; flex: none; }

/* ── focus-factor check-in, inside the rating zone (v2-guard §6.6) ── */
.factor-checkin { width: 100%; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; animation: pf-fade-in var(--dur-quick, 160ms) ease-out both; }
.fc-title { margin: 0; font-size: 11px; font-weight: 500; letter-spacing: 0.01em; color: var(--text-secondary); }
.fc-row { width: 100%; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.fc-chips {
  flex: 1; min-width: 0;
  /* the chips wrap onto a second line inside the timer panel — every one visible, nothing scrolls away */
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  padding: 3px 2px;
}
.fc-chips::-webkit-scrollbar { display: none; }
.fc-chip {
  appearance: none;
  flex: none;
  height: 26px;
  padding: 0 10px;
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; border-radius: 999px;
  background: var(--fill-inset, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary);
  font: inherit; font-size: 12px; font-weight: 500; white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-quick, 160ms), color var(--dur-quick, 160ms);
}
.fc-chip:hover { color: var(--text-primary); }
.fc-chip .fc-check { width: 0; height: 10px; opacity: 0; transition: width var(--dur-quick, 160ms), opacity var(--dur-quick, 160ms); }
.fc-chip .fc-caret { width: 10px; height: 10px; margin-right: -2px; opacity: 0.7; }
.fc-chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--tint, var(--focus-tint)) 16%, transparent);
  color: var(--tint-text, var(--focus-tint));
  animation: pf-chip-pop var(--dur-snappy, 420ms) var(--ease-quick, ease-out);
}
.fc-chip[aria-pressed="true"] .fc-check { width: 10px; opacity: 1; }
.fc-chip:focus-visible, .fc-done:focus-visible, .fc-menu-item:focus-visible { outline: 2px solid var(--tint-text, var(--focus-tint)); outline-offset: 2px; }
@keyframes pf-chip-pop { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }
.fc-done { flex: none; font-size: 12px; }
.fc-menu {
  position: fixed; z-index: 55;
  min-width: 170px; padding: 6px;
  display: flex; flex-direction: column;
  border-radius: 14px;
  background: var(--surface-1, #1a1a19);
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.1));
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  animation: pf-fade-in var(--dur-quick, 160ms) ease-out both;
}
:root[data-theme="light"] .fc-menu { background: #fff; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14); }
.fc-menu-item {
  appearance: none; display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px; border: 0; border-radius: 9px; background: none;
  color: var(--text-primary); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.fc-menu-item:hover { background: var(--fill-inset, rgba(255, 255, 255, 0.08)); }
.fc-menu-item .fc-check { width: 11px; height: 11px; color: var(--tint-text, var(--focus-tint)); opacity: 0; }
.fc-menu-item[aria-checked="true"] .fc-check { opacity: 1; }
.fc-menu-more { max-height: min(60vh, 420px); overflow: auto; min-width: 190px; }
.fc-menu-head { margin: 2px 8px 6px; font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.fc-menu-done {
  appearance: none; margin-top: 5px; height: 30px; border: 0; border-radius: 9px;
  background: var(--fill-inset, rgba(255, 255, 255, 0.08)); color: var(--text-primary);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.fc-menu-done:hover { background: color-mix(in srgb, var(--text-primary) 14%, transparent); }
.fc-menu-done:focus-visible { outline: 2px solid var(--tint-text, var(--focus-tint)); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .fc-chip[aria-pressed="true"] { animation: none; } }
body.reduce-motion .fc-chip[aria-pressed="true"] { animation: none; }

/* ── the shield chip: last child of .timer-footer (v2-guard §7.1) ── */
#guard-chip-root { display: inline-flex; }
.guard-chip {
  appearance: none;
  height: 24px;
  padding: 0 9px 0 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-quick, 160ms), opacity var(--dur-quick, 160ms), color var(--dur-quick, 160ms);
}
.guard-chip-label { display: inline-block; }
.guard-chip svg { width: 14px; height: 14px; flex: none; }
.guard-chip[data-state="on"], .guard-chip[data-state="block"] { color: var(--tint-text, var(--focus-tint)); }
.guard-chip:hover, .guard-chip[aria-expanded="true"] { background: var(--fill-inset, rgba(255, 255, 255, 0.08)); }
.guard-chip:focus-visible { outline: 2px solid var(--tint-text, var(--focus-tint)); outline-offset: 2px; }
body.timer-running[data-mode="focus"] .guard-chip { opacity: 0.55; }
body.timer-running[data-mode="focus"] .guard-chip:hover,
body.timer-running[data-mode="focus"] .guard-chip:focus-visible,
body.timer-running[data-mode="focus"] .guard-chip[aria-expanded="true"] { opacity: 1; }

/* ── the Guard popover (300 wide, above the chip) ── */
.guard-pop {
  position: fixed;
  z-index: 50;
  left: 16px; top: 16px;
  width: min(300px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 14px 16px 10px;
  border-radius: 18px;
  background: var(--surface-1, #1a1a19);
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.1));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  color: var(--text-primary);
  font-family: var(--font, system-ui);
  animation: pf-fade-in var(--dur-quick, 160ms) var(--ease-quick, ease-out) both;
}
:root[data-theme="light"] .guard-pop { background: #fff; border-color: rgba(11, 11, 11, 0.08); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14); }
.gp-head { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.gp-glyph { width: 16px; height: 16px; flex: none; color: var(--tint-text, var(--focus-tint)); }
.gp-head-text { flex: 1; display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.gp-title { font-size: 13px; font-weight: 600; }
.gp-state { font-size: 12px; color: var(--text-muted); }
.gp-explain { margin: 4px 0 10px; }
.gp-points { margin: 0 0 8px; padding: 0 0 0 16px; font-size: 12px; line-height: 1.45; color: var(--text-secondary); }
.gp-points li { margin: 0 0 4px; }
.gp-privacy { margin: 0; font-size: 11.5px; line-height: 1.4; color: var(--text-muted); }
.gp-turn-on { width: 100%; margin: 0 0 10px; }
.gp-row.is-unavailable .gp-row-title { color: var(--text-secondary); }
.gp-row.is-unavailable .guard-switch { opacity: 0.45; }
.gp-caption { margin: 8px 0 6px; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.gp-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--hairline, rgba(255, 255, 255, 0.1)); }
.gp-head + .gp-row { margin-top: 8px; }
.gp-row--btn {
  appearance: none; width: 100%; background: none; border: 0; border-top: 1px solid var(--hairline, rgba(255, 255, 255, 0.1));
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.gp-row--btn:hover .gp-row-title { color: var(--tint-text, var(--focus-tint)); }
.gp-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.gp-row-title { font-size: 12.5px; font-weight: 600; }
.gp-row-sub { font-size: 11.5px; line-height: 1.4; color: var(--text-muted); }
.gp-link {
  appearance: none; background: none; border: 0; padding: 0; margin: 0;
  font: inherit; font-size: 11.5px; font-weight: 550; color: var(--tint-text, var(--focus-tint)); cursor: pointer; text-align: left;
}
.gp-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.gp-link:focus-visible, .gp-row--btn:focus-visible { outline: 2px solid var(--tint-text, var(--focus-tint)); outline-offset: 2px; border-radius: 4px; }
.gp-live { margin: 2px 0 8px; padding: 8px 10px; border-radius: 10px; background: var(--fill-inset, rgba(255, 255, 255, 0.08)); font-size: 12px; color: var(--tint-text, var(--text-secondary)); }
.gp-foot { display: flex; justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--hairline, rgba(255, 255, 255, 0.1)); }
.guard-chevron { width: 12px; height: 12px; flex: none; color: var(--text-muted); }
.guard-switch { flex: none; }

/* ── Settings › Focus Guard (v2-guard §7.2) ── */
.settings-section[data-section-id="guard"] { display: flex; flex-direction: column; gap: 10px; }
.guard-card { gap: 18px; }
.guard-hero { flex-wrap: nowrap; gap: 14px; }
.guard-hero .pref-text { flex: 1 1 auto; }
.guard-hero-icon {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--tint, var(--focus-tint)) 16%, transparent);
  color: var(--tint-text, var(--focus-tint));
  transition: background var(--dur-smooth, 610ms), color var(--dur-smooth, 610ms);
}
.guard-hero-icon svg { width: 26px; height: 26px; }
.guard-card.is-off .guard-hero-icon { background: var(--fill-inset, rgba(255, 255, 255, 0.08)); color: var(--text-secondary); }
.guard-hero-title { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; color: var(--text-primary); }
.guard-collapse {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows var(--dur-smooth, 610ms) var(--ease-smooth, ease), opacity var(--dur-smooth, 610ms) var(--ease-smooth, ease),
              margin var(--dur-smooth, 610ms) var(--ease-smooth, ease);
}
.guard-collapse-inner { min-height: 0; overflow: hidden; }
.guard-card.is-off .guard-collapse { grid-template-rows: 0fr; opacity: 0; margin-top: -18px; }
.guard-pref { flex-wrap: nowrap; }
.guard-pref .pref-text { flex: 1 1 auto; }
.guard-link-row {
  appearance: none; width: 100%; padding: 0; margin: 0; background: none; border: 0;
  color: inherit; font: inherit; text-align: left; cursor: pointer; flex-wrap: nowrap;
}
.guard-link-row:hover .pref-title { color: var(--tint-text, var(--focus-tint)); }
.guard-link-row:focus-visible { outline: 2px solid var(--tint-text, var(--focus-tint)); outline-offset: 4px; border-radius: 8px; }
.guard-row-tail { display: flex; align-items: center; color: var(--text-muted); }
.guard-row-tail .guard-chevron { width: 14px; height: 14px; }
.pref-row .segmented.guard-seg { grid-template-columns: repeat(var(--seg-n, 3), minmax(54px, 1fr)); }
.guard-stepper { display: flex; align-items: center; gap: 8px; flex: none; }
.guard-stepper .icon-btn { font-size: 16px; font-weight: 600; line-height: 1; }
.guard-stepper .icon-btn:disabled { opacity: 0.35; cursor: default; }
.guard-stepper-value { min-width: 18px; text-align: center; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.guard-how > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-secondary); list-style: none; }
.guard-how > summary::-webkit-details-marker { display: none; }
.guard-how > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--text-muted); transition: transform var(--dur-quick, 160ms); }
.guard-how[open] > summary::before { transform: rotate(90deg); }
.guard-how-list { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }
.guard-privacy { margin: 0 6px; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
@media (max-width: 520px) {
  .guard-pref { flex-wrap: wrap; }
  .guard-pref .segmented.guard-seg { width: 100%; }
  .guard-pref:has(> .guard-stepper), .guard-pref:has(> .guard-switch) { flex-wrap: nowrap; }
}

/* ── sheets: the distraction list and the extension guide (z 70) ── */
.guard-sheet { width: min(520px, calc(100vw - 32px)); }
.guard-sheet .sheet-header { padding-right: 14px; }
.guard-sheet-lede { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.guard-sheet-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.guard-add { display: flex; gap: 8px; }
.guard-add .text-input { flex: 1; height: 36px; }
.guard-add .btn { height: 36px; }
.guard-add-msg { margin: -8px 2px 0; min-height: 16px; font-size: 12px; color: var(--text-muted); }
.guard-add-msg.is-error { color: var(--text-secondary); }
.guard-confirm { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: -6px; padding: 10px 12px; border-radius: 12px; background: var(--fill-inset, rgba(255, 255, 255, 0.08)); font-size: 12.5px; color: var(--text-secondary); }
.guard-confirm > span { flex: 1 1 200px; }
.guard-confirm[hidden] { display: none; }
.guard-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.guard-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 0; border-bottom: 1px solid var(--hairline, rgba(255, 255, 255, 0.1)); }
.guard-item-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--fill-inset, rgba(255, 255, 255, 0.08)); color: var(--text-secondary); }
.guard-item-icon svg { width: 15px; height: 15px; }
.guard-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.guard-item-name { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guard-item-kind { font-size: 11.5px; color: var(--text-muted); }
.guard-item-remove { opacity: 0; transition: opacity var(--dur-quick, 160ms); }
.guard-item-remove svg { width: 11px; height: 11px; }
.guard-item:hover .guard-item-remove, .guard-item:focus-within .guard-item-remove { opacity: 1; }
@media (hover: none) { .guard-item-remove { opacity: 1; } }
.guard-empty, .guard-items-cap { padding: 10px 0 2px; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.guard-suggest-title { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.guard-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.guard-sugg {
  appearance: none; height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.1)); background: var(--fill-inset, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
  transition: color var(--dur-quick, 160ms), background var(--dur-quick, 160ms);
}
.guard-sugg:hover { color: var(--text-primary); background: color-mix(in srgb, var(--text-primary) 10%, transparent); }
.guard-sugg:focus-visible { outline: 2px solid var(--tint-text, var(--focus-tint)); outline-offset: 2px; }
.guard-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }

/* ── Reduce Motion twins ── */
@media (prefers-reduced-motion: reduce) {
  .nudge { animation-name: pf-fade-in; animation-duration: 150ms; transform: translateX(-50%); }
  .nudge.is-leaving { animation-name: pf-fade-out; }
}
body.reduce-motion .nudge { animation-name: pf-fade-in; animation-duration: 150ms; }
body.reduce-motion .nudge.is-leaving { animation-name: pf-fade-out; }

/* H5 polish: check-in chips wrap instead of hiding off-screen on narrow screens */
@media (max-width: 640px) {
  .fc-row { flex-direction: column; gap: 6px; }
  .fc-chips { flex: none; width: 100%; flex-wrap: wrap; justify-content: center; overflow: visible; mask-image: none; -webkit-mask-image: none; }
  .fc-chips > :first-child, .fc-chips > :last-child { margin-left: 0; margin-right: 0; }
}
