/*
 * TFM Mantra Repeater
 * /wp-content/themes/blocksy/css/tfm-mantra-repeater.css
 *
 * Styles for the repeater module (see php/tfm-mantra-repeater.php). All
 * classes start with tfm-mr- so nothing collides with the rest of the page.
 * The markup is built by js/tfm-mantra-repeater.js.
 *
 * Colors follow the area palette (--area-accent etc.) and fall back to the
 * Town Square turquoise when the module runs outside an area page.
 * Button colors are !important because the theme styles <button> globally.
 *
 * ── STRUCTURE ────────────────────────────────────────────────
 *  1. Variables, popup overlay, inline box
 *  2. Background layers (spiral, halo)
 *  3. Top bar: rhythm tabs + close
 *  4. Input field (own mantra)
 *  5. Stage: mantra, breath ring, bell ring, echo lines, phase, done
 *  6. Controls
 *  7. Responsive + reduced motion
 */

/* ============================================================
   1. VARIABLES, POPUP OVERLAY, INLINE BOX
   ============================================================ */

.tfm-mr {
  --mr-accent: var(--area-accent, #40d9b0);
  --mr-soft: var(--area-accent-soft, #80e8cc);
  --mr-glow: var(--area-accent-glow, rgba(64, 217, 176, .35));
  --mr-ink: var(--ink, #f6f1ea);
  --mr-text: var(--body-text, #e4ddf0);
  --mr-muted: var(--muted, #b6afc7);

  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  color: var(--mr-text);
  font-family: 'Jost', sans-serif;
  -webkit-font-smoothing: antialiased;
}
.tfm-mr *,
.tfm-mr *::before,
.tfm-mr *::after {
  box-sizing: border-box;
}

/* Popup: full screen layer above the page. */
.tfm-mr-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background:
    radial-gradient(1000px 700px at 50% 40%, rgba(40, 30, 80, .55), transparent 70%),
    rgba(6, 8, 16, .97);
}
.tfm-mr-overlay[hidden] {
  display: none;
}
.tfm-mr--popup {
  height: 100%;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 18px calc(18px + env(safe-area-inset-bottom, 0px));
}

/* Inline: a box inside the page (own repeater page). Height: set a minimum
   height on the Elementor container if you want more room than this. */
.tfm-mr--inline {
  min-height: 640px;
  height: 100%;
  padding: 22px 20px 24px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--mr-accent) 22%, transparent);
  background:
    radial-gradient(800px 500px at 50% 40%, rgba(40, 30, 80, .5), transparent 70%),
    rgba(10, 10, 24, .82);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .75), 0 0 40px -18px var(--mr-glow);
}

.tfm-mr-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ============================================================
   2. BACKGROUND LAYERS
   ============================================================ */

.tfm-mr-spiral {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}
.tfm-mr[data-mode="spiral"] .tfm-mr-spiral {
  opacity: 1;
}
.tfm-mr-halo {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 70vmin;
  height: 70vmin;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--mr-accent) 16%, transparent), transparent 65%);
  pointer-events: none;
}

/* ============================================================
   3. TOP BAR: RHYTHM TABS + CLOSE
   ============================================================ */

.tfm-mr-top {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: center;
  padding: 0 56px;
}
.tfm-mr--inline .tfm-mr-top {
  padding: 0;
}
.tfm-mr-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid color-mix(in srgb, var(--mr-accent) 20%, transparent);
}
.tfm-mr .tfm-mr-tab {
  min-height: 38px;
  padding: 8px 14px;
  border: 0 !important;
  border-radius: 999px;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  font-family: 'Jost', sans-serif !important;
  font-size: .7rem !important;
  font-weight: 600 !important;
  letter-spacing: .12em !important;
  line-height: 1.2 !important;
  text-transform: uppercase !important;
  color: var(--mr-muted) !important;
  transition: background .2s ease, color .2s ease;
}
.tfm-mr .tfm-mr-tab:hover {
  color: var(--mr-ink) !important;
}
.tfm-mr .tfm-mr-tab[aria-selected="true"] {
  background: color-mix(in srgb, var(--mr-accent) 24%, transparent) !important;
  color: var(--mr-ink) !important;
}
.tfm-mr .tfm-mr-close {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--mr-accent) 30%, transparent) !important;
  background: rgba(255, 255, 255, .04) !important;
  box-shadow: none !important;
  color: var(--mr-ink) !important;
  font-family: 'Jost', sans-serif !important;
  font-size: 1.5rem !important;
  line-height: 1 !important;
}
.tfm-mr .tfm-mr-close:hover {
  border-color: var(--mr-accent) !important;
}
.tfm-mr--inline .tfm-mr-close,
.tfm-mr--inline .tfm-mr-done-close {
  display: none !important;
}
.tfm-mr-desc {
  position: relative;
  z-index: 3;
  margin: 12px auto 0;
  max-width: 560px;
  text-align: center;
  font-family: 'Cormorant Garamond', serif !important;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--mr-muted);
}

