/* Native-app feel on phones: bottom tab bar, safe areas, touch behaviour. */

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

a, button, summary, select, label, [role="button"] {
  touch-action: manipulation;
}

/* iOS zooms the page when a focused field is under 16px. */
@media (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    font-size: max(16px, 1em);
  }
}

/* Keep controls clear of the notch when installed to the home screen. */
.navbar-glass {
  padding-top: env(safe-area-inset-top);
}
.practice-launch-header {
  padding-top: max(20px, env(safe-area-inset-top));
}

/* 44px minimum touch target for the menu button and footer links. */
.mobile-btn {
  width: 44px;
  height: 44px;
}
.footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    justify-content: space-around;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: rgba(250, 248, 245, 0.94);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(45, 55, 72, 0.1);
  }

  .bottom-nav-item {
    flex: 1;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 12px;
    color: #4A5568;
    font: 500 11px/1.2 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    text-decoration: none;
  }

  .bottom-nav-item.is-active {
    color: #74569b;
  }

  .bottom-nav-item:active {
    background: rgba(116, 86, 155, 0.1);
  }

  /* Room for the tab bar, and the site footer moves into the Me tab's flow. */
  body.has-bottom-nav main {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
  body.has-bottom-nav .footer-minimal {
    margin-top: 24px;
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

/* Installed app: behave like an app, not a page. */
@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: none;
  }
  .navbar-glass, .bottom-nav, .practice-launch-header {
    -webkit-user-select: none;
    user-select: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bottom-nav-item { transition: none; }
}

/* ── Phone: calm, compact inside pages ─────────────────────────── */
@media (max-width: 768px) {
  /* Footer: one wrapped row of small links instead of a three-screen stack. */
  .footer-minimal {
    margin-top: 16px;
    padding: 20px 20px 24px;
  }
  body.has-bottom-nav .footer-minimal {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }
  .footer-minimal .footer-branding,
  .footer-minimal .footer-verse,
  .footer-minimal .footer-links > span {
    display: none;
  }
  .footer-minimal .footer-links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 6px;
    margin: 0 0 8px;
  }
  .footer-minimal .footer-link {
    min-height: 40px;
    padding: 0 8px;
    font-size: 13px;
  }
  .footer-minimal .footer-bottom { padding-top: 8px; margin-top: 0; }
  .footer-minimal .footer-copyright {
    margin: 0;
    font-size: 12px;
    text-align: center;
    opacity: 0.7;
  }
}

/* Practice choices: easy rows instead of tall tiles. */
@media (max-width: 760px) {
  .practice-hub {
    width: calc(100% - 32px);
    padding: 12px 0 24px;
  }
  .practice-welcome { margin-bottom: 20px; }
  .practice-welcome h1 {
    font-size: 30px;
    letter-spacing: -0.8px;
    line-height: 1.15;
  }
  .practice-welcome > p:last-child { font-size: 16px; margin-top: 10px; }
  .practice-kicker { margin-bottom: 8px; }

  .practice-grid { gap: 12px; }
  .practice-choice {
    min-height: 0;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 20px;
    box-shadow: none;
  }
  .practice-choice:hover { transform: none; box-shadow: none; }
  .practice-choice:active { transform: scale(0.985); }
  .practice-choice-icon {
    flex: none;
    width: 52px;
    height: 52px;
    font-size: 26px;
    border-radius: 16px;
  }
  .practice-choice-copy { justify-content: center; }
  .practice-choice-copy strong { font-size: 20px; margin-bottom: 3px; }
  .practice-choice-copy small { font-size: 14px; line-height: 1.45; }
  .practice-choice-arrow {
    flex: none;
    margin: 0;
    font-size: 20px;
    opacity: 0.45;
  }
}

/* The empty-journal circle uses a gradient colour that was never defined, so its
   white icon sat on a white circle. */
