/* Reusable UI components: dropdown menus, modals, toggle switches.
   One job: the shared interactive widgets used across pages. */

/* ── Dropdown menu (header popovers) ────────────────────────────── */
.menu-pop {
  transform-origin: top;
  animation: menu-pop .14s ease-out;
}

/* A <details>-based row menu: hide the native disclosure triangle so the summary is just a button. */
.js-menu > summary { list-style: none; cursor: pointer; }
.js-menu > summary::-webkit-details-marker { display: none; }

@keyframes menu-pop {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Modal / popup ──────────────────────────────────────────────── */
.modal-pop {
  animation: modal-pop .18s ease-out;
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Touch targets ───────────────────────────────────────────────
   `.tap` marks a control that is comfortable with a mouse but too small for a fingertip — a filter
   chip, a tab, an icon button, a "Edit" link inside a row. Measured across the app at 390px, 133 such
   controls existed, the smallest 20px tall.

   Two decisions worth stating:

   1. It raises the height ONLY under `pointer: coarse`. A mouse is precise and a 26px button is fine
      for it; inflating every chip on the desktop would change a layout the design already settled.
      This is a media query about the input device, not the screen — a touch laptop gets the larger
      target at 1440px, and a phone in a desktop-width emulator does not lose it.

   2. It centres its content, because `min-height` does nothing to an inline box. Most of these
      controls are already `inline-flex items-center`; for the ones that are not, this is what makes
      the extra height wrap the label instead of sitting under it.

   44px is the figure both Apple's and Google's guidance land on for a primary target. */
.tap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (pointer: coarse) {
  .tap { min-height: 44px; }

  /* A label wrapping a checkbox or a switch IS the target — the input itself is 16px, or `sr-only`
     and has no box at all. Raising the label is the only thing that helps. */
  .tap-row { min-height: 44px; }

  /* For a control that must STAY small to look right — the 18px tick box that completes a task — the
     answer is not to inflate the box but to widen what counts as a hit. This lays an invisible 44px
     pad over the centre, so the finger has room the eye does not have to see. */
  .tap-hit { position: relative; }
  .tap-hit::after {
    content: "";
    position: absolute;
    top: 50%;
    inset-inline-start: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }
  html[dir="rtl"] .tap-hit::after { transform: translate(50%, -50%); }
}

/* ── Controls that only appear on hover ──────────────────────────
   Five places in the app hide a control with `opacity-0` and reveal it with `group-hover:opacity-100`
   — rename and delete on a saved conversation, the copy button on a transcript line, the edit and
   remove buttons on a minutes row. On a desktop that is a tidy way to keep a row calm.

   On a phone it is a dead control. There is no hover, so the button never becomes visible and never
   gets touched; the feature simply does not exist for that reader.

   `hover: none` is the honest test, and it is deliberately NOT `pointer: coarse`: a laptop with a
   touchscreen still has a mouse, so it keeps the quiet-until-hovered behaviour it was designed for.
   Only a device that cannot hover at all gets the controls shown outright.

   This sits in components.css, which _Layout links AFTER tailwind.css — same specificity, later
   declaration, so it wins over the `.opacity-0` utility without needing !important. */
@media (hover: none) {
  .group-hover\:opacity-100 { opacity: 1; }
}

/* ── Mobile navigation drawer ────────────────────────────────────
   Why this is CSS and not a Tailwind utility: `translate-x-*` is PHYSICAL. The drawer is pinned to the
   leading edge (`start-0`), which is the left in English and the right in Arabic, so a single
   `-translate-x-full` would slide it off-screen in one language and straight across the page in the
   other. The transform has to mirror with the direction, and only a `[dir]` selector can do that.

   The panel is also `hidden` until first opened, so it is skipped by the accessibility tree and by
   keyboard navigation while closed. mobile-nav.js clears the attribute one frame BEFORE adding
   `.is-open`, because a transition cannot run out of `display: none`. */
.nav-drawer {
  transform: translateX(-100%);
  transition: transform .22s cubic-bezier(.32, .72, 0, 1);
  will-change: transform;
}

html[dir="rtl"] .nav-drawer { transform: translateX(100%); }

.nav-drawer.is-open,
html[dir="rtl"] .nav-drawer.is-open { transform: translateX(0); }

/* The scrim fades rather than appearing, so the drawer reads as sliding over the page. */
#navScrim { transition: opacity .2s ease; }
#navScrim.is-open { opacity: 1; pointer-events: auto; }

/* Somebody who asked for less motion gets the panel placed, not thrown. */
@media (prefers-reduced-motion: reduce) {
  .nav-drawer { transition: none; }
  #navScrim { transition: none; }
}

/* While the drawer is open the page behind it must not scroll — otherwise a touch-drag on the scrim
   moves the article underneath and the reader loses their place. */
body.nav-drawer-open { overflow: hidden; }

/* ── Toggle switch (notification preferences) ───────────────────── */
.tg-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #ECECF1;
  position: relative;
  transition: .2s;
  display: inline-block;
  flex-shrink: 0;
}

.tg-track::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
  transition: .2s;
}

