/* =========================================================================
   FFP demo — app shell.
   Adapts the extract's preview-only device shell into a real responsive app
   and adds the components the prototype never designed.
   Load AFTER tokens.css and app.css.
   ========================================================================= */

/* ---- Viewport clamping -------------------------------------------------
   The shell must be exactly viewport-height so .scrollarea scrolls INTERNALLY
   and the tab bar stays pinned. Without this the document scrolls and the
   primary navigation disappears below the fold on every screen.            */
html, body { height: 100%; }
body {
  background: var(--c-bg); padding: 0; display: block;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 699.98px) {
  .device {
    width: 100%; max-width: 100%;
    height: 100vh; height: 100svh; height: 100dvh;   /* iOS<15.4 fallback  */
    max-height: 100dvh; min-height: 0;
    border-radius: 0; box-shadow: none; margin: 0;
    display: flex; flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
  }
  #app    { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .screen { flex: 1 1 auto; height: auto; min-height: 0; }
  /* OS chrome belongs to the phone, not to a web app */
  .statusbar, .home-indicator { display: none; }
}
.scrollarea {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--s-7);       /* tab bar is in flow now, not overlaying */
  overscroll-behavior: contain;
}
.tabbar {
  position: sticky; bottom: 0; z-index: 20;
  margin-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

/* Desktop: show it inside a phone mock, where the status bar reads as part
   of the mockup rather than as a bug. */
@media (min-width: 700px) {
  body { background: #14110F; display: flex; justify-content: center;
         align-items: center; padding: 24px 0; }
  .device { width: 390px; max-width: 390px; height: 844px; max-height: 92dvh;
            min-height: 0; border-radius: 44px; overflow: hidden;
            box-shadow: 0 24px 64px rgba(0,0,0,.55);
            display: flex; flex-direction: column; }
  #app    { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .screen { flex: 1 1 auto; min-height: 0; }
}

/* ---- Touch behaviour --------------------------------------------------- */
#app a, #app button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* iOS zooms the page on focus for any input under 16px, and never zooms back */
#app input, #app textarea, #app select { font-size: max(16px, 1rem); }

/* ---- Minimum 44px tap targets ------------------------------------------ */
#app .icon-btn, #app .icon-btn-circle {
  min-width: 44px; min-height: 44px;
  display: inline-grid; place-items: center;
}
#app .switch { position: relative; }
#app .switch::before { content: ""; position: absolute; inset: -8px; }
.rating button { min-width: 44px; min-height: 44px; }
.tabbar__item { min-height: 48px; }

/* ---- Hero pager (full-bleed) vs content rail (guttered) ----------------
   Both reuse .carousel in the extract; the hero must not inherit the rail's
   side padding or gap, and its slides must be allowed to shrink.           */
