/* ============================================================
   Morning Messages 2.3 — Fully Responsive CSS
   No Divi dependencies. BEM-style naming. Mobile-first mindset.
   ============================================================ */

/* ============================================================
   PAGE LAYOUT — two-column: intro (left) + app card (right)
   ============================================================ */
.mm-page {
  display: flex;
  gap: 48px;
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 24px;
  align-items: flex-start;
  font-family: 'Poppins', sans-serif;
}

/* Left column: intro text */
.mm-page__intro {
  flex: 1 1 300px;
  min-width: 220px;
  padding-top: 40px;
  color: #2d2f39;
}
.mm-page__title {
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 700;
  margin: 0 0 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.mm-page__intro p {
  font-size: clamp(14px, 1.6vw, 15px);
  line-height: 1.7;
  color: #555;
  margin: 0 0 14px;
}
.mm-page__intro h2,
.mm-page__intro h3 {
  font-size: clamp(16px, 1.8vw, 18px);
  font-weight: 600;
  margin: 24px 0 8px;
  color: #2d2f39;
}

/* Right column: app in a card */
.mm-page__app {
  flex: 0 0 auto;
  width: 580px;
  max-width: 100%;
  background: #fff;
  border-radius: 20px;
  box-shadow:
    0 4px 6px rgba(0,0,0,.04),
    0 12px 40px rgba(102,126,234,.12);
  padding: 24px;
  margin-top: 40px;
}

/* Tablet: stack to single column */
@media (max-width: 960px) {
  .mm-page {
    flex-direction: column;
    gap: 20px;
    padding: 0 16px;
    margin: 24px auto;
  }
  .mm-page__intro { padding-top: 16px; }
  .mm-page__app {
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
  }
}

/* Phone: reduce card padding */
@media (max-width: 480px) {
  .mm-page { padding: 0 10px; margin: 16px auto; }
  .mm-page__app {
    padding: 14px;
    border-radius: 16px;
    box-shadow:
      0 2px 4px rgba(0,0,0,.04),
      0 8px 24px rgba(102,126,234,.1);
  }
}


/* ============================================================
   APP CORE
   ============================================================ */

/* --- Reset & base --- */
.mm, .mm * { box-sizing: border-box; }

.mm {
  --purple:  #667eea;
  --violet:  #764ba2;
  --bg-soft: #eef1ff;
  --text:    #2d2f39;
  --radius:  12px;
  --radius-pill: 40px;
  --transition: .25s ease;

  max-width: 600px;
  margin: 0 auto;
  padding: 12px;
  font-family: 'Poppins', sans-serif;
  text-align: center;
  color: var(--text);
}

/* --- Canvas / image area ---
   Uses aspect-ratio so it scales with width.
   The 4:5 ratio (portrait) works well for the quote card images.
   A max-height cap prevents it being too tall on wide screens.
   ----------------------------------------------------------- */
.mm__canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 620px;
  margin: 16px auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, rgba(102,126,234,.75), rgba(118,75,162,.75)),
              var(--welcome-bg) center/cover no-repeat;
}

.mm--has-quote .mm__canvas {
  background: #fff;
}

.mm__canvas > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .35s ease;
}

.mm__canvas > img.show { opacity: 1; }

/* --- Welcome overlay --- */
.mm__welcome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 20px 20%;
  color: #fff;
  text-align: center;
  transition: opacity .35s ease;
}

.mm--has-quote .mm__welcome { opacity: 0; pointer-events: none; }

.mm__welcome h1 {
  font-size: clamp(22px, 5vw, 44px);
  font-weight: 700;
  margin: 0 0 8px;
}
.mm__welcome p  { font-size: clamp(14px, 3vw, 22px); margin: 0 0 4px; }
.mm__welcome small { font-size: clamp(12px, 2.5vw, 1.1em); font-style: italic; }

/* --- Back button --- */
.mm__back {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.24);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  color: var(--violet);
  z-index: 2;
}
.mm__back:hover { background: rgba(255,255,255,.36); transform: translateY(-2px); }
.mm--welcome .mm__back,
.mm--fullscreen .mm__back { display: none; }

