/* ═══════════════════════════════════════════════════════════════════════════════
   components.css — buttons, nav, the mascot, avatars, and the app-UI recreations.

   The "device mockups" here are real HTML/CSS built from the app's actual tokens
   rather than screenshots in a phone frame. They look native because they use
   the app's geometry, and they stay responsive, translatable, and RTL-correct.
   Every one is built with logical properties; only decorative transforms use the
   --dir multiplier.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Buttons (ui/components/button.dart) ─────────────────────────────────────
   Labels are always w700 in the app. Sizes md/lg map to the app's 44px/52px
   touch targets. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  font-weight: var(--fw-bold);
  font-size: var(--fs-label-md);
  letter-spacing: var(--ls-label);
  line-height: 1.25;
  padding: 12px var(--s4);
  min-height: 44px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  transition:
    transform var(--t-fast) var(--e-spring),
    background-color var(--t-fast) var(--e-glide),
    box-shadow var(--t-fast) var(--e-glide);
}

/* The app disables ink splashes globally (NoSplash.splashFactory) and presses
   via a scale instead. Same idea here. */
.btn:active { transform: scale(.97); }

.btn-lg {
  min-height: 56px;
  font-size: var(--fs-title-md);
  padding: 14px var(--s5);
}

.btn-filled {
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: var(--shadow-sm);
}
.btn-filled:hover { box-shadow: var(--shadow-toast), var(--glow-accent); transform: translateY(-1px); }

.btn-soft {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
}
.btn-soft:hover { background: var(--card-2); }

.btn-ghost {
  background: none;
  color: var(--ink);
  padding-inline: var(--s3);
}
.btn-ghost:hover { background: var(--hairline); }

.btn-inverse {
  background: var(--ink);
  color: var(--bg);
}

/* ── Store badges ─────────────────────────────────────────────────────────────
   The official artwork from Apple and Google. Their guidelines forbid recolouring,
   restyling, or adding effects, so these carry no background, border, or shadow of
   their own — only a hover lift, which is a transform on the link. */
.store-row {
  display: flex;
  gap: var(--s3);
  flex-wrap: wrap;
  align-items: center;
}

.store-badge-official {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r2);
  transition: transform var(--t-fast) var(--e-spring);
}
.store-badge-official:hover { transform: translateY(-3px); }
.store-badge-official img { height: 52px; width: auto; background: none; }

/* Google's PNG has ~20% transparent padding baked in. Matching the image height
   to Apple's would make its artwork read visibly smaller, so it is scaled up and
   pulled back with a negative inline margin to keep the optical gap even. */
.store-badge-play {
  height: 66px !important;
  margin-inline: -9px;
}

/* Stands in for the Google Play badge until the listing is approved (see
   _store_badges.html). Not Google's artwork, so free to be our own — but
   shaped like Apple's badge beside it: black, the same height and corner, a
   small line over a large one. */
.store-badge-android {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  block-size: 52px;
  padding-inline: 14px 18px;
  border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--paper) 30%, transparent);
  background: var(--night);
  color: var(--paper);
  text-align: start;
  transition: transform var(--t-fast) var(--e-spring), box-shadow var(--t-fast);
}
.store-badge-android:hover { transform: translateY(-3px); box-shadow: var(--shadow-toast); }
.store-badge-android-mark { inline-size: 22px; block-size: 22px; flex: none; color: var(--accent); }
.store-badge-android-text { display: flex; flex-direction: column; line-height: 1.12; }
.store-badge-android-kicker { font-size: 11px; font-weight: var(--fw-medium); opacity: .86; }
.store-badge-android-label { font-size: 18px; font-weight: var(--fw-bold); letter-spacing: -.2px; white-space: nowrap; }
[lang="ar"] .store-badge-android-text { line-height: 1.3; }
[lang="ar"] .store-badge-android-label { letter-spacing: 0; font-size: 17px; }


/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-dialog);
  box-shadow: var(--shadow-toast);
}

.card-pad { padding: var(--s4); }

/* ── Chips / pills ───────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-pill);
  background: var(--card);
  border: 1px solid var(--hairline);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.chip-accent {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

/* ── Category colours ─────────────────────────────────────────────────────────
   The app's real light-mode glow colours (Wisp/lib/features/plans_calendar/
   models/plan.dart, kCategoryVisuals). These are the one place a hex lives
   outside tokens.css: they are per-category data, not theme. A .cat-* class
   sets --glow, and the emoji tile reads it. */