.carousel--hero {
  padding: 0; gap: 0; scroll-padding: 0;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.carousel--hero::-webkit-scrollbar { display: none; }
.carousel--hero > .hero {
  flex: 0 0 100%; min-width: 0; scroll-snap-align: start;
}
/* Flex children default to min-width:auto and refuse to shrink below their
   longest unbreakable label, which dragged slides to ~870px wide. */
.carousel--hero > * { min-width: 0; }
.nav-list__row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero > p, .hero > h2, .hero > .nav-list, .hero > .dots { margin-left: var(--gutter); margin-right: var(--gutter); }
.hero > .dots { margin-bottom: var(--s-4); }
.hero__art { height: 200px; }
@media (max-height: 700px) { .hero__art { height: 132px; } }

/* ---- Content rail ------------------------------------------------------ */
.rail {
  display: flex; gap: var(--s-4); overflow-x: auto;
  padding: 0 var(--gutter) var(--s-2);
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > .content-card { flex: 0 0 259px; scroll-snap-align: start; }

/* ---- Floating CTA ------------------------------------------------------
   app.css centres this with left:50% + translateX(-50%), which is an
   absolute-positioning trick. On a sticky element `left` is a threshold, not
   a placement, so the transform shoved it half a viewport left.            */
.btn-floating {
  position: static;                 /* flex sibling of .scrollarea, not overlaid */
  left: auto; right: auto; bottom: auto; transform: none;
  width: 100%; max-width: none; min-height: 0;
  margin: 0; padding: 0 var(--gutter) var(--s-2);
  flex: 0 0 auto; z-index: 15;
}
.btn-floating .btn { width: 100%; }

/* ---- Modals ------------------------------------------------------------ */
.scrim { position: fixed; inset: 0; z-index: 40; }
.sheet {
  z-index: 50; max-height: 85dvh; overflow-y: auto;
  padding-bottom: calc(var(--s-8) + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 700px) { .scrim { position: absolute; } }
.is-modal-open, .is-modal-open body { overflow: hidden; overscroll-behavior: contain; }
.sheet__grab { display: block; width: 36px; height: 4px; border-radius: 2px;
               background: #DCD7D2; margin: 0 auto var(--s-5); }

/* ---- Rows: label left, control right ----------------------------------- */
.setting { display: flex; align-items: flex-start; gap: var(--s-3); }
.setting > :not(.switch) { flex: 1 1 auto; min-width: 0; }
.setting > .switch { flex: 0 0 auto; margin-top: 2px; }
.card--link { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.card--link > :first-child { min-width: 0; }
.card--link svg { flex: 0 0 auto; }

/* ---- Reader ------------------------------------------------------------
   The bar must stay reachable: this is the screen a woman needs to leave
   fastest, and the article is up to ~19,000px tall. */
.reader__bar {
  position: sticky; top: 0; z-index: 15;
  background: var(--c-bg-2);
  padding-top: env(safe-area-inset-top, 0px);
}
.theme-dark .reader__bar { background: var(--c-dark-bg); }
.reader__group { font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
                 color: var(--c-muted); margin: var(--s-7) 0 var(--s-2); }
.reader h2 { font-size: 20px; line-height: 27px; font-weight: 500; margin: var(--s-6) 0 var(--s-2); }
.reader p { font-size: 16px; line-height: 28px; margin: 0 0 var(--s-4); color: var(--c-ink); }
.theme-dark { background: var(--c-dark-bg); color: var(--c-dark-fg); }
.theme-dark .reader p { color: var(--c-dark-fg); }
.theme-dark .card, .theme-dark .q-card { background: #262626; }
.theme-dark .reader__group { color: var(--c-dark-muted); }

/* ---- User preferences -------------------------------------------------- */
html[data-textsize="grande"] { font-size: 112.5%; }
html[data-textsize="mayor"]  { font-size: 125%; }
html[data-contrast="alto"] { --c-muted: #4A4A4A; --c-muted-2: #333; --c-hairline: #9A9A9A; }

/* ---- Demo annotations -------------------------------------------------- */
.note { margin: var(--s-4) 0; padding: var(--s-3) var(--s-4);
        border-radius: 12px; background: #FFF4E5; border: 1px solid #F0D6AE;
        font-size: 13px; line-height: 19px; color: #6B4E1E; }
.note b { font-weight: 600; }
html[data-notes="off"] .note { display: none; }

/* ---- Search ------------------------------------------------------------ */
.searchfield { display: flex; align-items: center; gap: var(--s-3);
  background: var(--c-surface); border-radius: 999px; padding: 0 var(--s-4);
  min-height: 48px; margin-bottom: var(--s-4); border: 1px solid var(--c-hairline); }
.searchfield input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--c-ink); }
.result { display: block; padding: var(--s-4) 0; border-bottom: 1px solid var(--c-hairline);
          text-decoration: none; color: inherit; min-height: 48px; }
.result__q { font-size: 15px; line-height: 21px; font-weight: 500; }
.result__meta { font-size: 12px; color: var(--c-muted); margin-top: 4px; display: block; }
mark { background: #FDE7C9; color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---- Self-assessment --------------------------------------------------- */
.q-card { background: var(--c-surface); border-radius: var(--r-card); padding: var(--s-5); margin-bottom: var(--s-4); }
.q-progress { font-size: 12px; color: var(--c-muted); margin-bottom: var(--s-2); }
.q-text { font-size: 17px; line-height: 25px; font-weight: 500; }
.q-actions { display: flex; gap: var(--s-3); margin-top: var(--s-5); }
.q-actions .btn { flex: 1; }
.result-block { background: var(--c-surface); border-radius: var(--r-card); padding: var(--s-5);
  margin-bottom: var(--s-4); border-left: 4px solid var(--c-legal-hero); }
.result-block.is-clear { border-left-color: #BFE3E5; }
.result-block h3 { margin: 0 0 var(--s-2); font-size: 15px; line-height: 21px; }
.result-block p { margin: 0; font-size: 14px; line-height: 21px; color: var(--c-muted-2); }

/* ---- Decoy calculator -------------------------------------------------- */
.calc { flex: 1 1 auto; min-height: 0; background: #000; color: #fff; display: flex;
        flex-direction: column; justify-content: flex-end;
        padding: 0 12px calc(24px + env(safe-area-inset-bottom, 0px)); }
.calc__out { font-size: clamp(44px, 14vw, 68px); font-weight: 300; text-align: right;
             padding: 0 16px 18px; letter-spacing: -1px; word-break: break-all; }
.calc__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 3vw, 12px); }
.calc__k { aspect-ratio: 1; border: 0; border-radius: 999px; font-size: clamp(22px, 7vw, 30px);
           background: #333; color: #fff; font-family: inherit; cursor: pointer; min-height: 44px; }
.calc__k--fn { background: #A5A5A5; color: #000; }
.calc__k--op { background: #FF9F0A; }
.calc__k--wide { aspect-ratio: auto; grid-column: span 2; border-radius: 999px; text-align: left; padding-left: 28px; }
.calc__hint { color: #666; font-size: 11px; text-align: center; padding: 10px 0 0; }

/* ---- Assistant --------------------------------------------------------- */
.bubble { max-width: 82%; padding: 12px 14px; border-radius: 18px; font-size: 15px;
          line-height: 22px; margin-bottom: var(--s-3); }
.bubble--user { background: var(--c-ink-2); color: #fff; margin-left: auto; border-bottom-right-radius: 6px; }
.bubble--bot { background: var(--c-surface); border-bottom-left-radius: 6px; }
.conf { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; border-radius: 999px;
        padding: 3px 9px; margin-top: 8px; font-weight: 500; }
.conf--alta { background: #D9EEF0; color: #12595E; }
.conf--media { background: #F8DCC6; color: #7A4A18; }
.conf--baja { background: #F3D2D2; color: #7A2222; }
.cite { font-size: 12px; color: var(--c-muted); margin-top: 8px; padding-top: 8px;
        border-top: 1px solid var(--c-hairline); }

/* ---- Misc -------------------------------------------------------------- */
.tabbar__item span { font-size: 12px; }
.tel { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
       text-decoration: none; color: inherit; }
.tel__num { font-size: 15px; font-weight: 600; white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: #fff; padding: 8px 12px; border-radius: 8px; }