/* ============================================================
   4. INPUT FIELD (own mantra)
   ============================================================ */

.tfm-mr-input {
  position: relative;
  z-index: 3;
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 640px;
  margin: 18px auto 0;
}
.tfm-mr-input[hidden] {
  display: none;
}
.tfm-mr .tfm-mr-input input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 10px 16px !important;
  border-radius: 10px !important;
  border: 1px solid color-mix(in srgb, var(--mr-accent) 32%, transparent) !important;
  background: rgba(255, 255, 255, .05) !important;
  box-shadow: none !important;
  color: var(--mr-ink) !important;
  font-family: 'Cormorant Garamond', serif !important;
  font-style: italic !important;
  font-size: 1.2rem !important;
}
.tfm-mr .tfm-mr-input input::placeholder {
  color: var(--mr-muted);
  opacity: .8;
}
.tfm-mr .tfm-mr-input input:focus {
  outline: none;
  border-color: var(--mr-accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mr-accent) 22%, transparent) !important;
}
.tfm-mr-hint {
  position: relative;
  z-index: 3;
  margin: 8px 0 0;
  text-align: center;
  font-size: .8rem;
  color: #f0a0a0;
}
.tfm-mr-hint[hidden] {
  display: none;
}

/* Shared look of the text buttons (Start, Repeat again, Close). */
.tfm-mr .tfm-mr-btn {
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--mr-accent) 40%, transparent) !important;
  background: color-mix(in srgb, var(--mr-accent) 12%, transparent) !important;
  box-shadow: none !important;
  font-family: 'Jost', sans-serif !important;
  font-size: .74rem !important;
  font-weight: 600 !important;
  letter-spacing: .12em !important;
  line-height: 1.2 !important;
  text-transform: uppercase !important;
  color: var(--mr-soft) !important;
  transition: background .2s ease, border-color .2s ease;
}
.tfm-mr .tfm-mr-btn:hover {
  background: color-mix(in srgb, var(--mr-accent) 24%, transparent) !important;
  border-color: var(--mr-accent) !important;
}

/* ============================================================
   5. STAGE
   ============================================================ */

.tfm-mr-stage {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tfm-mr-mantra {
  position: relative;
  z-index: 2;
  margin: 0;
  max-width: min(760px, 90%);
  text-align: center;
  font-family: 'Cormorant Garamond', serif !important;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.7rem, 4.6vw, 3rem);
  line-height: 1.35;
  color: var(--mr-ink);
  text-shadow: 0 0 28px color-mix(in srgb, var(--mr-accent) 35%, transparent);
  transition: opacity .9s ease, transform 1.4s ease, text-shadow 1s ease;
}
.tfm-mr[data-mode="spiral"] .tfm-mr-mantra {
  transition: opacity 1.2s ease, transform 3.6s ease;
  text-shadow: 0 0 22px rgba(0, 0, 0, .9), 0 0 40px color-mix(in srgb, var(--mr-accent) 40%, transparent);
}
.tfm-mr[data-mode="echo"] .tfm-mr-mantra {
  display: none;
}
.tfm-mr-mantra.is-glowing,
.tfm-mr-mantra.is-bell {
  text-shadow: 0 0 36px color-mix(in srgb, var(--mr-accent) 80%, transparent);
}
/* No mantra yet (own page before Start). */
.tfm-mr-mantra.is-placeholder {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: var(--mr-muted);
  text-shadow: none;
}
.tfm-mr-mantra .tfm-mr-w {
  display: inline-block;
  opacity: 0;
  filter: blur(8px);
  transform: translateY(8px);
  transition: opacity .7s ease, filter .7s ease, transform .7s ease;
}
.tfm-mr-mantra .tfm-mr-w.is-on {
  opacity: 1;
  filter: blur(0);
  transform: none;
}

.tfm-mr-ring {
  position: absolute;
  width: min(58vmin, 440px);
  height: min(58vmin, 440px);
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--mr-soft) 50%, transparent);
  box-shadow: 0 0 70px color-mix(in srgb, var(--mr-accent) 22%, transparent), inset 0 0 70px color-mix(in srgb, var(--mr-accent) 14%, transparent);
  transform: scale(.62);
  opacity: 0;
  transition: transform 4s ease-in-out, opacity .8s ease;
  pointer-events: none;
}
.tfm-mr[data-mode="breath"] .tfm-mr-ring {
  opacity: 1;
}

.tfm-mr-timer {
  position: absolute;
  width: min(62vmin, 460px);
  height: min(62vmin, 460px);
  transform: rotate(-90deg);
  opacity: 0;
  transition: opacity .6s ease;
  pointer-events: none;
}
.tfm-mr[data-mode="timer"] .tfm-mr-timer {
  opacity: 1;
}
.tfm-mr-timer circle {
  fill: none;
  stroke-width: 2;
}
.tfm-mr-track {
  stroke: rgba(255, 255, 255, .08);
}
.tfm-mr-bar {
  stroke: var(--mr-soft);
  stroke-linecap: round;
  stroke-dasharray: 578.05;
  stroke-dashoffset: 0;
}