.bg-gradient-to-br.from-sanctuary-purple.to-dawn-lavender {
  background: linear-gradient(135deg, #8b5cf6, #e9d8fd);
}

/* ── Phone density: less empty space, smaller type, no heavy effects ───── */
@media (max-width: 768px) {
  /* Custom page shells */
  .sanctuary-dashboard { min-height: auto; }
  .sanctuary-content { padding: 14px 16px 20px; }

  .journal-header { gap: 10px; margin-bottom: 14px; }
  .journal-title { font-size: 26px; line-height: 1.2; margin-bottom: 4px; }
  .journal-subtitle { font-size: 15px; }

  .greeting-card { padding: 18px 20px; border-radius: 18px; }
  .greeting-message { font-size: 22px; }

  .journal-entry-card,
  .scripture-sanctuary {
    padding: 18px;
    margin-bottom: 14px;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(45, 55, 72, 0.06);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    animation: none;
  }
  .scripture-icon { font-size: 30px; margin-bottom: 6px; animation: none; }
  .scripture-label { font-size: 12px; margin-bottom: 6px; }
  .scripture-reference { font-size: 22px; margin-bottom: 10px; }
  .scripture-instruction { font-size: 15px; line-height: 1.6; margin-bottom: 16px; }
  .spiritual-summary-box { padding: 16px; margin-top: 16px; }
  .empty-state-sanctuary { padding: 28px 18px; }
  .empty-state-icon { font-size: 44px; }

  .btn-new-entry {
    min-height: 48px;
    padding: 0 22px;
    background: #74569b;
    color: #fff;
    box-shadow: none;
    animation: none;
  }
  .btn-new-entry::before { display: none; }

  /* Tailwind-built pages (Journal list, forms): compress the scale. */
  main .min-h-screen { min-height: auto; }
  main .py-8 { padding-top: 14px; padding-bottom: 14px; }
  main .py-16 { padding-top: 28px; padding-bottom: 28px; }
  main .text-4xl { font-size: 26px; line-height: 1.2; }
  main .text-3xl { font-size: 22px; line-height: 1.25; }
  main .text-2xl { font-size: 19px; line-height: 1.3; }
  main .mb-8 { margin-bottom: 16px; }
  main .mb-6 { margin-bottom: 12px; }
  main .p-6 { padding: 16px; }
  main .p-8 { padding: 18px; }
  main .gap-6 { gap: 12px; }
  main .w-24.h-24 { width: 64px; height: 64px; margin-bottom: 12px; }
  main .w-12.h-12 { width: 30px; height: 30px; }
  main .shadow-lg { box-shadow: 0 1px 4px rgba(45, 55, 72, 0.08); }

  /* Title on the left, action on the right: let it wrap instead of squeezing. */
  main .flex.items-center.justify-between { flex-wrap: wrap; gap: 10px; }
  main [style*="justify-content: space-between"] { flex-wrap: wrap; gap: 12px; }

  /* Pages with inline spacing (Settings, forms). */
  main [style*="margin-bottom: 48px"] { margin-bottom: 18px !important; }
  main [style*="margin-bottom: 32px"] { margin-bottom: 14px !important; }
  main [style*="margin-bottom: 24px"] { margin-bottom: 12px !important; }
  main [style*="padding: 20px"] { padding: 16px !important; }
  main [style*="padding: 32px"] { padding: 18px !important; }
  main [style*="padding: 40px"] { padding: 18px !important; }
  main h2[style*="font-size: 24px"] { font-size: 19px !important; line-height: 1.3; }
  main ul[style*="line-height: 2"] { line-height: 1.8 !important; }
}

/* ── Fit the screen: Pray / Journal / Fast / Complete and Referrals ─────── */
@media (max-width: 768px) {
  /* The focus layout never got border-box sizing, so every width:100% button and
     card with padding overshot by its padding, and the flex body let <main> grow
     past the screen. */
  .focus-body,
  .focus-body *,
  .focus-body *::before,
  .focus-body *::after {
    box-sizing: border-box;
  }
  .focus-body { display: block; overflow-x: hidden; }
  .focus-main { width: 100%; min-width: 0; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
  .focus-header { padding: max(12px, env(safe-area-inset-top)) 16px 12px; }

  .focus-intro { margin-bottom: 18px; }
  .focus-intro h1,
  .focus-complete h1 { font-size: 32px; letter-spacing: -1px; line-height: 1.12; }
  .focus-intro > p,
  .focus-complete > p { font-size: 16px; line-height: 1.6; margin-top: 10px; }

  .focus-form,
  .focus-scripture,
  .focus-active-plan,
  .focus-existing {
    padding: 18px;
    border-radius: 20px;
    box-shadow: 0 1px 4px rgba(55, 43, 67, 0.08);
  }
  .focus-scripture, .focus-active-plan { margin-bottom: 14px; }

  /* A flex child with a text input must be allowed to shrink. */
  main .flex-1 { min-width: 0; }
  main input.flex-1 { width: 100%; }
}

/* ══ App shell: one calm, trustworthy look on every screen ══════════════
   Header, page and phone status bar all share the same warm cream, the
   header is separated only by a hairline, and the brand reads the same
   everywhere: dove mark + "The Quiet Place" in Literata. */
:root {
  --shell-bg: #f7f2e9;
  --shell-bg-glass: rgba(247, 242, 233, 0.88);
  --shell-ink: #292437;
  --shell-muted: #706a78;
  --shell-purple: #74569b;
  --shell-line: rgba(41, 36, 55, 0.08);
}

/* Same background behind the header and the page (no lavender corner,
   no white bar on cream). */
body.bg-sanctuary-cream,
.focus-body,
.practice-launch-body {
  background: var(--shell-bg);
}

/* Header surface */
.navbar-glass,
.practice-launch-header,
.focus-header {
  background: var(--shell-bg-glass);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--shell-line);
  box-shadow: none;
}

.practice-launch-header,
.focus-header {
  box-sizing: border-box;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  position: sticky;
  top: 0;
  z-index: 50;
}

.navbar-container {
  height: 64px;
}

/* Brand */
.navbar-logo,
.practice-launch-brand,
.focus-brand {
  align-items: center;
  display: flex;
  gap: 10px;
  text-decoration: none;
}

.logo-text,
.practice-launch-brand strong,
.focus-brand > span:last-child {
  color: var(--shell-ink);
  font-family: "Literata", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.focus-brand-mark {
  height: auto;
  width: auto;
}

/* Header actions: quiet, rounded, clearly tappable */
.focus-header-actions {
  gap: 8px;
}

.practice-account-link,
.focus-end-link,
.focus-quiet-button {
  align-items: center;
  border-radius: 999px;
  box-sizing: border-box;
  display: inline-flex;
  font: 600 13px/1 "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.practice-account-link,
.focus-end-link {
  background: transparent;
  border: 1px solid rgba(116, 86, 155, 0.28);
  color: var(--shell-purple);
}

.practice-account-link:hover,
.focus-end-link:hover {
  background: rgba(116, 86, 155, 0.08);
}

.focus-quiet-button {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--shell-line);
  color: var(--shell-muted);
}

.focus-quiet-button:hover {
  color: var(--shell-purple);
}

.focus-quiet-button.is-active {
  background: #dfe8d9;
  border-color: transparent;
  color: #536b52;
}

.practice-account-link:focus-visible,
.focus-end-link:focus-visible,
.focus-quiet-button:focus-visible,
.navbar-logo:focus-visible,
.focus-brand:focus-visible {
  outline: 2px solid var(--shell-purple);
  outline-offset: 2px;
}

/* Signed-out top bar buttons, in the same calm palette */
.auth-signin {
  color: var(--shell-muted);
}

.auth-signup {
  background: var(--shell-purple);
  border-radius: 999px;
  box-shadow: none;
}

.auth-signup:hover {
  background: #4d376a;
  box-shadow: none;
}

.user-avatar {
  background: var(--shell-purple);
}

@media (max-width: 760px) {
  /* Phones: keep the name next to the dove; the awake button is icon-only. */
  .focus-brand > span:last-child {
    display: inline;
  }

  .focus-quiet-button {
    justify-content: center;
    padding: 0;
    width: 40px;
  }

  .focus-end-link {
    padding: 0 14px;
  }

  .logo-text,
  .practice-launch-brand strong,
  .focus-brand > span:last-child {
    font-size: 17px;
  }

  /* The bottom tab bar replaces the account link on phones. */
  .practice-account-link {
    display: none;
  }
}

@media (max-width: 359px) {
  .focus-brand > span:last-child {
    display: none;
  }
}

/* Toasts sit above the bottom tab bar. */
@media (max-width: 768px) {
  body.has-bottom-nav .focus-toast {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
}

/* ── Reminders (Settings) ─────────────────────────────────────────── */
.reminders-card { scroll-margin-top: 80px; }
.reminders-title {
  color: var(--shell-ink);
  font: 700 22px/1.3 "Literata", Georgia, serif;
  margin: 0 0 6px;
}
.reminders-lead, .reminder-note {
  color: var(--shell-muted);
  font: 400 14px/1.5 "Inter", sans-serif;
  margin: 0 0 18px;
}
.reminder-note { font-size: 12px; margin: 14px 0 0; }
.push-panel {
  align-items: center;
  background: #fbf8f2;
  border: 1px solid var(--shell-line);
  border-radius: 16px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 14px 16px;
}
.push-panel strong, .reminder-check strong {
  color: var(--shell-ink);
  display: block;
  font: 600 15px/1.3 "Inter", sans-serif;
}
.push-status {
  color: var(--shell-muted);
  font: 400 13px/1.4 "Inter", sans-serif;
  margin: 3px 0 0;
}
.push-status.is-on { color: #536b52; }
.push-help {
  background: #f1ebf7;
  border-radius: 14px;
  color: var(--shell-ink);
  font: 400 14px/1.5 "Inter", sans-serif;
  margin-bottom: 14px;
  padding: 14px 16px;
}
.push-help ol { margin: 8px 0 0; padding-left: 20px; }
.reminder-button {
  background: var(--shell-purple);
  border: 0;
  border-radius: 999px;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  font: 600 14px/1 "Inter", sans-serif;
  min-height: 44px;
  padding: 0 20px;
}
.reminder-button:hover { background: #4d376a; }
.reminder-button.is-secondary {
  background: transparent;
  border: 1px solid rgba(116, 86, 155, 0.35);
  color: var(--shell-purple);
}
.reminder-form { display: flex; flex-direction: column; gap: 4px; }
.reminder-row {
  align-items: center;
  border-bottom: 1px solid var(--shell-line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 0;
}
.reminder-check {
  align-items: flex-start;
  cursor: pointer;
  display: flex;
  gap: 12px;
  min-width: 0;
}
.reminder-check input[type="checkbox"] {
  accent-color: var(--shell-purple);
  flex-shrink: 0;
  height: 20px;
  margin-top: 2px;
  width: 20px;
}
.reminder-check small {
  color: var(--shell-muted);
  display: block;
  font: 400 13px/1.4 "Inter", sans-serif;
  margin-top: 2px;
}
.reminder-time {
  -webkit-appearance: none;
  appearance: none;
  background: white;
  border: 1px solid var(--shell-line);
  border-radius: 12px;
  color: var(--shell-ink);
  flex-shrink: 0;
  font: 500 16px/1 "Inter", sans-serif;
  min-height: 44px;
  min-width: 0;
  padding: 0 12px;
  width: 116px;
}
.reminder-save { align-self: flex-start; margin-top: 14px; }
.push-help ol { list-style: decimal; }
.push-help li { margin: 2px 0; }

/* ══ Loading feedback: a tap always shows that something is happening ══ */
#qp-loading-bar {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  height: 3px;
  width: 0;
  background: var(--shell-purple);
  border-radius: 0 3px 3px 0;
  opacity: 0;
  z-index: 10000;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#qp-loading-bar.is-active {
  opacity: 1;
  animation: qp-loading-grow 8s cubic-bezier(0.1, 0.7, 0.2, 1) forwards;
}
@keyframes qp-loading-grow {
  0% { width: 0; }
  10% { width: 35%; }
  100% { width: 92%; }
}
#qp-loading-note {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: #fff;
  color: var(--shell-ink);
  box-shadow: 0 8px 28px rgba(41, 36, 55, 0.14);
  font: 500 14px/1.3 "Inter", system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#qp-loading-note.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.qp-spinner {
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(116, 86, 155, 0.25);
  border-top-color: var(--shell-purple);
  border-radius: 50%;
  animation: qp-spin 0.8s linear infinite;
}
@keyframes qp-spin { to { transform: rotate(360deg); } }

/* Reflection being prepared (journal entry pages) */
.qp-reflection-status {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(116, 86, 155, 0.06);
  border: 1px solid rgba(116, 86, 155, 0.18);
  color: var(--shell-ink);
  font-family: "Inter", system-ui, sans-serif;
}
.qp-reflection-status .qp-spinner { margin-top: 2px; }
.qp-reflection-status strong { display: block; font-size: 16px; margin-bottom: 4px; }
.qp-reflection-status p { margin: 0; color: var(--shell-muted); font-size: 14px; line-height: 1.5; }
.qp-reflection-status.is-quiet { background: #fff; border-color: var(--shell-line); }

@media (prefers-reduced-motion: reduce) {
  #qp-loading-bar.is-active { animation: none; width: 60%; }
  .qp-spinner { animation-duration: 2.4s; }
}

/* ══ Footer: one quiet line, right after the content ══════════════════ */
.qp-footer {
  border-top: 1px solid var(--shell-line);
  background: var(--shell-bg);
  color: var(--shell-muted);
  font: 400 13px/1.4 "Inter", system-ui, sans-serif;
}
.qp-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 8px 24px;
  flex-wrap: wrap;
}
.qp-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--shell-ink);
  font-family: "Literata", Georgia, serif;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}
.qp-footer-brand .logo-mark { width: 22px; height: 22px; }
.qp-footer-links { display: flex; flex-wrap: wrap; gap: 0 4px; margin-left: auto; }
.qp-footer-links a {
  color: var(--shell-muted);
  text-decoration: none;
  padding: 10px 8px;
}
.qp-footer-links a:hover { color: var(--shell-purple); }
.qp-footer-copy { margin: 0; width: 100%; font-size: 12px; opacity: 0.8; }

/* The footer itself makes room for the tab bar, so the page does not
   add a second empty band above it. */
body.has-bottom-nav main.flex-1 { padding-bottom: 0; }
main > :last-child { margin-bottom: 0; }

@media (max-width: 768px) {
  .qp-footer-inner { padding: 16px 16px 12px; justify-content: center; text-align: center; }
  .qp-footer-brand { display: none; }
  .qp-footer-links { margin: 0; justify-content: center; }
  .qp-footer-links a { padding: 8px 8px; }
  body.has-bottom-nav .qp-footer { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* Tester preview */
.tester-preview-note {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(116, 86, 155, 0.08);
  color: var(--shell-ink);
  font: 400 14px/1.5 "Inter", system-ui, sans-serif;
}
.tester-preview-note a,
.tester-preview-card a { color: var(--shell-purple); font-weight: 700; }
.tester-preview-card h2 { font-family: "Literata", Georgia, serif; font-size: 22px; font-weight: 600; color: var(--shell-ink); margin: 0 0 8px; }
.tester-preview-card p { color: var(--shell-muted); font-size: 15px; line-height: 1.6; margin: 0 0 6px; }
