/* ==========================================================================
   THE NOTIFICATIONS BELL AND ITS PANEL
   Built from _incoming/design/ui-change-requests/04-1b (11 Oct 2026),
   in Madar's own tokens.

   WHAT WAS TAKEN FROM THE REFERENCE and what was not. The reference is a
   LAYOUT PATTERN, which is what the change-request README asks for: a
   rounded panel hanging under the bell, a header carrying the title and
   one clearing action, a scrolling list of two-line rows, an unread dot
   at the inline-end of each row and a tinted ground behind the unread
   ones. Every COLOUR here is a Madar token -- the reference product's
   translucent charcoal and orange accent are its identity, not ours, and
   DESIGN_SYSTEM §1.3 forbids a hex outside tokens.css in any case. In
   dark mode this panel is dark because the tokens are, not because a
   colour was copied.

   NO SHADOW, which is §1's rule and the recorded tiebreak for popovers
   in this product (the account menu's own comment in base.css says the
   same thing): the 1px border is what separates the panel from the page.
   ========================================================================== */

/* The bell plus its overlay. `relative` so the panel can hang off the
   BELL rather than off the bar's end edge the way the account menu does
   -- the account control is the last thing in the bar and the bell is
   not, and an offset measured from the bar's end would drift every time
   the signed-in person's name changes length. */
.notif {
  position: relative;
  display: flex;
  align-items: center;
}

/* The button itself is `.appbar__icon-btn`, unchanged. This adds only
   the one thing a <button> needs that the <a> it replaced did not. */
.notif__bell {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

/* No box of its own -- it is a wrapper for the two things below, one of
   which is fixed to the viewport and the other anchored to `.notif`. */
.notif-menu {
  display: contents;
}

/* THE SHELL'S ONE SCRIM TECHNIQUE -- `--ink` at an opacity, never a
   fresh rgba(). The drawer, the account menu, the calendar's filter
   sheet and the dashboard's modal all settled on this so the product
   carries ONE scrim; a literal rgb() would also be a hard-coded colour,
   which §1.3 forbids and which core/test_design_rules.py would NOT
   catch, because it scans for hex. */
.notif-menu__scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--ink);
  opacity: .34;
}

.notif-menu__panel {
  position: absolute;
  z-index: 61;
  /* 6px UNDER THE BAR, not under the button, and the difference was
     visible in the first capture: `calc(100% + var(--sp-6))` measures
     from the 36px button, which is centred in the 56px bar, so the
     panel began at 52px and sat 4px INSIDE the bar's own bottom
     border. The account menu hangs 6px below the bar and this now
     matches it -- 10px of centring above the button, its 36px, then
     the 10px below it, then the gap. */
  inset-block-start: calc(100% + 10px + var(--sp-6));
  inset-inline-end: 0;
  /* 380, not 360. The reference fits its one-line rows on one line;
     at 360 a real Omani guest name («يوسف بن علي الرواحي») wrapped
     every payment row to three. Measured against seeded data, which
     is the whole reason CLAUDE.md's click-through rule insists on
     real-length names. */
  inline-size: 380px;
  /* A phone never sees this (the bar is desktop-only), but a 1024px
     laptop with the panel anchored near the bar's end still must not
     push the page sideways -- the band this project has measured two
     horizontal-overflow defects in. */
  max-inline-size: calc(100vw - var(--sp-32));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.notif-menu__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-12);
  padding: var(--sp-12) var(--sp-14);
  border-block-end: 1px solid var(--line);
}

.notif-menu__title {
  margin: 0;
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--ink);
}

/* «تعليم الكل كمقروء». The reference draws this as an accent-coloured
   text action with a tick; the accent is Madar's `--primary`. */
.notif-menu__readall {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  border: 0;
  background: none;
  padding: var(--sp-4) var(--sp-6);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: var(--fs-12);
  font-weight: 600;
  font-family: inherit;
  color: var(--primary);
}
.notif-menu__readall:hover { background: var(--chip); }
.notif-menu__readall .icon { flex-shrink: 0; }

/* THE LIST SCROLLS INSIDE THE PANEL, which is the reference's own
   behaviour and the only one that works: the feed is capped at 50 rows
   and a panel 50 rows tall would run off the bottom of a laptop screen.
   `overscroll-behavior` so reaching the end does not start scrolling
   the page underneath. */
