/* Nowenna Pompejańska — calm minimal theme */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --ink: #23221f;
  --muted: #74726b;
  --faint: #9b988f;
  --line: #e8e4db;
  --accent: #5e7186;
  --accent-soft: #eef1f4;
  --accent-ink: #ffffff;
  --bead: #ded9cf;
  --danger: #9a5a4f;
  --radius: 16px;
  --radius-sm: 11px;
  --maxw: 640px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-prayer: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --shadow: 0 1px 2px rgba(40, 38, 33, 0.04), 0 8px 28px rgba(40, 38, 33, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1e1e24;
    --ink: #ece9e3;
    --muted: #a6a39c;
    --faint: #76746e;
    --line: #2d2d35;
    --accent: #93a6bc;
    --accent-soft: #24262d;
    --accent-ink: #16161a;
    --bead: #3a3a43;
    --danger: #cf8a7e;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px rgba(0,0,0,0.35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  /* Kill the iOS "double-tap to zoom" delay/zoom when tapping quickly
     (e.g. counting beads); pinch-zoom stays available for accessibility. */
  touch-action: manipulation;
}

noscript { display: block; padding: 2rem; text-align: center; }

button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
/* Rapid taps on controls shouldn't select text or trigger zoom gestures. */
.counter-tap, .btn, .navbar, .bar, .lang-btn, .icon-btn, .bead, .intention-strip { -webkit-user-select: none; user-select: none; }

.screen {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen-pad { max-width: var(--maxw); margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.25rem); }

/* ---- buttons ---- */
.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.85rem 1.4rem;
  font-size: 1rem;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-block { width: 100%; }
.btn svg { display: block; }

.linkish {
  background: none; border: none; color: var(--accent);
  font-size: 0.95rem; font-weight: 550; padding: 0.2rem 0.1rem;
}
.linkish.small { font-size: 0.85rem; }

.icon-btn {
  background: none; border: none; color: var(--muted);
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
}
.icon-btn:active { background: var(--accent-soft); }

/* ---- language button + sheet ---- */
.lang-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); border-radius: 999px;
  padding: 0.4rem 0.7rem; font-size: 0.82rem; font-weight: 600;
  letter-spacing: 0.04em;
}
.lang-btn:active { background: var(--accent-soft); }
.lang-globe { display: grid; place-items: center; color: var(--faint); }
.lang-code { line-height: 1; }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 19, 16, 0.32);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@media (prefers-color-scheme: dark) { .sheet-backdrop { background: rgba(0,0,0,0.55); } }
.sheet {
  width: 100%; max-width: var(--maxw);
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 0.5rem 1.1rem calc(1.4rem + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,0.18);
  animation: slideup .24s cubic-bezier(.2,.8,.2,1);
  max-height: 82dvh; overflow-y: auto;
}
.sheet-grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 0.4rem auto 0.8rem; }
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(100%); } }

.lang-list { display: flex; flex-direction: column; }
.lang-row {
  display: flex; align-items: baseline; gap: 0.6rem;
  background: none; border: none; text-align: left;
  padding: 0.85rem 0.4rem; border-radius: 10px;
  color: var(--ink); border-bottom: 1px solid var(--line);
}
.lang-row:last-child { border-bottom: none; }
.lang-row-native { font-size: 1.08rem; font-weight: 550; }
.lang-row-en { font-size: 0.8rem; color: var(--faint); }
.lang-row.is-active { color: var(--accent); }
.lang-row.is-active .lang-row-native { font-weight: 700; }
.lang-check { margin-left: auto; color: var(--accent); display: grid; place-items: center; }

.translit-toggle {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: 0.9rem; padding: 0.9rem 0.4rem 0.2rem;
  border-top: 1px solid var(--line); font-size: 0.95rem; color: var(--muted);
}
.translit-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 44px; height: 26px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .18s ease; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .18s ease; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.translit-toggle input:checked + .switch { background: var(--accent); }
.translit-toggle input:checked + .switch::after { transform: translateX(18px); }

.sheet-actions { display: flex; gap: 0.6rem; margin-top: 1rem; }
.sheet-actions.tight { margin-top: 0.6rem; }
.sheet-actions .btn { flex: 1; }

