/* =========================================================================
   Harmonie — Application des soins
   Design system distilled from "Soins App - Maquette.dc.html".
   ========================================================================= */
@import url('./fonts/fonts.css');

:root {
  /* palette */
  --accent:      #05C296;
  --accent-deep: #05A07C;
  --accent-bg:   #E7F8F2;
  --accent-bg2:  #EEF4F1;
  --ink:         #2C3A36;
  --ink-soft:    #33403B;
  --body:        #5a6661;
  --muted:       #9aa8a3;
  --muted2:      #7c8a85;
  --faint:       #A6B2AE;
  --hint:        #C3CEC9;
  --bg:          #F7FAF8;
  --bg-detail:   #FBFDFC;
  --card:        #ffffff;
  --line:        #E4EEEA;
  --line2:       #EEF4F1;
  --line3:       #ECF3F0;
  --frame:       #0f1714;

  /* type */
  --serif: 'Marcellus', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans:  'Mulish', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* reading preferences — set from the Réglages screen, applied to detail content */
  --reading-scale: 1;
  --reading-color: var(--body);

  /* shadows */
  --sh-card:  0 8px 26px rgba(20, 60, 50, .06);
  --sh-soft:  0 4px 16px rgba(20, 60, 50, .04);
  --sh-btn:   0 10px 22px -6px rgba(5, 194, 150, .5);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; margin: 0; overflow-x: hidden; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* The "device viewport": full screen on phones, a centred card on desktop. */
.app {
  position: relative;
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  isolation: isolate;
}

@media (min-width: 480px) {
  body {
    background:
      radial-gradient(1200px 600px at 50% -10%, #EAF4EF 0%, #E2ECE7 55%, #DCE7E1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 0;
  }
  .app {
    height: min(900px, calc(100vh - 56px));
    min-height: 0;
    border-radius: 40px;
    box-shadow: 0 40px 80px -28px rgba(20, 55, 45, .45), 0 12px 30px rgba(20, 55, 45, .14);
    border: 1px solid rgba(255, 255, 255, .6);
  }
}

/* Landscape (short, wide viewports — e.g. a phone rotated sideways): let the
   card grow wider so it fills the horizontal space instead of a narrow strip.
   Width adapts fluidly to the viewport, capped for comfortable reading. */
@media (orientation: landscape) and (max-height: 600px) {
  .app {
    max-width: min(720px, calc(100vw - 48px));
  }
}

/* ----------------------------------------------------------------- screens */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  transform: translateX(100%);
  transition: transform .34s cubic-bezier(.4, 0, .2, 1), opacity .34s ease;
  pointer-events: none;
  will-change: transform;
  overflow: hidden;
}
.screen.is-active { opacity: 1; transform: none; pointer-events: auto; }
.screen.is-behind { opacity: 0; transform: translateX(-22%); }
/* The first screen shown on load settles instantly (no slide-in flash). */
.app.no-anim .screen { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .screen { transition: opacity .2s ease; transform: none; }
  .screen:not(.is-active) { transform: none; }
}

.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;           /* never scroll sideways */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* status-bar safe area filler at the very top of each screen */
.safe-pad { height: var(--safe-top); flex: none; }

/* ------------------------------------------------------------------ shared */
.serif { font-family: var(--serif); font-weight: 400; }
.hidden { display: none !important; }

.iconbtn {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 3px 10px rgba(20, 60, 50, .04);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  transition: transform .12s ease, background .12s ease;
}
.iconbtn:active { transform: scale(.93); background: #F2F8F5; }

.chev { flex: none; }

/* search / filter field */
.field {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--sh-soft);
}
.field svg { flex: none; }
.field input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: 400 14px var(--sans); color: var(--ink);
}
.field input::placeholder { color: var(--faint); }