/* --- Action buttons --- */
.mm__actions { margin-top: 4px; }

.mm__btn {
  border: none;
  padding: 14px 26px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-weight: 600;
  font-size: clamp(14px, 2vw, 15px);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 6px 16px rgba(0,0,0,.22);
  /* Ensure touch-friendly minimum size */
  min-height: 48px;
}
.mm__btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.28); }

.mm__btn--primary {
  background: linear-gradient(135deg, var(--purple), var(--violet));
  color: #fff;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 12px;
  display: block;
}

.mm__btn--secondary {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid rgba(102,126,234,.3);
}
.mm__btn--secondary:disabled {
  opacity: .55;
  pointer-events: none;
}

.mm__row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.mm__hint { font-size: clamp(11px, 1.5vw, 12px); color: #666; margin-top: 8px; }

/* --- Favourites --- */
.mm__favs { margin-top: 12px; }
.mm__favs summary {
  cursor: pointer;
  font-weight: 600;
  padding: 8px;
  /* Touch-friendly tap target */
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mm__favs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.mm__fav-card {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  cursor: pointer;
  transition: outline var(--transition);
}
.mm__fav-card:hover { outline: 2px solid rgba(102,126,234,.35); outline-offset: 2px; }
.mm__fav-card img { width: 100%; display: block; border-radius: 6px; }

.mm__fav-actions { display: flex; gap: 6px; margin: 6px; justify-content: space-between; }
.mm__fav-actions button {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  /* Touch-friendly minimum */
  min-height: 36px;
}
.mm__fav-actions .view  { background: var(--purple); color: #fff; }
.mm__fav-actions .remove { background: #e53935; color: #fff; }


/* ============================================================
   MEDITATION MODAL — fullscreen immersive
   ============================================================ */
.mm-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 99999;
}
.mm-modal.open { display: block; }

/* Fullscreen background image */
.mm-modal__bg {
  position: absolute;
  inset: 0;
  background: #111 center/cover no-repeat;
  transition: opacity .6s ease;
}
.mm-modal__bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.25);
}

/* Floating controls panel — bottom-right, subtle */
.mm-modal__controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 280px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #fff;
  opacity: .45;
  transition: opacity .4s ease;
  z-index: 2;
}
.mm-modal__controls:hover,
.mm-modal__controls.mm-modal__controls--active { opacity: 1; }

.mm-modal__controls h4 { margin: 0; font-size: 14px; text-align: center; color: rgba(255,255,255,.85); }

/* Close button — top-right corner */
.mm-modal__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background .25s ease, transform .25s ease;
}
.mm-modal__close:hover { background: rgba(0,0,0,.7); transform: scale(1.08); }