/* ---- top bars ---- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: calc(0.5rem + env(safe-area-inset-top)) 0.85rem 0.5rem;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-day { font-size: 0.9rem; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }

.home-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(0.7rem + env(safe-area-inset-top)) 1.1rem 0.4rem;
}
.home-top-spacer { flex: 1; }

/* ---- progress tracks ---- */
.track { height: 3px; background: var(--line); position: relative; overflow: hidden; }
.track-step { position: sticky; top: 52px; z-index: 9; }
.track-novena { border-radius: 3px; margin: 1.1rem 0 0.2rem; }
.track-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); transition: width .25s ease; border-radius: 3px; }

/* ---- intention follow-along strip ---- */
.intention-strip {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; max-width: var(--maxw); margin: 0 auto;
  background: var(--accent-soft); border: none; border-bottom: 1px solid var(--line);
  color: var(--muted); text-align: left;
  padding: 0.5rem 1rem; font-size: 0.85rem;
}
.intention-strip .intention-icon { color: var(--accent); flex: none; }
.intention-strip-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: white-space .2s; flex: 1;
}
.intention-strip.is-open .intention-strip-text { white-space: normal; }

/* ---- stage / card ---- */
.stage {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(1.1rem, 4vw, 2.2rem) clamp(1.1rem, 4vw, 1.6rem) 1.2rem;
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; padding: clamp(1.4rem, 5vw, 2.4rem); animation: rise .22s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.eyebrow {
  margin: 0 0 0.7rem; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent);
}
.card-title {
  margin: 0 0 0.4rem; font-family: var(--font-prayer);
  font-size: clamp(1.45rem, 5vw, 1.95rem); font-weight: 600; line-height: 1.25;
  letter-spacing: -0.01em;
}
.card-body { margin-top: 1rem; }
.prayer-text p {
  font-family: var(--font-prayer); font-size: clamp(1.12rem, 4vw, 1.32rem);
  line-height: 1.72; margin: 0 0 0.7rem;
}
.translit {
  color: var(--muted); font-style: italic; font-family: var(--font-prayer);
  font-size: 0.98rem; line-height: 1.6;
}
.translit-title { margin: -0.1rem 0 0.2rem; font-size: 1rem; }

/* ---- mystery card ---- */
.mystery .card-title { color: var(--ink); }
.scripture {
  margin-top: 1rem; padding: 0.9rem 1rem; background: var(--accent-soft);
  border-radius: var(--radius-sm);
}
.scripture-ref {
  display: flex; align-items: center; gap: 0.45rem; margin: 0;
  font-weight: 650; font-size: 0.95rem; color: var(--ink);
}
.scripture-ico { color: var(--accent); display: grid; place-items: center; }
.scripture-user { margin-top: 0.5rem; }
.scripture-text {
  font-family: var(--font-prayer); font-size: 1.18rem; line-height: 1.7;
  margin: 0 0 0.4rem; white-space: pre-wrap;
}
.scripture-link {
  display: inline-block; margin: 0.15rem 0 0.2rem; color: var(--accent);
  font-size: 0.85rem; font-weight: 600; text-decoration: none;
}
.scripture-link:active { opacity: 0.7; }
.add-scripture { color: var(--accent); }

.meditation { margin-top: 1.3rem; }
.med-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 0.35rem;
}
.med-text {
  font-family: var(--font-prayer); font-size: clamp(1.05rem, 4vw, 1.22rem);
  line-height: 1.72; margin: 0;
}

/* ---- counter / beads ---- */
.counter { margin-top: 1.6rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.counter-tap {
  background: none; border: none; padding: 0.4rem; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 0.7rem;
  border-radius: var(--radius-sm);
}
.counter-tap:active { background: var(--accent-soft); }
.beads { display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: center; }
.bead {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bead); transition: background .12s ease, transform .12s ease;
}
.bead.on { background: var(--accent); transform: scale(1.12); }
.counter-num { font-size: 1.05rem; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter-hint { font-size: 0.78rem; color: var(--faint); }
.counter.done .counter-num { color: var(--accent); }

/* ---- bottom nav ---- */
.navbar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: 0.7rem; align-items: center;
  padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-top: 1px solid var(--line);
}
.nav-back { flex: 0 0 auto; }
.nav-next { flex: 1; }

