/* ==========================================================================
   PomoMed — extras: focus (zen) mode, break tips
   Owner: EXTRAS. Uses tokens from app.css / features.css.
   ========================================================================== */

/* ---------- 1. Focus-mode button (top-right of the timer card) ---------- */
#timer-card { position: relative; }

.btn-zen {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  opacity: .92;
  transition: background-color .15s, opacity .15s, transform .08s;
}
.btn-zen svg { width: 20px; height: 20px; }
.btn-zen:hover { opacity: 1; background: var(--glass-dark, var(--shade)); border-color: var(--glass-line, transparent); }
.btn-zen:active { transform: scale(.94); }
.btn-zen:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; border-radius: 10px; }

/* Keep the centred mode tabs clear of the corner button. */
#timer-card > .mode-tabs { max-width: calc(100% - 92px); }
@media (max-width: 440px) {
  #timer-card > .mode-tabs { max-width: 100%; margin-top: 34px; }
  .btn-zen { top: 2px; right: 2px; }
}

/* ---------- 2. Zen mode: only the timer core stays ---------------------- */
body.zen > :not(main):not(dialog):not(#toast-region):not(.pm-toast-region):not(script),
body.zen .app > :not(#timer-card),
body.zen #timer-card > :not(#timer-display):not(.timer-controls):not(#focus-on):not(#music-mini):not(#break-tip):not(#btn-zen) {
  display: none !important;
}

body.zen .app {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: calc(640px + 2 * var(--gutter));
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: max(56px, env(safe-area-inset-top));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}
body.zen #timer-card {
  padding: 0 0 12px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
body.zen #timer-card > .mode-tabs { margin-top: 0; }
body.zen .timer-display {
  margin: 0 0 34px;
  font-size: clamp(5rem, 27vw, 11rem);
  text-shadow: 0 6px 34px rgba(0, 0, 0, .16);
}
body.zen .btn-zen {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  background: var(--shade);
}
body.zen .btn-zen:hover { background: rgba(0, 0, 0, .26); }
@media (prefers-reduced-motion: no-preference) {
  /* Animate the card's children, not the card: a transform on #timer-card would
     become the containing block of the position:fixed exit button mid-animation. */
  body.zen #timer-card > :not(#btn-zen) { animation: zen-in .35s var(--ease); }
}
@keyframes zen-in {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: 1; transform: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  body.zen .app { justify-content: flex-start; padding-top: 16px; }
  body.zen .timer-display { margin-bottom: 18px; font-size: clamp(4rem, 22vh, 7rem); }
}

/* ---------- 3. Break tip ------------------------------------------------- */
.break-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 440px;
  margin: -10px auto 22px;
  padding: 10px 6px 10px 12px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .2);
  color: #fff;
  text-align: left;
}
body[data-theme="dark"] .break-tip { background: rgba(255, 255, 255, .08); }
.break-tip__emoji {
  flex: none;
  margin-top: 1px;
  font-size: 1.375rem;
  line-height: 1.2;
}
.break-tip__body { flex: 1 1 auto; min-width: 0; }
.break-tip__label {
  margin: 0;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.break-tip__text {
  margin: 2px 0 0;
  font-size: .9375rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.break-tip__next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: .8125rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color .15s, transform .08s;
}
.break-tip__next:hover { background: rgba(255, 255, 255, .24); }
.break-tip__next:active { transform: scale(.96); }
.break-tip__next:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@media (max-width: 520px) {
  .break-tip__next { width: 40px; padding: 0; }
  .break-tip__next-txt {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .break-tip:not([hidden]) { animation: break-tip-in .32s var(--ease); }
}
@keyframes break-tip-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
body.zen .break-tip { margin-top: -18px; }

/* ---------- 4. Motion & forced colours ---------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .btn-zen,
  .break-tip__next { transition: none; }
  .break-tip,
  body.zen #timer-card > * { animation: none; }
}

@media (forced-colors: active) {
  .btn-zen,
  .break-tip,
  .break-tip__next { border: 1px solid CanvasText; }
}

@media print {
  .btn-zen, .break-tip { display: none !important; }
}
