/* ══════════════════════════════════════════════════════════════════════════
   RESEARCH EGYPT ACADEMY — the public shell's CSS
   (resources/views/site/partials/_shell-head + _site-nav + _site-footer)

   Every public page that is not the home page wears the home page's own
   header, mobile menu and footer (resources/views/site/rea/_header and
   _footer) — the same markup, styled by the same five stylesheets the home
   page loads (public/assets/rea/css). Those stylesheets were written for a
   page that is entirely theirs: they reset ul/ol/h1–p/img/button/a, and they
   style .btn, .container, .section, .nav … — class names these pages' bodies
   use for their own, different designs. And the bodies' stylesheets
   (site.css, app.css …) style .nav, .btn, .burger, header, footer … in turn.

   So the two are kept apart with cascade layers instead of a forked copy of
   the chrome's CSS (_shell-head imports the rea files into layer `rea`):

     1 · layer `rea`        the home page's CSS, unchanged, lowest priority.
     2 · layer `rea-shell`  (a) one rule that reverts every element OUTSIDE
                            the chrome to the browser's defaults as far as the
                            rea layer is concerned — the page's own unlayered
                            CSS still applies on top, so a body renders
                            exactly as it did before the rea files were
                            loaded; (b) what the chrome needs on these pages
                            and not on the home page (the inherited type of
                            the home page's <body>, the room under the fixed
                            header, the account menu).
     3 · unlayered          the page's own CSS … and, last, the GUARD below:
                            every element INSIDE the chrome rolls back past the
                            unlayered styles (`all: revert-layer`) to the two
                            layers above, so no page rule reaches the header,
                            the menu or the footer. Doubled ids (2,0,0) beat
                            any single-id page rule wherever it is loaded.

   Custom properties are not part of `all`: the few names both stylesheets
   declare on :root (--navy, --orange, --sky, --ease, --maxw, --r*, --ok-soft)
   are re-declared on the chrome's two roots with the home page's values.

   Wave 2 (the bodies' redesign) switches a page's body over to the rea
   stack by putting class="rea-body" on its <html>: rule 2a stops applying.
   ══════════════════════════════════════════════════════════════════════════ */
@layer rea, rea-shell;

@layer rea-shell {
  /* 2a · outside the chrome, the rea layer does not exist.
     `revert` lands on the browser's defaults — and would also drop an
     element's PRESENTATION attributes (an SVG path's d/fill/stroke, an img
     or iframe's width/height, a table's width…), which the cascade ranks
     below every author layer. So elements that carry them are left out of
     the blanket revert and only lose what the rea files set on them by tag
     (img/svg: display:block, max-width; everything: box-sizing). */
  :root:not(.rea-body),
  :root:not(.rea-body) :not(.rea-shell, .rea-shell *, svg, svg *, img, iframe, video, canvas, embed, object, table, tr, td, th, col, colgroup, hr),
  :root:not(.rea-body) :not(.rea-shell, .rea-shell *, svg *)::before,
  :root:not(.rea-body) :not(.rea-shell, .rea-shell *, svg *)::after,
  :root:not(.rea-body) :not(.rea-shell, .rea-shell *)::placeholder,
  :root:not(.rea-body) :not(.rea-shell, .rea-shell *)::marker,
  :root:not(.rea-body) :not(.rea-shell, .rea-shell *)::selection {
    all: revert;
  }
  :root:not(.rea-body) :is(svg, img, iframe, video, canvas, embed, object):not(.rea-shell *) {
    display: revert; max-width: revert; box-sizing: revert; transition: revert;
  }
  :root:not(.rea-body) :is(svg *, table, tr, td, th, col, colgroup, hr):not(.rea-shell *) {
    box-sizing: revert;
  }

  /* 2b · the chrome's roots carry what the home page's <html>/<body> give
     its header and footer there: the type, the ink, and the tokens whose
     names the page stylesheets also use on :root. */
  .rea-shell {
    display: block;
    font-family: var(--f-body); font-size: 16.5px; font-weight: 400; font-style: normal; line-height: 1.7;
    color: var(--c-text); letter-spacing: normal; word-spacing: normal; text-transform: none; text-align: start;
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
    --ease: cubic-bezier(.16, 1, .3, 1);
    --maxw: 1840px;
    --navy: #0D1940; --orange: #F58220;
    --r-sm: 14px; --r: 26px; --r-lg: 34px;
    --sky: #E2ECFA; --ok-soft: #DFF3EA;
  }
  html[data-theme="dark"] .rea-shell { --sky: #0E1C4A; --ok-soft: rgba(62, 224, 160, .12); }

  /* the header is fixed (as on the home page, where the hero starts under
     it): the top root keeps its height in the flow, so a body starts below */
  .rea-shell--top { height: calc(var(--header-h) + 8px); }
  /* the footer stands on the home page's ground, whatever the body's is */
  .rea-shell--foot { background: var(--c-bg); overflow-x: clip; }

  /* the page you are on (site-chrome.js marks the links that point at it) */
  .rea-shell .footer__links a[aria-current="page"],
  .rea-shell .footer__legal a[aria-current="page"] { color: var(--c-hi-text); }
  .rea-shell .header__right .btn[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--c-hi); }

  /* ── the account menu (a signed-in visitor, in place of «trainee login») ──
     A disclosure, not an ARIA menu: button + list, opened on click (it holds
     «log out», so it never opens under a passing pointer). */
  .hacct { position: relative; display: flex; }
  .hacct__btn { gap: 8px; max-width: 220px; }
  .hacct__btn > span { overflow: hidden; text-overflow: ellipsis; }
  .hacct__btn svg { transition: transform .3s var(--ease); }
  .hacct.is-open .hacct__btn svg { transform: rotate(180deg); }
  .hacct__menu {
    position: absolute; inset-block-start: calc(100% + 10px); inset-inline-end: 0; z-index: 2;
    min-width: 220px; padding: 6px; display: grid; gap: 2px;
    border-radius: 18px; background: var(--c-card); border: 1px solid var(--c-line);
    box-shadow: 0 24px 60px -24px var(--c-shadow);
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity .2s, transform .3s var(--ease), visibility 0s .3s;
  }
  .hacct.is-open .hacct__menu { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .3s var(--ease); }
  .hacct__menu form { display: contents; }
  .hacct__i {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
    padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--c-text-2);
    text-align: start; transition: background .2s, color .2s;
  }
  .hacct__i:hover, .hacct__i:focus-visible { background: var(--c-hi-a); color: var(--c-text); }
  .hacct__i--out { color: var(--c-error); }
  .hacct__badge {
    min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
    background: var(--orange); color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
  }
  .mmenu__row form { display: contents; }
  @media (prefers-reduced-motion: reduce) {
    .hacct__menu, .hacct.is-open .hacct__menu, .hacct__btn svg { transition: none; }
  }
}

/* 3 · the guard: inside the chrome only the two layers above count */
#reaShellTop#reaShellTop,
#reaShellTop#reaShellTop *,
#reaShellTop#reaShellTop *::before,
#reaShellTop#reaShellTop *::after,
#reaShellTop#reaShellTop *::placeholder,
#reaShellFoot#reaShellFoot,
#reaShellFoot#reaShellFoot *,
#reaShellFoot#reaShellFoot *::before,
#reaShellFoot#reaShellFoot *::after,
#reaShellFoot#reaShellFoot *::placeholder {
  all: revert-layer;
}