.notif-menu__list {
  max-block-size: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* The empty state is ONE QUIET LINE, not `partials/_empty_state.html`.
   That partial is a full state panel with an icon, a title and a body
   explaining why a SCREEN is empty; inside a 360px dropdown it would be
   larger than the content it stands in for. */
.notif-menu__empty {
  margin: 0;
  padding: var(--sp-26) var(--sp-14);
  text-align: center;
  font-size: var(--fs-13);
  color: var(--muted);
}

/* The skeleton's generic lines, given this panel's padding. The lines
   themselves are base.css's -- `partials/_skeleton.html`'s own docstring
   asks a region whose shape differs to write its own markup from
   `.skeleton__line`, which is what the list partial does. */
.notif-menu__list .skeleton {
  padding: var(--sp-14);
}

/* ---- one row ---- */

.notif-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-10);
  /* TIGHTER THAN THE FIRST CUT, measured against the reference: at
     12px padding, 1.55 line-height and a 4px gap a two-line row came
     out ~110px against the reference's ~85, so the panel showed four
     rows where the drawing shows six. */
  padding: var(--sp-10) var(--sp-14);
  border-block-end: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}
.notif-row:last-child { border-block-end: 0; }
.notif-row:hover { background: var(--surface-2); }

/* THE UNREAD TINT, and it had to be changed after the first capture:
   `--surface-2` is #FCFCFA against `--surface`'s #FFFFFF, a 1%
   difference that is simply not visible, so the reference's clearly
   grouped unread block read as one flat list. `--chip` is the
   product's existing neutral fill and is actually perceptible in both
   themes.

   Which also moved the HOVER fill. `--chip` was the hover, and a
   hover that lands on the same colour as "unread" tells the reader
   nothing -- so read rows now lift to `--surface-2` and unread ones
   to `--chip-2`. Still a surface token either way: the dot carries
   the signal, the ground only groups. */
.notif-row--unread { background: var(--chip); }
.notif-row--unread:hover { background: var(--chip-2); }

.notif-row__body {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.notif-row__text {
  font-size: var(--fs-13);
  line-height: 1.45;
  color: var(--ink);
}

/* «منذ 27 دقيقة», under the sentence -- the reference's own placement. */
.notif-row__age {
  font-size: var(--fs-11);
  color: var(--muted);
}

/* LAST CHILD, so in RTL it sits at the far inline-end of the row, which
   is where the reference draws it. `margin-block-start` nudges it onto
   the first line of text rather than the row's vertical centre, because
   a two-line row would otherwise float it between the lines. */
.notif-row__dot {
  flex-shrink: 0;
  inline-size: 8px;
  block-size: 8px;
  margin-block-start: var(--sp-6);
  border-radius: var(--radius-pill);
  background: var(--badge-urgent);
}


/* ==========================================================================
   THE PANEL ON A PHONE (14 Oct 2026)

   Until the shell's two bars were merged, this file needed no media query at
   all and said so: "a phone never sees this (the bar is desktop-only)". The
   bell is in the one bar now, at every width, so the panel has to answer for
   itself below 1024px.

   `position: fixed` AND NOT the anchored `absolute` above. Anchoring to
   `.notif` puts a 380px panel against the bar's inline-end on a 360px
   screen, where there is 348px of room -- and the anchor's own
   `inset-block-start: calc(100% + 10px + 6px)` is measured from a 36px
   button centred in a 56px bar, neither of which is true here. Fixed to the
   viewport with an 8px gutter either side is the only arrangement that is
   correct at 360, 390 and 414 without three numbers.

   THE 65px IS THE BAR'S OWN HEIGHT at this width -- 10px of padding, a 44px
   tile, 11px of padding -- written as a literal rather than as a custom
   property. A `--phone-bar-h` declared locally is not a token, and
   `core/test_design_rules.py` rightly refuses a `var()` whose name is in no
   token table; adding it to the table would put one breakpoint's measurement
   in the product's shared vocabulary for two rules' benefit.

   AND THE LIST SCROLLS TO THE VIEWPORT, not to 420px. A 420px list inside a
   780px phone leaves the panel's head and its «تعليم الكل كمقروء» on screen
   and everything else below the fold; the feed is capped at 50 rows, so on a
   short phone it has to give up height rather than overflow it.
   ========================================================================== */
@media (max-width: 1023px) {
  .notif-menu__panel {
    position: fixed;
    inset-inline: var(--sp-8);
    inset-block-start: calc(65px + var(--sp-6));
    inline-size: auto;
    max-inline-size: none;
  }
  .notif-menu__list {
    max-block-size: calc(100vh - 185px);   /* older engines */
    max-block-size: calc(100dvh - 185px);  /* the visible viewport, which is the one that matters */
  }
}

/* «تعليم الكل كمقروء» is a 28px text action, which is a desktop pointer's
   size. The phone sweep measured it at 116x28 at all three phone widths. */
@media (max-width: 1023px) {
  .notif-menu__readall {
    min-block-size: var(--control-height);
    padding-inline: var(--sp-10);
  }
}