/* ---- home ---- */
.home-main { flex: 1; padding: clamp(1.5rem, 6vw, 3rem) clamp(1.25rem, 5vw, 2rem); display: flex; flex-direction: column; }
.home-eyebrow { text-align: center; margin: 0.5rem 0 0.4rem; font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.home-day { text-align: center; font-family: var(--font-prayer); font-size: clamp(2.4rem, 11vw, 3.4rem); font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.home-phase { text-align: center; color: var(--accent); font-weight: 600; margin: 0.2rem 0 0; }
.home-actions { margin-top: 1.6rem; display: flex; flex-direction: column; gap: 0.6rem; }
.home-foot { text-align: center; padding: 1rem 1rem calc(1.4rem + env(safe-area-inset-bottom)); }

.intention-card {
  margin-top: 1.6rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.intention-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.45rem; }
.intention-icon { color: var(--accent); display: inline-grid; place-items: center; }
.intention-label { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.intention-head .linkish { margin-left: auto; }
.intention-text { margin: 0; font-family: var(--font-prayer); font-size: 1.12rem; line-height: 1.55; }
.intention-text.is-empty, .intention-inline-text.is-empty { color: var(--faint); font-style: italic; }

.intention-inline { margin-top: 1.1rem; padding: 0.9rem 1rem; background: var(--accent-soft); border-radius: var(--radius-sm); display: flex; align-items: flex-start; gap: 0.6rem; }
.intention-inline-text { margin: 0; flex: 1; font-family: var(--font-prayer); font-size: 1.12rem; line-height: 1.5; }

/* ---- welcome ---- */
.welcome { flex: 1; }
.welcome-title { font-family: var(--font-prayer); font-size: clamp(2rem, 8vw, 2.7rem); font-weight: 600; margin: 0.6rem 0 0.2rem; letter-spacing: -0.02em; }
.welcome-sub { color: var(--accent); font-weight: 600; margin: 0 0 1rem; }
.welcome-intro { color: var(--muted); font-size: 1.05rem; margin: 0 0 1.8rem; }
.field-label { display: block; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin-bottom: 0.5rem; }
.field {
  width: 100%; font-family: var(--font-prayer); font-size: 1.1rem; line-height: 1.55;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem; resize: vertical;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-note { font-size: 0.85rem; color: var(--faint); margin: 0.5rem 0 1.4rem; }

/* ---- day done / finished ---- */
.day-done, .finished { min-height: 100dvh; }
.done-box { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem clamp(1.25rem, 6vw, 2.5rem) calc(2rem + env(safe-area-inset-bottom)); gap: 0.4rem; }
.done-mark { color: var(--accent); margin-bottom: 0.6rem; }
.done-mark.crown { color: var(--accent); }
.done-title { font-family: var(--font-prayer); font-size: clamp(1.8rem, 7vw, 2.4rem); font-weight: 600; margin: 0; }
.done-body { color: var(--muted); font-size: 1.05rem; max-width: 30ch; margin: 0.3rem 0 1.4rem; }
.done-body.quote { font-family: var(--font-prayer); font-style: italic; font-size: 1.2rem; color: var(--ink); max-width: 34ch; }
.done-intention { display: inline-flex; align-items: center; gap: 0.5rem; background: var(--accent-soft); border-radius: 999px; padding: 0.5rem 1rem; margin-bottom: 1.6rem; font-family: var(--font-prayer); font-size: 1.02rem; }
.done-box .btn-block { max-width: 360px; }

/* ---- login gate ---- */
.login { min-height: 100dvh; }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.5rem clamp(1.25rem, 6vw, 2rem) calc(3rem + env(safe-area-inset-bottom)); }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-mark { color: var(--ink); display: flex; justify-content: center; margin-bottom: 1.4rem; }
.login-title { font-family: var(--font-prayer); font-size: clamp(1.7rem, 7vw, 2.2rem); font-weight: 600; margin: 0 0 0.4rem; }
.login-sub { color: var(--muted); font-size: 1rem; margin: 0 0 1.8rem; line-height: 1.5; }
.login-form { display: flex; flex-direction: column; text-align: left; }
.login-form .field-label { margin-top: 0.9rem; }
.login-form .field { font-family: var(--font-ui); font-size: 1rem; margin-top: 0.1rem; }
.login-form .field:first-of-type { margin-top: 0; }
.login-form .btn { margin-top: 1.4rem; }
.login-error { color: var(--danger); font-size: 0.9rem; margin: 0.9rem 0 0; text-align: center; }
.login-links { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; flex-wrap: wrap; }
.login-links .linkish { color: var(--muted); text-decoration: none; }
.login-links .linkish:hover { color: var(--accent); }

/* ---- account (in language/settings sheet) ---- */
.sheet-account { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.acct-line { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.8rem; }
.acct-label { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.acct-email { font-size: 0.95rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