/* =====================================================  1 · LOGIN  ======= */
#screen-login { background: var(--bg); }
.login-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 0 34px calc(28px + var(--safe-bot));
  overflow-y: auto;
}
.login-top { flex: 1.1; min-height: 56px; }
.login-logo { margin-bottom: 26px; }
.login-title { font-family: var(--serif); font-size: 32px; color: var(--ink); letter-spacing: .01em; }
.login-form { width: 100%; margin-top: 56px; }
.field-label {
  font: 500 12px var(--sans); color: var(--muted2);
  letter-spacing: .03em; margin-bottom: 9px;
}
.pw-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-soft);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pw-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(5,194,150,.12); }
.pw-row input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: 600 17px var(--sans); color: var(--ink); letter-spacing: .22em;
}
.pw-row input::placeholder { color: var(--hint); letter-spacing: .22em; }
.pw-eye { background: none; border: 0; padding: 4px; cursor: pointer; display: flex; }
.pw-error {
  height: 0; overflow: hidden; opacity: 0;
  font: 500 12px var(--sans); color: #D9534F; margin-top: 0;
  transition: opacity .2s ease, height .2s ease, margin .2s ease;
}
.pw-error.show { height: auto; opacity: 1; margin-top: 10px; }
.btn-primary {
  width: 100%; margin-top: 18px; padding: 17px;
  background: var(--accent); border: 0; border-radius: 16px;
  text-align: center; cursor: pointer; box-shadow: var(--sh-btn);
  font: 600 16px var(--sans); color: #fff; letter-spacing: .02em;
  transition: transform .12s ease, filter .12s ease;
}
.btn-primary:active { transform: translateY(1px) scale(.99); filter: brightness(.97); }
.login-note {
  font: 400 12.5px/1.6 var(--sans); color: var(--muted);
  text-align: center; margin-top: 22px; padding: 0 8px;
}
.shake { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-7px); }
  40%,80% { transform: translateX(7px); }
}

