/* Focus mode for chores and routines (see js/focus.js), plus its launch buttons
 * on the Chores screen (js/chores.js) and the Today / wall screen (js/home.js). */

/* ---------- launch buttons ---------- */
.focus-launch { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fl-cap {
  display: inline-flex; align-items: center; gap: 4px; margin-right: 2px;
  font-size: .76rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
}
.fl-cap svg { width: 16px; height: 16px; }
.fl-btn {
  --sec: var(--accent);
  font: inherit; font-weight: 700; font-size: .9rem; color: var(--text); white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 6px 14px 6px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--sec) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--sec) 45%, var(--border));
}
.fl-btn:hover { background: color-mix(in srgb, var(--sec) 26%, var(--surface)); }
.fl-btn.icon { width: 44px; height: 44px; padding: 0; }
.fl-ico { font-size: 1.15rem; line-height: 1; }
.fl-morning { --sec: #e0a21a; }
.fl-afternoon { --sec: #2f8fc9; }
.fl-evening { --sec: #6a5acd; }
.fl-chore { --sec: var(--good); }

/* Chores screen: under the person's progress bar */
.ch-focus { margin-top: 10px; }
@media (max-width: 480px) {
  .ch-focus .fl-label { display: none; }
  .ch-focus .fl-btn { width: 44px; padding: 0; }
}

/* Chores screen: section headings open Focus mode */
.ch-sec-focus {
  font: inherit; font-weight: inherit; color: inherit; text-align: left; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: none; border: 0; border-radius: 8px; padding: 4px 6px; margin: -4px -6px; min-height: 44px;
}
.ch-sec-focus:hover { background: color-mix(in srgb, var(--sec, var(--accent)) 14%, transparent); }
.ch-sec-focus .fl-svg { width: 16px; height: 16px; color: var(--muted); }

/* Today / wall screen: next to each person's name */
.hp-head { flex-wrap: wrap; row-gap: 4px; }
.hp-focus { margin-left: auto; gap: 4px; }
.hp-head .points + .hp-focus { margin-left: 0; }
.hp-focus:empty { display: none; }
.hp-focus .fl-btn { border-color: transparent; }
body.wall .hp-focus .fl-btn { width: 48px; height: 48px; }
body.wall .hp-focus .fl-ico { font-size: 1.35rem; }

/* ---------- the overlay ---------- */
body.focus-open { overflow: hidden; }
body.focus-open .wall-exit { display: none !important; }
#focus-root {
  position: fixed; inset: 0; z-index: 55; background: var(--bg); color: var(--text);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
#focus-root[hidden] { display: none; }
/* Nothing in Focus mode is text to copy. Without this, a double-tap or press-and-hold on an iPhone
   starts selecting text (e.g. "3 of 5 done"), shows the magnifier/copy menu, and the tap is lost. */
#focus-root, #focus-root * {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* While Focus mode (or the wall display) is up, nothing anywhere on the page is selectable —
   including things outside the Focus layer like the screen underneath and pop-up messages. */
html:has(body.focus-open), body.focus-open, body.focus-open *,
html:has(body.wall), body.wall, body.wall * {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
body.wall input, body.wall textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.fc-wrap {
  --sec: var(--accent);
  max-width: 980px; min-height: 100%; margin: 0 auto;
  padding: 0 calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 28px) calc(env(safe-area-inset-left) + 16px);
}
.fc-wrap:focus { outline: none; }
.fc-wrap.fc-sec-morning { --sec: #e0a21a; }
.fc-wrap.fc-sec-afternoon { --sec: #2f8fc9; }
.fc-wrap.fc-sec-evening { --sec: #6a5acd; }
.fc-wrap.fc-sec-chore { --sec: var(--good); }

/* top bar: who + stars on the left, hold-to-exit on the right; stays put while scrolling */
.fc-bar {
  position: sticky; top: 0; z-index: 3; background: var(--bg);
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 0 12px;
}
.fc-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar.fc-avatar { width: 48px; height: 48px; font-size: 1.3rem; }
.fc-points {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 1.25rem;
  background: #fff4d6; color: #8a5a00; border: 1px solid #f0d58a; border-radius: 999px; padding: 5px 14px;
}
.fc-points svg { width: 22px; height: 22px; fill: #e0a21a; stroke: #c98a00; }

.fc-exit {
  position: relative; overflow: hidden; flex: none; margin-left: auto; min-width: 9.6em; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px 8px 12px;
  font: inherit; font-weight: 700; font-size: .95rem; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
}
.fc-exit-fill {
  position: absolute; inset: 0; transform: scaleX(0); transform-origin: left center;
  background: color-mix(in srgb, var(--accent) 38%, var(--surface)); transition: transform .15s ease-out;
}
/* The fill is the progress, so it runs even with reduced motion. */
.fc-exit.holding { border-color: var(--accent); }
.fc-exit.holding .fc-exit-fill { transform: scaleX(1); transition: transform 2s linear; }
.fc-exit-ico, .fc-exit-label { position: relative; }
.fc-exit-ico svg { width: 18px; height: 18px; }

/* heading */
.fc-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.fc-sec-ico {
  flex: none; width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
  font-size: 2.2rem; line-height: 1; background: color-mix(in srgb, var(--sec) 22%, var(--surface));
}
.fc-head-main { flex: 1; min-width: 0; }
.fc-title { margin: 0; font-size: clamp(1.5rem, 6vw, 2.4rem); line-height: 1.15; overflow-wrap: break-word; }
.fc-when { color: var(--muted); font-weight: 600; margin-top: 2px; }
.fc-progress-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; }
.fc-count { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.fc-progress { flex: 1 1 140px; height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.fc-progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* items: each one is a single big button */
.fc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.fc-item {
  width: 100%; min-height: 76px; display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 16px;
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  /* Quick feedback animations. The check itself already appears the instant you tap;
     these just play alongside it. */
  transition: background-color .15s, border-color .15s, transform .08s, opacity .15s;
}
@media (hover: hover) { .fc-item:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); } }
.fc-item:active { transform: scale(.985); }
/* Dimmed only while the save hasn't shown up on this device yet — normally a blink, longer on a slow connection. */
.fc-item.pending { opacity: .65; }
.fc-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.fc-emoji { flex: none; width: 44px; text-align: center; font-size: 2rem; line-height: 1; }
.fc-item-title { flex: 1; min-width: 0; font-size: 1.35rem; font-weight: 700; line-height: 1.25; overflow-wrap: break-word; }
.fc-pts { flex: none; font-weight: 800; font-size: 1rem; color: #8a5a00; background: #fff4d6; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.fc-check {
  flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid var(--muted); color: var(--surface); /* readable on the green in light and dark */
  transition: background-color .15s, border-color .15s;
}
.fc-check svg { width: 30px; height: 30px; stroke-width: 3.2; }
.fc-item.done {
  background: color-mix(in srgb, var(--good) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--good) 55%, var(--border));
}
.fc-item.done .fc-check { background: var(--good); border-color: var(--good); }
.fc-item.done .fc-item-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }
.fc-item.done .fc-emoji { opacity: .6; }
.fc-item.pending .fc-check { border-style: dashed; }
.fc-item.old { opacity: .55; cursor: default; }
.fc-item.old .fc-check { border-style: dashed; }
.fc-item.old:active { transform: none; }

.fc-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 14px; padding: 12px;
  font-size: 1.3rem; font-weight: 800; color: var(--good); border-radius: 16px;
  background: color-mix(in srgb, var(--good) 14%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--good) 40%, var(--border));
}
.fc-note { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.fc-empty { text-align: center; padding: 48px 16px; font-size: 1.4rem; font-weight: 700; }
.fc-empty p { margin: 8px 0 0; }
.fc-empty-ico { font-size: 4rem; line-height: 1; }

/* ---------- celebration ---------- */
.fc-cele {
  position: fixed; inset: 0; z-index: 2; display: grid; place-items: center; overflow: hidden; cursor: pointer;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}
.fc-cele[hidden] { display: none; }
.fc-cele-card {
  position: relative; z-index: 1; text-align: center; max-width: min(92vw, 560px);
  background: var(--surface); border: 3px solid var(--accent); border-radius: 28px; padding: 28px 32px; box-shadow: var(--shadow);
  animation: fc-pop .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.fc-cele-big { font-size: clamp(2.2rem, 10vw, 4.2rem); font-weight: 900; line-height: 1.1; color: var(--accent); }
.fc-cele-name { font-size: clamp(1.2rem, 4.5vw, 1.8rem); font-weight: 700; margin-top: 8px; overflow-wrap: break-word; }
.fc-cele-stars {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 6px 18px; border-radius: 999px;
  font-size: clamp(1.3rem, 5vw, 2rem); font-weight: 900; color: #8a5a00; background: #fff4d6;
}
.fc-cele-stars svg { width: 1.2em; height: 1.2em; fill: #e0a21a; stroke: #c98a00; }
.fc-cele-tap { margin-top: 14px; color: var(--muted); font-size: .95rem; }
.fc-confetti { position: absolute; inset: 0; pointer-events: none; }
.fc-bit, .fc-star { position: absolute; top: -6vh; left: var(--x); animation: fc-fall var(--t) var(--d) cubic-bezier(.25, .6, .5, 1) both; }
.fc-bit { width: 10px; height: 16px; border-radius: 2px; background: var(--c); }
.fc-star { font-size: 26px; line-height: 1; color: var(--c); }
@keyframes fc-fall { from { transform: translateY(0) rotate(0deg); } to { transform: translateY(116vh) rotate(var(--r)); } }
@keyframes fc-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fc-points { background: #3b2f12; color: #f3cf74; border-color: #5c4718; }
  :root:not([data-theme="light"]) .fc-pts, :root:not([data-theme="light"]) .fc-cele-stars { background: #3b2f12; color: #f3cf74; }
}
:root[data-theme="dark"] .fc-points { background: #3b2f12; color: #f3cf74; border-color: #5c4718; }
:root[data-theme="dark"] .fc-pts, :root[data-theme="dark"] .fc-cele-stars { background: #3b2f12; color: #f3cf74; }

/* ---------- sizes ---------- */
@media (max-width: 420px) {
  .fc-sec-ico { width: 52px; height: 52px; font-size: 1.8rem; border-radius: 15px; }
  .fc-item { gap: 10px; padding: 10px 12px; }
  .fc-emoji { width: 36px; font-size: 1.7rem; }
  .fc-item-title { font-size: 1.2rem; }
  .fc-check { width: 44px; height: 44px; }
  .fc-exit { min-width: 8.6em; padding: 8px 12px 8px 10px; font-size: .9rem; }
  .fc-points { font-size: 1.1rem; padding: 4px 12px; }
}
/* Tablets, the kitchen wall display and computers: big, kid-friendly */
@media (min-width: 900px) {
  .fc-wrap { padding-left: calc(env(safe-area-inset-left) + 32px); padding-right: calc(env(safe-area-inset-right) + 32px); }
  .fc-bar { padding-top: calc(env(safe-area-inset-top) + 20px); }
  .avatar.fc-avatar { width: 60px; height: 60px; font-size: 1.6rem; }
  .fc-points { font-size: 1.5rem; padding: 6px 18px; }
  .fc-points svg { width: 28px; height: 28px; }
  .fc-exit { min-height: 56px; font-size: 1.05rem; }
  .fc-sec-ico { width: 84px; height: 84px; font-size: 3rem; border-radius: 22px; }
  .fc-title { font-size: 2.8rem; }
  .fc-when, .fc-count { font-size: 1.25rem; }
  .fc-progress { height: 16px; }
  .fc-list { gap: 14px; }
  .fc-item { min-height: 96px; gap: 20px; padding: 16px 22px; border-radius: 22px; }
  .fc-emoji { width: 60px; font-size: 2.8rem; }
  .fc-item-title { font-size: 1.9rem; }
  .fc-pts { font-size: 1.25rem; padding: 4px 14px; }
  .fc-check { width: 64px; height: 64px; border-width: 4px; }
  .fc-check svg { width: 40px; height: 40px; }
  .fc-banner { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .fc-confetti { display: none; }
  .fc-cele-card { animation: none; }
  .fc-item { transition: none; }
  .fc-item:active { transform: none; }
}