.cat-coffee       { --glow: #8C5120; }
.cat-food         { --glow: #B89860; }
.cat-gym          { --glow: #4A8BB5; }
.cat-padel        { --glow: #A6C42A; }
.cat-football     { --glow: #2E9E4F; }
.cat-gaming       { --glow: #7B4FD6; }
.cat-cards        { --glow: #C0263A; }
.cat-movies       { --glow: #C9971F; }
.cat-study        { --glow: #3F4FB5; }
.cat-outdoors     { --glow: #2E7D32; }
.cat-camping      { --glow: #CC661C; }
.cat-trip         { --glow: #1E9E92; }
.cat-celebration  { --glow: #E84393; }
.cat-other        { --glow: #2F6FAD; }

/* The category's emoji on a square tinted with its colour — the leading tile
   on every plan card in the app. */
.emoji-tile {
  display: inline-grid;
  place-items: center;
  inline-size: 46px;
  block-size: 46px;
  flex: none;
  border-radius: 15px;
  background: color-mix(in srgb, var(--glow, var(--accent)) 17%, var(--card));
  font-size: 23px;
  line-height: 1;
}
.emoji-tile-sm {
  inline-size: 36px;
  block-size: 36px;
  border-radius: 12px;
  font-size: 18px;
}

/* ── The mark ─────────────────────────────────────────────────────────────────
   The four-pointed "wisp" star from assets/App_icon.svg, used through the
   #wisp-mark <symbol> wherever it is just a logo. */
.mark {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* ── The mascot ───────────────────────────────────────────────────────────────
   The same mark as a character (templates/_mascot.html): its eyes blink, and
   follow the pointer where there is one. site.js writes --look-x / --look-y in
   SVG user units — the viewBox is 1024 wide, so ±34 is a glance, not a stare. */
[data-mascot] {
  --look-x: 0;
  --look-y: 0;
}

.mascot-figure {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 14px 22px rgba(var(--shadow-rgb), .22));
}

.mascot-eyes {
  transform: translate(calc(var(--look-x) * 1px), calc(var(--look-y) * 1px));
  transition: transform 220ms var(--e-glide);
}

/* Blink: squash the eye paths, not the whole mark. 160ms of a 5.2s cycle. */
.mascot-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: mascot-blink 5.2s infinite;
}
.mascot-eye + .mascot-eye { animation-delay: .05s; }

@keyframes mascot-blink {
  0%, 95% { transform: scaleY(1); }
  96.5%, 97.5% { transform: scaleY(.08); }
  99%, 100% { transform: scaleY(1); }
}

/* No pointer to follow: the eyes look around on their own instead. */
@media (hover: none) {
  .mascot-eyes { animation: mascot-look-around 9s var(--e-glide) infinite; }
}
@keyframes mascot-look-around {
  0%, 18% { transform: translate(0, 0); }
  24%, 42% { transform: translate(-30px, 8px); }
  48%, 66% { transform: translate(28px, -14px); }
  72%, 100% { transform: translate(0, 0); }
}

@keyframes mascot-float {
  from { transform: translateY(0) rotate(calc(-3deg * var(--dir))); }
  to { transform: translateY(-12px) rotate(calc(3deg * var(--dir))); }
}

@media (prefers-reduced-motion: reduce) {
  .mascot-eye,
  .mascot-eyes { animation: none; transition: none; }
}

/* ── Nav pill ─────────────────────────────────────────────────────────────────
   Modelled on the app's FloatingNavBar: a floating rounded shell with a hairline,
   a blur, and the app's toast shadow. */
.nav {
  position: sticky;
  inset-block-start: 0;
  z-index: 100;
  padding-block: 14px;
  padding-block-start: max(14px, env(safe-area-inset-top));
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: var(--s2);
  max-width: 940px;
  min-height: 56px;
  margin-inline: auto;
  padding: var(--s2);
  padding-inline-start: 18px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--card) 84%, transparent);
  border: 1px solid var(--hairline);
  box-shadow: 0 12px 32px -14px rgba(var(--shadow-rgb), .28);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  transition: box-shadow var(--t-med) var(--e-glide), background-color var(--t-med) var(--e-glide);
}
/* site.js sets .is-scrolled once the page has moved, when the pill is floating
   over content rather than over the hero. */
.nav.is-scrolled .nav-pill {
  background: color-mix(in srgb, var(--card) 92%, transparent);
  box-shadow: var(--shadow-dialog);
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: var(--fw-black);
  font-size: 20px;
  letter-spacing: -.4px;
}
.nav-brand .mark { width: 28px; transition: transform var(--t-slow) var(--e-spring); }
.nav-brand:hover .mark { transform: rotate(calc(45deg * var(--dir))) scale(1.08); }
/* Latin wordmark: live text, always lowercase, isolated so it cannot reorder
   inside an Arabic run. */
.nav-brand .wordmark { direction: ltr; unicode-bidi: isolate; }

/* Arabic wordmark وسب: outlined SVG rather than live text, so it keeps the
   brand face and the ss01 swash on the final beh — the extended tail. Sized by
   cap height rather than box height, since that tail and the descenders make the
   artwork much taller than the letters read. */
.wordmark-ar {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
}
/* No vertical nudge here on purpose. make-headlines.py emits this SVG with a
   viewBox made symmetrical about the centre of the LETTER BODIES, so the swash
   tail hanging below the baseline no longer drags the word off centre — plain
   align-items: center is correct.

   Consequence: the letters occupy 0.406 of the box height (the tool prints this
   figure), so the height below is the letter height divided by 0.406. Rerun the
   tool if the wordmark changes and rescale from the number it reports. */
.wordmark-ar svg {
  display: block;
  height: 2.08em;      /* ≈ .85em of letter, matching the 18px Latin wordmark */
  width: auto;
}

.footer-brand .wordmark-ar svg { height: 2.29em; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  /* Pushes the trailing group to the inline end — mirrors correctly in RTL. */
  margin-inline-start: auto;
}

.nav-link {
  padding: 9px var(--s3);
  border-radius: var(--r-pill);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-faint-strong);
  transition: color var(--t-fast), background-color var(--t-fast);
}
.nav-link:hover { color: var(--ink); background: var(--hairline); }

.nav-lang {
  padding: 9px 18px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--card);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-bold);
  transition: transform var(--t-fast) var(--e-spring), box-shadow var(--t-fast);
}
.nav-lang:hover { transform: translateY(-1px); box-shadow: var(--shadow-toast); }

/* The narrow-screen menu. Hidden on wide screens, where .nav-links shows. */
.nav-menu { display: none; position: relative; }

.nav-menu-button {
  display: grid;
  place-items: center;
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--r-pill);
  background: var(--bg-lift);
  cursor: pointer;
  list-style: none;
}
.nav-menu-button::-webkit-details-marker { display: none; }

/* Three bars from one element and its two pseudo-elements; [open] folds the
   middle one away and crosses the other two. */
.nav-menu-bars,
.nav-menu-bars::before,
.nav-menu-bars::after {
  display: block;
  inline-size: 16px;
  block-size: 2px;
  border-radius: 2px;
  background: var(--ink);
  transition: transform var(--t-med) var(--e-spring), background-color var(--t-fast);
}
.nav-menu-bars { position: relative; }
.nav-menu-bars::before,
.nav-menu-bars::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
}
.nav-menu-bars::before { transform: translateY(-5px); }
.nav-menu-bars::after { transform: translateY(5px); }
.nav-menu[open] .nav-menu-bars { background: transparent; }
.nav-menu[open] .nav-menu-bars::before { transform: rotate(45deg); }
.nav-menu[open] .nav-menu-bars::after { transform: rotate(-45deg); }

.nav-menu-panel {
  position: absolute;
  inset-block-start: calc(100% + 14px);
  inset-inline-end: -8px;
  min-inline-size: 230px;
  display: flex;
  flex-direction: column;
  padding: var(--s2);
  border-radius: var(--r-toast);
  background: var(--card);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-dialog);
  animation: menu-in var(--t-med) var(--e-spring);
  transform-origin: top;
}
.nav-menu-panel a {
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: var(--fw-semibold);
}
.nav-menu-panel a:hover { background: var(--bg-lift); }

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(.96); }
}

@media (max-width: 760px) {
  .nav-links { display: none; }
  .nav-menu { display: block; }
  .nav-lang { margin-inline-start: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-menu-panel { animation: none; }
}

/* ── Memojis ─────────────────────────────────────────────────────────────────
   The friends from the store set, each on the tint the store artwork gives
   them (FACE_BG in wisp-store-assets/tools/slides/friends.html). Like the
   category colours, these tints are per-person data rather than theme, so they
   live here instead of in tokens.css. */
.memoji-omar   { --memoji-tint: #F1E6CC; }
.memoji-khalid { --memoji-tint: #CFF0DA; }
.memoji-mishal { --memoji-tint: #E4F0CF; }

/* A friend floating free: a white-rimmed bubble. */
.memoji {
  display: block;
  overflow: hidden;
  border-radius: var(--r-pill);
  border: 5px solid var(--paper);
  background: var(--memoji-tint, var(--bg-lift));
  box-shadow: var(--shadow-dialog);
}
.memoji img {
  inline-size: 112%;
  max-width: none;
  margin-inline-start: -6%;
  margin-block-start: 4%;
  background: none;
}

/* The faces chip from the store headlines: three memojis overlapping on a
   white pill, set inline at the end of a line of copy. */
.face-chip {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--paper);
  box-shadow: var(--shadow-toast);
  rotate: calc(-4deg * var(--dir));
}
.face-chip img {
  inline-size: 30px;
  block-size: 30px;
  border-radius: var(--r-pill);
  border: 2px solid var(--paper);
  background: var(--memoji-tint, var(--accent-soft));
}
.face-chip img + img { margin-inline-start: -8px; }
.face-chip-on-night { align-self: flex-start; margin-block-start: var(--s2); }

/* An activity on a white tile, as the store artwork floats them. */
.activity {
  display: grid;
  place-items: center;
  inline-size: 72px;
  block-size: 72px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow-dialog);
  font-size: 38px;
  line-height: 1;
}

/* The sparkle (#wisp-sparkle in _mark.svg), in ink or in cream. */
.sparkle { display: block; overflow: visible; }
.sparkle-ink { color: var(--ink); }
.sparkle-cream { color: var(--sparkle-cream); }

/* Gentle bobbing for anything floating. Each element sets its own --spin, and
   a negative delay so they do not move in step. */
.float {
  animation: float-bob 5.4s var(--e-glide) infinite alternate;
}
@keyframes float-bob {
  from { transform: translateY(0) rotate(calc(var(--spin, 0deg) * var(--dir))); }
  to { transform: translateY(-14px) rotate(calc((var(--spin, 0deg) + 5deg) * var(--dir))); }
}
@media (prefers-reduced-motion: reduce) {
  .float { animation: none; transform: rotate(calc(var(--spin, 0deg) * var(--dir))); }
}

/* ── Phone ────────────────────────────────────────────────────────────────────
   A frame around a real capture. Proportions follow phone() in friends.html: a
   thin band and bezel, a Dynamic Island, and the 1560 × 3376 capture filling
   the screen. */
.phone {
  inline-size: 300px;
  flex: none;
  padding: 9px;
  border-radius: 52px;
  background: var(--night);
  box-shadow:
    0 1px 2px rgba(var(--shadow-rgb), .10),
    0 24px 48px -10px rgba(var(--shadow-rgb), .22),
    0 80px 140px -30px rgba(var(--shadow-rgb), .28),
    inset 0 0 0 1px rgba(255, 255, 255, .25);
}

.phone-screen {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1560 / 3376;
  border-radius: 43px;
  background: var(--bg);
}
.phone-capture {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  background: none;
}
/* The island. Centred with auto margins between zero insets, which needs no
   physical left and so stays put in RTL. */
.phone-screen::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset-block-start: 9px;
  inset-inline: 0;
  margin-inline: auto;
  inline-size: 29%;
  aspect-ratio: 3.4;
  border-radius: var(--r-pill);
  background: var(--night);
}

.status-bar {
  position: absolute;
  inset-block-start: 12px;
  inset-inline: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 26px 22px;
  direction: ltr;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
}
.status-icons { display: flex; align-items: center; gap: 4px; }
.status-icons svg { inline-size: auto; block-size: 9px; fill: currentColor; }

/* ── Lifted cards ─────────────────────────────────────────────────────────────
   One card cut out of a capture and raised off the page, like lift() in
   friends.html. The box takes the region's aspect ratio; the image inside is
   scaled so the region spans the box, then shifted so it starts at the box's
   corner. Every number is in capture pixels (1560 × 3376):

     --x --y   the region's top-left corner
     --w --h   its size

   Physical left/top and a transform, not logical insets: the capture is a
   picture of one language's screen and must not be mirrored. */
.lift {
  --radius: 92;                       /* the card's corner, in capture pixels */
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--w) / var(--h);
  /* A percentage radius is measured on each axis separately, so a round
     corner of --radius capture pixels needs its own share of each. */
  border-radius: calc(var(--radius) / var(--w) * 100%) / calc(var(--radius) / var(--h) * 100%);
  background: var(--card);
  box-shadow:
    0 1px 2px rgba(var(--shadow-rgb), .08),
    0 20px 40px -8px rgba(var(--shadow-rgb), .18),
    0 60px 100px -24px rgba(var(--shadow-rgb), .30);
}
.lift img {
  position: absolute;
  left: 0;
  top: 0;
  inline-size: calc(100% * 1560 / var(--w));
  max-width: none;
  background: none;
  transform: translate(calc(-100% * var(--x) / 1560), calc(-100% * var(--y) / 3376));
}

/* The regions. Most are friends.html's own boxes, cropped just inside each
   card's border; the invitation and the chat's plan header were measured the
   same way. The poll sits at a different x in each language. */
.lift-create    { --x: 84; --y: 476;  --w: 1392; --h: 288; }
.lift-plan      { --x: 68; --y: 572;  --w: 1424; --h: 968; }
.lift-invite    { --x: 68; --y: 1850; --w: 1424; --h: 1087; }
.lift-chat-plan { --x: 68; --y: 309;  --w: 1424; --h: 396; }
.lift-message   { --x: 24; --y: 1360; --w: 1512; --h: 360; }
.lift-poll      { --x: 268; --y: 1936; --w: 1224; --h: 988; }
[lang="ar"] .lift-poll { --x: 68; }
.lift-month     { --x: 68; --y: 572;  --w: 1424; --h: 1200; }

/* ── FAQ (native <details>, zero JS) ─────────────────────────────────────────── */
.faq-item {
  margin-block-end: 10px;
  border-radius: 24px;
  background: var(--card);
  border: 1px solid var(--hairline);
  transition: box-shadow var(--t-med) var(--e-glide), border-color var(--t-med);
}
.faq-item:hover { border-color: var(--hairline-strong); }
.faq-item[open] { box-shadow: var(--shadow-toast); border-color: var(--hairline-strong); }

.faq-item summary {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 20px 22px;
  padding-inline-end: 18px;
  cursor: pointer;
  font-size: var(--fs-title-lg);
  font-weight: var(--fw-bold);
  line-height: 1.4;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }

/* A plus drawn from two bars; open turns it into a cross on the accent. */
.faq-toggle {
  position: relative;
  inline-size: 34px;
  block-size: 34px;
  flex: none;
  margin-inline-start: auto;
  border-radius: var(--r-pill);
  background: var(--bg-lift);
  transition: transform var(--t-med) var(--e-spring), background-color var(--t-fast);
}
.faq-toggle::before,
.faq-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  inline-size: 12px;
  block-size: 2px;
  border-radius: 2px;
  background: var(--ink);
}
.faq-toggle::after { transform: rotate(90deg); }
.faq-item[open] .faq-toggle { transform: rotate(45deg); background: var(--accent); }
.faq-item summary:hover .faq-toggle { background: var(--accent-soft); }
.faq-item[open] summary:hover .faq-toggle { background: var(--accent); }

.faq-answer {
  padding: 0 22px 22px;
  max-width: 68ch;
  color: var(--text-faint-strong);
}
[lang="ar"] .faq-answer { max-width: 60ch; }
.faq-answer a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* Animated open where the browser can size to auto; elsewhere it just opens. */
@supports (interpolate-size: allow-keywords) {
  .faq-item { interpolate-size: allow-keywords; }
  .faq-item::details-content {
    block-size: 0;
    overflow: hidden;
    transition: block-size var(--t-med) var(--e-glide), content-visibility var(--t-med) allow-discrete;
  }
  .faq-item[open]::details-content { block-size: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .faq-item::details-content { transition: none; }
}