/* =====================================================  2 · HOME  ======== */
.home-head {
  padding: 18px 26px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.home-title { font-family: var(--serif); font-size: 28px; color: var(--ink); }
.home-search { margin: 6px 26px 0; }
.cat-list { display: flex; flex-direction: column; gap: 14px; padding: 22px 26px 0; }
.cat-card {
  display: flex; align-items: center; gap: 16px; padding: 19px;
  background: var(--card); border: 1px solid var(--line2);
  border-radius: 22px; box-shadow: var(--sh-card);
  cursor: pointer; text-align: left; width: 100%;
  transition: transform .14s ease, box-shadow .14s ease;
}
.cat-card:active { transform: scale(.985); box-shadow: 0 4px 14px rgba(20,60,50,.08); }
.cat-icon {
  flex: none; width: 54px; height: 54px; border-radius: 16px;
  background: var(--accent-bg); display: flex; align-items: center; justify-content: center;
}
.cat-meta { flex: 1; min-width: 0; }
.cat-name { font-family: var(--serif); font-size: 20px; color: var(--ink); }

/* =====================================================  3 · LIST  ======== */
.list-head {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px 14px;
}
.list-title { font-family: var(--serif); font-size: 24px; color: var(--ink); }
.list-filter { margin: 0 22px; }
.rows { padding: 8px 22px calc(20px + var(--safe-bot)); }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 17px 4px; border-bottom: 1px solid var(--line3);
  cursor: pointer; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0;
  transition: background .12s ease, padding-left .12s ease;
}
.row:last-child { border-bottom: 0; }
.row:active { background: #F1F7F4; padding-left: 10px; border-radius: 12px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font: 600 15px var(--sans); color: var(--ink); overflow-wrap: break-word; }
.row .tag {
  display: inline-block; font: 600 10px var(--sans); color: var(--accent-deep);
  background: var(--accent-bg); border-radius: 999px; padding: 2px 8px;
  margin-bottom: 5px; letter-spacing: .02em;
}
.empty {
  padding: 48px 30px; text-align: center; color: var(--muted);
  font: 400 13.5px/1.6 var(--sans);
}
.empty .serif { display: block; font-size: 19px; color: var(--ink); margin-bottom: 6px; }

/* =====================================================  4 · DETAIL  ====== */
#screen-detail { background: var(--bg-detail); }
#screen-detail .scroll { background: var(--bg-detail); }
/* Prières: centre the prayer vertically; auto margins collapse to 0 (so it
   scrolls normally) when a prayer is taller than the viewport. */
#screen-detail .scroll.is-centered { display: flex; flex-direction: column; }
#screen-detail .scroll.is-centered .detail-body { margin-top: auto; margin-bottom: auto; }
.detail-head { display: flex; align-items: center; gap: 14px; padding: 12px 22px 6px; }
.detail-title { flex: 1; font: 400 22px/1.18 var(--serif); color: var(--ink); }
.detail-body { padding: 18px 24px calc(40px + var(--safe-bot)); }

/* rendered content from the .md files. Size + colour follow the reading prefs. */
.content {
  font-family: var(--sans); font-weight: 400;
  font-size: calc(14px * var(--reading-scale)); line-height: 1.7;
  color: var(--reading-color); overflow-wrap: break-word;
}
.content p { margin: 0 0 12px; }
.content p:last-child { margin-bottom: 0; }
/* markdown headings (# / ## / ###) — the section titles */
.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
  font-family: var(--serif); font-weight: 400;
  font-size: calc(17px * var(--reading-scale)); color: var(--ink); letter-spacing: .005em;
  margin: 22px 0 4px; line-height: 1.3;
}
.content h1:first-child, .content h2:first-child, .content h3:first-child { margin-top: 4px; }
/* inline emphasis: **bold** and *italic* */
.content b, .content strong { font-weight: 700; color: var(--ink-soft); }
.content i, .content em { color: var(--accent-deep); font-style: italic; }
.content .verse {
  font-style: italic; color: var(--accent-deep);
  border-left: 2px solid var(--accent); padding: 2px 0 2px 14px; margin: 4px 0 12px;
}
.content ul { margin: 0 0 12px; padding-left: 4px; list-style: none; }
.content li { position: relative; padding-left: 20px; margin-bottom: 8px; }
.content li::before {
  content: ''; position: absolute; left: 4px; top: 9px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.content .ol li { padding-left: 38px; margin-bottom: 13px; }
.content .ol li::before {
  content: attr(data-n);
  width: 26px; height: 26px; left: 0; top: 0; border-radius: 50%;
  background: var(--accent); color: #fff;
  font: 600 12.5px var(--sans); display: flex; align-items: center; justify-content: center;
}

.detail-fade {
  position: absolute; bottom: 0; left: 0; right: 0; height: 36px;
  background: linear-gradient(to top, var(--bg-detail), rgba(251,253,252,0));
  pointer-events: none;
}

/* generic loading shimmer */
.loading { padding: 40px 24px; color: var(--muted); font: 400 13px var(--sans); text-align: center; }

/* =====================================================  5 · RÉGLAGES  ==== */
.settings {
  padding: 8px 26px calc(28px + var(--safe-bot));
  display: flex; flex-direction: column; gap: 30px;
}
.set-group { display: flex; flex-direction: column; }
.set-label {
  font: 500 12px var(--sans); color: var(--muted2);
  letter-spacing: .03em; margin-bottom: 12px;
}

/* text-size chooser: an "A" per option, growing left → right */
.set-sizes { display: flex; gap: 10px; }
.set-size {
  flex: 1; height: 56px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--sh-soft); cursor: pointer;
  color: var(--ink); font-family: var(--serif); line-height: 1;
  transition: border-color .14s ease, box-shadow .14s ease, transform .12s ease;
}
.set-size:active { transform: scale(.96); }
.set-size.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(5,194,150,.12); }

/* colour swatches */
.set-colors { display: flex; gap: 14px; }
.set-color {
  width: 48px; height: 48px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid var(--line); background: var(--card);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, border-color .14s ease, box-shadow .14s ease;
}
.set-color:active { transform: scale(.92); }
.set-color .dot { width: 28px; height: 28px; border-radius: 50%; }
.set-color.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(5,194,150,.12); }

/* live preview — reuses .content so it mirrors the chosen size + colour */
.set-preview {
  background: var(--bg-detail); border: 1px solid var(--line2);
  border-radius: 18px; padding: 18px 20px; box-shadow: var(--sh-soft);
}
.set-preview p:last-child { margin-bottom: 0; }