.peer:checked + .tg-track { background: #383857; }
.peer:checked + .tg-track::after { inset-inline-start: 21px; }
.peer:disabled + .tg-track { opacity: .6; }

/* ── Plan picker ────────────────────────────────────────────────────────────
   A radio group that looks like a pricing table. The whole card is the label, so the hit target is the
   card rather than an 8px dot — this is chosen once, under pressure, by someone signing up. */

/* min-width:0 lets a card shrink below its content's min width. Without it the nowrap price sets a
   floor on the grid track and the whole picker overflows sideways in anything narrow (a dialog). */
.plan-option { display: block; cursor: pointer; min-width: 0; }

/* Off-screen rather than display:none — a hidden input is skipped by keyboard navigation, and this is
   a radio group that must stay tabbable and announce itself. */
.plan-option-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.plan-option-body {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  height: 100%;
  border: 1px solid rgb(var(--c-line));
  border-radius: 14px;
  padding: 1rem 1.1rem;
  background: rgb(var(--c-surface));
  transition: border-color .15s ease, box-shadow .15s ease;
}

.plan-option:hover .plan-option-body { border-color: rgb(var(--c-ink) / .35); }

.plan-option-input:checked + .plan-option-body {
  border-color: rgb(var(--c-ink));
  box-shadow: 0 0 0 3px rgb(var(--c-ink) / .12);
}

/* The focus ring has to come from the INPUT, which is off-screen — so draw it on the card instead, or
   a keyboard user cannot see where they are. */
.plan-option-input:focus-visible + .plan-option-body {
  outline: 2px solid rgb(var(--c-ink) / .5);
  outline-offset: 2px;
}

.plan-option-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.plan-option-name { font-size: .95rem; font-weight: 600; color: rgb(var(--c-ink)); }
.plan-option-price { font-size: 1.05rem; font-weight: 700; color: rgb(var(--c-ink)); white-space: nowrap; }
.plan-option-unit { font-size: .68rem; font-weight: 500; color: rgb(var(--c-muted)); display: block; }
.plan-option-free { font-size: .82rem; font-weight: 600; color: #1F5946; }
.plan-option-desc { font-size: .78rem; color: rgb(var(--c-muted)); line-height: 1.5; }

.plan-option-list {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-top: auto;
  padding-top: .6rem;
  border-top: 1px solid rgb(var(--c-line));
}

.plan-option-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-size: .75rem;
  color: rgb(var(--c-muted));
}
.plan-option-row > :last-child { color: rgb(var(--c-ink)); font-weight: 500; }

/* ── Meeting timeline: the busy veil over the card while a search or comparison runs ──────────
   Laid OVER the card rather than replacing it, so the timeline the reader was looking at stays
   where it was and the card does not collapse to spinner height and jump the page. */
.tl-busy {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 1rem;
  background: rgb(var(--c-surface) / .82);
  backdrop-filter: blur(1px);
  color: rgb(var(--c-muted));
  font-size: 13px;
  text-align: center;
  padding: 1rem;
}

.tl-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid rgb(var(--c-track));
  border-top-color: rgb(var(--c-ink));
  animation: tl-spin .7s linear infinite;
}

.tl-busy-label { font-weight: 500; }
.tl-error { font-size: 13px; font-weight: 500; color: #B42318; }

@keyframes tl-spin { to { transform: rotate(360deg); } }

/* Somebody who asked for less motion still needs to see that it is working — fade instead of spin. */
@media (prefers-reduced-motion: reduce) {
  .tl-spinner { animation: tl-spin-fade 1.2s ease-in-out infinite; }
  @keyframes tl-spin-fade { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
}