.tfm-mr-echo {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}
.tfm-mr[data-mode="echo"] .tfm-mr-echo {
  display: block;
}
.tfm-mr-echo-line {
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(760px, 90%);
  margin: 0;
  translate: -50% -50%;
  text-align: center;
  font-family: 'Cormorant Garamond', serif !important;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.6rem, 4.2vw, 2.7rem);
  line-height: 1.3;
  color: var(--mr-ink);
  text-shadow: 0 0 26px color-mix(in srgb, var(--mr-accent) 35%, transparent);
  transition: transform 1.4s ease, opacity 1.4s ease, filter 1.4s ease;
}

.tfm-mr-phase {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 6%;
  min-height: 1em;
  margin: 0;
  text-align: center;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--mr-soft);
}

.tfm-mr-done {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  background: radial-gradient(circle, rgba(10, 13, 26, .6), rgba(10, 13, 26, .92));
}
.tfm-mr-done[hidden] {
  display: none;
}
.tfm-mr-done strong {
  font-family: 'Cormorant Garamond', serif !important;
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: var(--mr-ink);
}
.tfm-mr-done-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* ============================================================
   6. CONTROLS
   ============================================================ */

.tfm-mr-controls {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.tfm-mr .tfm-mr-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--mr-accent) !important;
  background: color-mix(in srgb, var(--mr-accent) 22%, transparent) !important;
  box-shadow: 0 0 28px -6px var(--mr-glow) !important;
  color: var(--mr-ink) !important;
}
.tfm-mr .tfm-mr-play:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.tfm-mr .tfm-mr-play svg {
  width: 24px;
  height: 24px;
}
.tfm-mr-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 18px;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mr-muted);
}
.tfm-mr-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--mr-accent) 22%, transparent);
}
.tfm-mr .tfm-mr-seg button {
  min-height: 32px;
  padding: 6px 12px;
  border: 0 !important;
  border-radius: 999px;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  font-family: 'Jost', sans-serif !important;
  font-size: .68rem !important;
  font-weight: 600 !important;
  letter-spacing: .1em !important;
  line-height: 1.2 !important;
  text-transform: uppercase !important;
  color: var(--mr-muted) !important;
}
.tfm-mr .tfm-mr-seg button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--mr-accent) 22%, transparent) !important;
  color: var(--mr-ink) !important;
}
.tfm-mr-goal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
/* The theme styles <label> elements itself, so the label's font is forced
   to match the "Repetition" text next to it. */
.tfm-mr .tfm-mr-goal {
  margin: 0 !important;
  font-family: 'Jost', sans-serif !important;
  font-size: .72rem !important;
  font-style: normal !important;
  font-weight: 400 !important;
  letter-spacing: .1em !important;
  line-height: 1.2 !important;
  text-transform: uppercase !important;
  color: var(--mr-muted) !important;
}
.tfm-mr .tfm-mr-goal select {
  min-height: 34px;
  margin: 0;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  border: 1px solid color-mix(in srgb, var(--mr-accent) 30%, transparent) !important;
  background: #12122a !important;
  box-shadow: none !important;
  color: var(--mr-ink) !important;
  font-family: 'Jost', sans-serif !important;
  font-size: .75rem !important;
}
.tfm-mr-count {
  font-weight: 600;
  color: var(--mr-ink);
}

.tfm-mr button:focus-visible,
.tfm-mr select:focus-visible {
  outline: 2px solid var(--mr-soft);
  outline-offset: 2px;
}

/* ============================================================
   7. RESPONSIVE + REDUCED MOTION
   ============================================================ */

@media (max-width: 700px) {
  .tfm-mr-top {
    justify-content: flex-start;
    padding: 0 50px 0 0;
  }
  .tfm-mr--inline .tfm-mr-top {
    justify-content: center;
    padding: 0;
  }
  /* The five modes wrap into two rows on phones; a softer radius than the
     pill keeps the two-row frame from looking squeezed. */
  .tfm-mr-tabs {
    border-radius: 20px;
  }
  .tfm-mr .tfm-mr-tab {
    min-height: 40px;
    padding: 8px 12px;
    font-size: .72rem !important;
    letter-spacing: .08em !important;
  }
  .tfm-mr-input {
    flex-direction: column;
  }
  .tfm-mr--inline {
    min-height: 600px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tfm-mr-mantra .tfm-mr-w {
    filter: none;
    transform: none;
  }
  .tfm-mr-echo-line {
    filter: none !important;
  }
  .tfm-mr-ring {
    transition: opacity .8s ease !important;
  }
}