/**
 * Self-contained styles for the interactive app-blocks (breathing pacer,
 * meditation timer, pelvic trainer, partner deck). Everything is namespaced
 * under the block root class so it is collision-proof on any host site, and
 * every colour/where sensible resolves a theme design-token with a calm
 * paper/ink fallback, so the tools look intentional on a bare theme too.
 *
 * Published next to the static site by App\Support\Blocks\AppToolRender.
 */

/* ── Shared shell ──────────────────────────────────────────────────────── */
.rr-app-tool {
  --rr-paper: var(--color-bg-alt, #f4f0e7);
  --rr-ink: var(--color-text, #202622);
  --rr-muted: var(--color-text-muted, #5b635e);
  --rr-accent: var(--color-primary, #b4532a);
  --rr-deep: #183129;
  --rr-line: var(--color-border, #e2dccf);
  box-sizing: border-box;
  background: var(--rr-paper);
  color: var(--rr-ink);
  border: 1px solid var(--rr-line);
  border-radius: 18px;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  max-width: 720px;
  margin: 0 auto;
  font-family: var(--font-body, system-ui, -apple-system, sans-serif);
  line-height: 1.5;
}
.rr-app-tool *, .rr-app-tool *::before, .rr-app-tool *::after { box-sizing: border-box; }
.rr-app-tool h2 {
  font-family: var(--font-heading, inherit);
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  line-height: 1.15;
  margin: 0.1em 0 0.3em;
  color: var(--rr-ink);
}
.rr-app-tool .eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rr-muted);
  margin: 0 0 0.4rem;
}
.rr-app-tool p { margin: 0 0 0.6rem; color: var(--rr-muted); }

/* Buttons */
.rr-app-tool .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.55em 1.25em;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease, background 0.2s ease;
}
.rr-app-tool .button:disabled { opacity: 0.45; cursor: not-allowed; }
.rr-app-tool .button:not(:disabled):active { transform: translateY(1px); }
.rr-app-tool .button-ink { background: var(--rr-deep); color: #f4f0e7; }
.rr-app-tool .button-ink:not(:disabled):hover { background: #21463a; }
.rr-app-tool .button-quiet { background: transparent; color: var(--rr-ink); border-color: var(--rr-line); }
.rr-app-tool .button-quiet:not(:disabled):hover { background: #ffffff66; }
.rr-app-tool .tool-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.rr-app-tool .tool-actions span { color: var(--rr-muted); font-variant-numeric: tabular-nums; }
.rr-app-tool .tool-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }

/* ── Breathing pacer ───────────────────────────────────────────────────── */
.rr-breath-tool .sound-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--rr-muted); white-space: nowrap;
}
.rr-breath-tool .pacer-stage {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  padding: 0.75rem 0 0.9rem;
}
.rr-breath-tool .breath-orb {
  position: relative;
  width: clamp(120px, 30vw, 160px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 42%, #ffffff, var(--rr-paper) 70%);
  box-shadow: inset 0 0 0 1px var(--rr-line), 0 12px 40px rgba(24, 49, 41, 0.12);
  transform: scale(0.72);
  transition: transform var(--phase-time, 3s) ease-in-out;
}
.rr-breath-tool .breath-orb.orb-in { transform: scale(1); }
.rr-breath-tool .breath-orb.orb-out { transform: scale(0.72); }
.rr-breath-tool .orb-progress {
  position: absolute; inset: -10px; border-radius: 50%;
  background: conic-gradient(var(--rr-accent) var(--progress, 0deg), transparent 0deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  opacity: 0.9;
}
.rr-breath-tool .orb-copy { text-align: center; }
.rr-breath-tool .orb-copy strong { display: block; font-size: 1.05rem; color: var(--rr-ink); }
.rr-breath-tool .orb-copy span { font-size: 1.6rem; font-variant-numeric: tabular-nums; color: var(--rr-deep); }
.rr-breath-tool .round-readout { display: flex; gap: 1.25rem; font-size: 0.8rem; color: var(--rr-muted); }
.rr-breath-tool .phase-settings {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem;
}
.rr-breath-tool .phase-settings > label {
  display: block; background: #ffffffaa; border: 1px solid var(--rr-line);
  border-radius: 12px; padding: 0.55rem 0.65rem;
}
.rr-breath-tool .phase-settings > label > span {
  display: block; font-size: 0.78rem; letter-spacing: 0.04em; color: var(--rr-muted); margin-bottom: 0.3rem;
}
.rr-breath-tool .stepper { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.rr-breath-tool .stepper button {
  width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--rr-line);
  background: var(--rr-paper); color: var(--rr-ink); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.rr-breath-tool .stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.rr-breath-tool .stepper output { font-variant-numeric: tabular-nums; font-weight: 600; }
.rr-breath-tool input[type="range"] { width: 100%; margin-top: 0.4rem; accent-color: var(--rr-accent); }
.rr-breath-tool input[type="range"]:disabled { opacity: 0.5; }
.rr-breath-tool .round-settings { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.75rem; }
.rr-breath-tool .round-settings span { font-size: 0.8rem; color: var(--rr-muted); margin-right: 0.25rem; }
.rr-breath-tool .round-settings button {
  min-width: 2.2rem; padding: 0.35rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--rr-line); background: transparent; color: var(--rr-ink); cursor: pointer;
}
.rr-breath-tool .round-settings button.selected { background: var(--rr-deep); color: #f4f0e7; border-color: var(--rr-deep); }
.rr-breath-tool .expert-warning {
  margin: 0.75rem 0; padding: 0.7rem 0.9rem; border-radius: 12px;
  background: #b4532a14; border: 1px solid #b4532a55; color: var(--rr-ink);
}
.rr-breath-tool .expert-warning strong { display: block; margin-bottom: 0.3rem; }
.rr-breath-tool .expert-warning label { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.85rem; margin-top: 0.5rem; }

/* Desktop: stage on the left, settings on the right — the whole tool fits a
   15" laptop viewport (browser chrome + taskbar included) without scrolling. */
@media (min-width: 700px) {
  .rr-breath-tool { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); grid-auto-rows: min-content; column-gap: 1.5rem; align-items: start; }
  .rr-breath-tool .tool-heading { grid-column: 1 / -1; }
  .rr-breath-tool .pacer-stage { grid-row: span 3; align-self: center; padding: 0; }
  .rr-breath-tool .phase-settings { grid-template-columns: 1fr 1fr; }
  .rr-breath-tool .expert-warning { grid-column: 1 / -1; margin: 0.75rem 0 0; }
}

/* ── Meditation timer ──────────────────────────────────────────────────── */
.rr-meditation-tool .meditation-timer-panel { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.rr-meditation-tool .zen-ring {
  position: relative; width: clamp(130px, 34vw, 170px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  background:
    radial-gradient(farthest-side, var(--rr-paper) calc(100% - 14px), transparent calc(100% - 13px)),
    conic-gradient(var(--rr-deep) var(--timer-progress, 0deg), var(--rr-line) 0deg);
}
.rr-meditation-tool .zen-ring strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; color: var(--rr-deep); }
.rr-meditation-tool .zen-ring span { display: block; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--rr-muted); }
.rr-meditation-tool .time-presets { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }
.rr-meditation-tool .time-presets button {
  min-width: 2.6rem; padding: 0.4rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--rr-line); background: transparent; color: var(--rr-ink); cursor: pointer;
}
.rr-meditation-tool .time-presets button.selected { background: var(--rr-deep); color: #f4f0e7; border-color: var(--rr-deep); }
.rr-meditation-tool .journey-panel { width: 100%; margin-top: 1rem; border-top: 1px solid var(--rr-line); padding-top: 0.85rem; }
.rr-meditation-tool .journey-panel select {
  width: 100%; padding: 0.45rem 0.6rem; border-radius: 10px; border: 1px solid var(--rr-line);
  background: #fff; color: var(--rr-ink); font: inherit; margin-bottom: 0.6rem;
}
.rr-meditation-tool .journey-days { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.rr-meditation-tool .journey-days li { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; border: 1px solid var(--rr-line); border-radius: 12px; background: #ffffffaa; }
.rr-meditation-tool .journey-days li.done { background: #18312912; border-color: #18312955; }
.rr-meditation-tool .day-check {
  flex: 0 0 auto; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  border: 1px solid var(--rr-line); background: var(--rr-paper); color: var(--rr-deep);
  cursor: pointer; display: grid; place-items: center; font-weight: 600;
}
.rr-meditation-tool .journey-days li.done .day-check { background: var(--rr-deep); color: #f4f0e7; border-color: var(--rr-deep); }
.rr-meditation-tool .journey-days li > div { flex: 1 1 auto; }
.rr-meditation-tool .journey-days strong { display: block; font-size: 0.92rem; color: var(--rr-ink); }
.rr-meditation-tool .journey-days small { color: var(--rr-muted); font-size: 0.78rem; }
.rr-meditation-tool .journey-start {
  flex: 0 0 auto; padding: 0.4rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--rr-line); background: transparent; color: var(--rr-ink); cursor: pointer; font-size: 0.8rem;
}

/* Desktop: timer left, journeys right — one-screen tall on a 15" laptop. */
@media (min-width: 700px) {
  .rr-meditation-tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-auto-rows: min-content; column-gap: 1.5rem; align-items: start; }
  .rr-meditation-tool .tool-heading { grid-column: 1 / -1; }
  .rr-meditation-tool .meditation-timer-panel { align-self: center; }
  .rr-meditation-tool .journey-panel { margin-top: 0; border-top: none; padding-top: 0; border-left: 1px solid var(--rr-line); padding-left: 1.25rem; }
  /* Without journeys the timer takes the full width again. */
  .rr-meditation-tool .meditation-timer-panel:last-child { grid-column: 1 / -1; }
}

/* ── Pelvic coordination ───────────────────────────────────────────────── */
.rr-pelvic-tool { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
@media (min-width: 560px) { .rr-pelvic-tool { grid-template-columns: 150px minmax(0, 1fr); align-items: center; } }
.rr-pelvic-tool .pelvic-visual {
  position: relative; width: 130px; height: 130px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #fff, var(--rr-paper) 72%);
  box-shadow: inset 0 0 0 1px var(--rr-line); display: grid; place-items: center;
}
.rr-pelvic-tool .pelvic-visual span {
  position: absolute; left: 50%; top: 50%; border-radius: 50%;
  background: var(--rr-deep); opacity: 0.16; transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease, opacity 0.6s ease, background 0.6s ease;
}
.rr-pelvic-tool .pelvic-visual span:nth-child(1) { width: 108px; height: 108px; }
.rr-pelvic-tool .pelvic-visual span:nth-child(2) { width: 72px; height: 72px; opacity: 0.24; }
.rr-pelvic-tool .pelvic-visual span:nth-child(3) { width: 36px; height: 36px; opacity: 0.5; background: var(--rr-accent); }
.rr-pelvic-tool .pelvic-visual[data-phase="1"] span:nth-child(3) { width: 54px; height: 54px; }
.rr-pelvic-tool .pelvic-visual[data-phase="2"] span:nth-child(3) { width: 22px; height: 22px; opacity: 0.85; }
.rr-pelvic-tool .pelvic-visual[data-phase="3"] span:nth-child(3) { width: 46px; height: 46px; opacity: 0.35; }
.rr-pelvic-tool .pelvic-copy strong { display: block; margin: 0.5rem 0 0; font-size: 1.1rem; color: var(--rr-deep); font-variant-numeric: tabular-nums; }
.rr-pelvic-tool .pelvic-copy strong small { color: var(--rr-muted); font-weight: 400; font-size: 0.8rem; }

/* ── Partner card deck ─────────────────────────────────────────────────── */
.rr-partner-deck { position: relative; }
.rr-partner-deck .deck-number {
  font-size: 2.4rem; font-weight: 700; line-height: 1; color: var(--rr-accent);
  font-variant-numeric: tabular-nums; margin-bottom: 0.4rem;
}