/* --- Player --- */
.mm-player {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.mm-player button {
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: background .2s ease;
  /* Touch-friendly minimum */
  min-width: 48px;
  min-height: 48px;
}
.mm-player button:hover { background: rgba(255,255,255,.28); }

/* --- Sliders --- */
.mm-slider-group label { font-size: 12px; font-weight: 600; display: block; margin-bottom: 2px; color: rgba(255,255,255,.7); }

.mm-slider {
  position: relative;
  width: 100%;
  height: 18px;
  background: rgba(255,255,255,.18);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  /* Taller touch target — the visible bar is 18px but add padding */
  padding: 0;
}

.mm-slider__fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  border-radius: 10px;
  transition: width .1s linear;
}
.mm-slider__fill--progress { background: linear-gradient(90deg, #4CAF50, #45a049); }
.mm-slider__fill--volume   { background: linear-gradient(90deg, var(--purple), var(--violet)); }
.mm-slider__fill--bg       { background: linear-gradient(90deg, #FF9800, #F57C00); }

.mm-time { font-size: 11px; color: rgba(255,255,255,.6); margin-top: 2px; }

/* --- Tips --- */
.mm__chip {
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  color: rgba(255,255,255,.8);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background .2s ease;
  min-height: 40px;
}
.mm__chip:hover { background: rgba(255,255,255,.22); }

.mm-tips {
  background: rgba(0,0,0,.5);
  color: rgba(255,255,255,.85);
  padding: 10px;
  border-radius: 8px;
  animation: mm-slideUp .25s ease;
}
.mm-tips h5 { margin: 0 0 6px; font-size: 13px; }
.mm-tips p  { margin: 3px 0; font-size: 12px; }

@keyframes mm-slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* --- Tablet landscape (<=960px) --- */
@media (max-width: 960px) {
  .mm { padding: 10px; }
  .mm__canvas { max-height: 560px; }
}

/* --- Tablet portrait / large phone (<=768px) --- */
@media (max-width: 768px) {
  .mm__canvas { max-height: 500px; }

  .mm__btn--primary { max-width: 100%; }
  .mm__row .mm__btn--secondary { flex: 1 1 45%; }

  .mm__favs-grid { grid-template-columns: repeat(2, 1fr); }

  /* Modal: controls wider, centred at bottom */
  .mm-modal__controls {
    width: calc(100% - 40px);
    left: 20px;
    right: 20px;
    bottom: 20px;
    opacity: .65;
  }
}

/* --- Phone (<=480px) --- */
@media (max-width: 480px) {
  .mm {
    padding: 6px;
  }

  .mm__canvas {
    margin: 10px auto;
    border-radius: 10px;
    /* On small phones, let the canvas breathe —
       cap height to 70vh so buttons stay visible */
    max-height: 70vh;
  }

  .mm__welcome {
    padding: 0 14px 16%;
  }

  .mm__back {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
  }

  .mm__actions { margin-top: 0; }

  .mm__btn {
    padding: 12px 20px;
    font-size: 14px;
  }
  .mm__btn--primary {
    max-width: 100%;
    margin-bottom: 10px;
  }
  .mm__row {
    gap: 8px;
  }
  .mm__row .mm__btn--secondary {
    flex: 1 1 45%;
    padding: 12px 10px;
    font-size: 13px;
  }

  .mm__hint { font-size: 11px; margin-top: 6px; }

  /* Favourites — 2 column, smaller gap */
  .mm__favs-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  /* Modal: controls take full width, always visible */
  .mm-modal__controls {
    width: calc(100% - 24px);
    left: 12px;
    right: 12px;
    bottom: 12px;
    border-radius: 14px;
    padding: 14px;
    gap: 10px;
    opacity: .7;
  }
  .mm-modal__controls:hover,
  .mm-modal__controls.mm-modal__controls--active { opacity: 1; }

  .mm-modal__close {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
  }

  .mm-player button {
    padding: 10px 14px;
    min-width: 44px;
    min-height: 44px;
  }

  .mm-slider { height: 20px; }
}

/* --- Very small phones (<=360px, e.g. iPhone SE) --- */
@media (max-width: 360px) {
  .mm__canvas {
    max-height: 65vh;
    border-radius: 8px;
  }

  .mm__welcome {
    padding: 0 10px 14%;
  }
  .mm__welcome h1 { font-size: 20px; }
  .mm__welcome p  { font-size: 14px; }

  .mm__btn {
    padding: 11px 16px;
    font-size: 13px;
    min-height: 44px;
  }

  .mm__row .mm__btn--secondary {
    font-size: 12px;
    padding: 10px 8px;
  }

  .mm-modal__controls {
    padding: 12px;
    gap: 8px;
  }
  .mm-modal__controls h4 { font-size: 13px; }
  .mm-player button { font-size: 16px; padding: 8px 12px; }
}

/* --- Landscape phones: reduce canvas height, keep controls visible --- */
@media (max-height: 500px) and (orientation: landscape) {
  .mm__canvas {
    max-height: 55vh;
    aspect-ratio: 5 / 3;
  }

  .mm-modal__controls {
    bottom: 8px;
    right: 8px;
    width: 240px;
    padding: 10px;
    gap: 6px;
    opacity: .6;
  }
  .mm-modal__close {
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
}

/* --- Ensure safe areas on notched phones (iPhone X+) --- */
@supports (padding: env(safe-area-inset-bottom)) {
  .mm-modal__controls {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .mm-modal__close {
    top: calc(20px + env(safe-area-inset-top));
  }
}
