/* ===========================================================================
   AL-SAEED ECONOMIC GROUP  —  pages/p-companies.css
   ---------------------------------------------------------------------------
   Companies. The seventh distinct visual key:
     Home            teal filled eyebrow, expanding six-panel strip
     About           gold filled eyebrow, timeline on one rule
     Chairman        gold-on-dark eyebrow, letter on the dark ground
     Leadership      outlined eyebrow, portrait grid with no card boxes
     Sectors         rule-and-label eyebrow, alternating full-width rows
     Sector detail   dark filled eyebrow pill, one page as a tab set
     Companies       NO pill and NO leading rule - the label is UNDERLINED,
                     a fine gold hairline directly beneath the text - and the
                     page is a filterable directory: a crest plate per company
                     in a card grid, with a pill filter bar above it.

   A directory is the one structure none of the six earlier pages uses, which
   is what keeps this page from reading like any of them. The filter is the
   page's only interaction, so it is built to be usable without JavaScript
   too: every card is in the HTML and visible until a filter is pressed.
   Direction-agnostic: logical properties throughout.
   =========================================================================== */

.page-companies{
  --eyebrow-fg:var(--gold-dk);
  --page-bg:var(--white);
}

/* The seventh eyebrow treatment: no pill, no fill, no border box, no leading
   rule - just the label with a fine gold hairline under it. `fit-content`
   keeps the rule the width of the words rather than the column. */
.page-companies .eyebrow{
  background:none;box-shadow:none;border:0;border-radius:0;
  padding:0 0 .4375rem;
  color:var(--eyebrow-fg);
  border-bottom:.0625rem solid var(--gold);
  width:fit-content;
}
.page-companies .eyebrow--onDark{
  color:var(--gold-lt);
  border-bottom-color:rgba(201,169,84,.55);
}

/* ---------------------------------------------------------------------------
   INTRO
   --------------------------------------------------------------------------- */
.intro{background:var(--white)}
.intro__text{
  color:var(--ink-2);font-size:var(--fs-lg);
  max-width:min(46rem,100%);margin:var(--s-3) 0 0;
}

/* Three counts, each one traceable to the reference rather than invented:
   what the design actually shows, what the group states, and the sectors the
   site is organised around. Rendered as a definition list because that is
   what they are - a label and its figure. */
.tally{
  display:grid;gap:var(--s-3) var(--gutter);
  grid-template-columns:1fr;
  margin:clamp(2rem,1.5rem + 2vw,3rem) 0 0;
}
@media (min-width:40rem){
  .tally{grid-template-columns:repeat(3,minmax(0,1fr))}
}
/* dt comes first in the markup, as a definition list requires, but the
   figure is what the eye should meet first - so the cell reverses visually
   and the reading order stays "label, then figure" for a screen reader. */
.tally__cell{
  display:flex;flex-direction:column-reverse;
  padding-top:var(--s-2);
  border-top:.125rem solid var(--gold);
}
.tally__n{
  display:block;margin:0;font-family:var(--ff-head, inherit);font-weight:700;
  font-size:clamp(1.75rem,1.3rem + 1.8vw,2.5rem);line-height:1.05;
  color:var(--ink);font-variant-numeric:tabular-nums;
}
.tally__k{
  display:block;margin-top:.375rem;
  font-size:var(--fs-sm);color:var(--muted);
}

/* ---------------------------------------------------------------------------
   DIRECTORY
   --------------------------------------------------------------------------- */
/* The cream band is what separates the directory from the white intro above
   it without needing a rule. `clip` rather than `hidden` so a card's hover
   lift can never widen the page, while position:sticky stays possible. */
.directory{background:var(--cream);overflow-x:clip}

.directory__head{
  display:flex;flex-wrap:wrap;gap:var(--s-3);
  align-items:flex-end;justify-content:space-between;
}

/* --- filter bar --------------------------------------------------------- */
.filters{
  display:flex;flex-wrap:wrap;gap:.5rem;
  margin:clamp(1.75rem,1.25rem + 2vw,2.5rem) 0 0;
}
.filter{
  display:inline-flex;align-items:center;gap:.5rem;
  padding:.625rem 1.125rem;
  font-family:var(--ff-head, inherit);
  font-size:var(--fs-sm);font-weight:600;
  color:var(--ink-2);
  background:var(--white);
  border:0;border-radius:var(--r-pill);
  box-shadow:inset 0 0 0 .0625rem var(--line);
  cursor:pointer;
  transition:color var(--dur-fast) var(--ease),
             background var(--dur-fast) var(--ease),
             box-shadow var(--dur-fast) var(--ease);
}
.filter:hover{color:var(--ink);box-shadow:inset 0 0 0 .0625rem var(--gold)}
/* aria-pressed is the state, so it is also the selector - the DOM cannot go
   out of step with what is drawn */
.filter[aria-pressed="true"]{
  color:var(--white);background:var(--dark);
  box-shadow:inset 0 0 0 .0625rem var(--dark);
}
.filter__n{
  font-size:var(--fs-xs);font-weight:700;
  color:var(--gold-dk);font-variant-numeric:tabular-nums;
}
.filter[aria-pressed="true"] .filter__n{color:var(--gold-lt)}

.filters__status{
  margin:var(--s-2) 0 0;
  font-size:var(--fs-sm);color:var(--muted);
}

/* --- the grid ----------------------------------------------------------- */
.firms{
  display:grid;gap:var(--gutter);
  grid-template-columns:1fr;
  margin:clamp(1.75rem,1.25rem + 2vw,2.5rem) 0 0;
  padding:0;list-style:none;
}
@media (min-width:36rem){ .firms{grid-template-columns:repeat(2,minmax(0,1fr))} }
@media (min-width:62rem){ .firms{grid-template-columns:repeat(3,minmax(0,1fr))} }

.firm{
  display:flex;flex-direction:column;
  height:100%;
  background:var(--white);
  border-radius:var(--r-md);
  box-shadow:var(--sh-1);
  overflow:hidden;position:relative;
  transition:transform var(--dur) var(--ease),
             box-shadow var(--dur) var(--ease);
}
/* the gold rule that draws itself across the top edge on hover: scaleX from
   the leading edge, so it grows left-to-right in English and right-to-left in
   Arabic and Kurdish without a mirrored rule */
.firm::before{
  content:"";position:absolute;inset-inline:0;top:0;z-index:2;
  height:.1875rem;background:var(--gold);
  transform:scaleX(0);transform-origin:left;
  transition:transform var(--dur) var(--ease);
}
/* transform-origin has no logical keyword that browsers accept today, so the
   leading edge is named explicitly for each direction */
[dir="rtl"] .firm::before{transform-origin:right}
.firm:hover,
.firm:focus-within{transform:translateY(-.25rem);box-shadow:var(--sh-2)}
.firm:hover::before,
.firm:focus-within::before{transform:scaleX(1)}

/* The crest plate. A fixed height rather than an aspect ratio: the six crests
   are different shapes (440x257 to 440x446) and what has to line up across a
   row is the plate, not the artwork. The image is `contain`, never `cover`,
   because a clipped logo is a wrong logo. */
.firm__plate{
  display:flex;align-items:center;justify-content:center;
  /* Sized so the crests land at 112-144px tall, which is where the
     reference draws them (measured: 126-144px). The plate height is the
     binding constraint, not its width - each crest is 440px wide natively
     and taller than the space, so it is max-height that decides. */
  height:clamp(9.5rem,8rem + 4vw,11.5rem);
  padding:1.25rem var(--s-3);
  background:var(--cream);
  border-bottom:.0625rem solid var(--line);
  overflow:hidden;
}
/* The crest is capped, not stretched. A height of 100% on the <img> is the
   thing to avoid here: a <picture> at auto height becomes the containing
   block, the percentage resolves to auto, and the image falls back to its
   440px intrinsic width - which is how the crests ended up drawn at full
   size, spilling out of the plate and over the company name underneath.
   max-width/max-height with auto dimensions scales each crest down to fit
   its plate and leaves the shorter ones alone, which is what object-fit
   contain should do for six logos of six different shapes. */
.firm__plate picture{
  display:flex;align-items:center;justify-content:center;
  width:100%;height:100%;min-height:0;
}
.firm__plate img{
  max-width:100%;max-height:100%;width:auto;height:auto;
  object-fit:contain;object-position:center;
  transition:transform var(--dur) var(--ease);
}
.firm:hover .firm__plate img{transform:scale(1.04)}

.firm__body{
  display:flex;flex-direction:column;
  gap:.5rem;flex:1 1 auto;
  padding:var(--s-3);
}
.firm__idx{
  font-size:var(--fs-xs);font-weight:700;
  color:var(--gold-dk);letter-spacing:.12em;
  font-variant-numeric:tabular-nums;
}
.firm__name{
  margin:0;font-size:var(--fs-lg);line-height:1.25;
  color:var(--ink);
}
.firm__sector{
  margin:0;font-size:var(--fs-xs);font-weight:600;
  color:var(--teal-dp);letter-spacing:.06em;text-transform:uppercase;
}
/* a company whose sector the reference never states: said plainly rather
   than guessed, and in the muted grey so it does not read as a sector */
.firm__sector--unknown{color:var(--muted);text-transform:none;letter-spacing:0}
.firm__text{
  margin:.25rem 0 0;font-size:var(--fs-sm);
  color:var(--muted);
}
/* pushes the link to the bottom edge so every card's link sits on one line
   across a row, whatever the length of the text above it */
.firm__foot{margin-top:auto;padding-top:var(--s-3)}

/* the "Read more" link: a label and an arrow that steps forward on hover */
.firm__more{
  display:inline-flex;align-items:center;gap:.5rem;
  font-family:var(--ff-head, inherit);
  font-size:var(--fs-sm);font-weight:600;
  color:var(--ink);
}
.firm__more svg{
  width:1rem;height:1rem;flex:0 0 auto;
  fill:none;stroke:var(--gold-btn);stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round;
  transition:transform var(--dur-fast) var(--ease);
}
.firm__more:hover{color:var(--gold-dk)}
/* forward is +X in LTR and -X in RTL; the logical property does not exist for
   transforms, so the direction is switched explicitly */
.firm__more:hover svg{transform:translateX(.1875rem)}
[dir="rtl"] .firm__more:hover svg{transform:translateX(-.1875rem)}

/* shown only when a filter matches nothing - it cannot happen with the counts
   as they stand, but the filter is data-driven and the counts will change */
.firms__empty{
  margin:var(--s-4) 0 0;
  font-size:var(--fs-lg);color:var(--muted);
}

/* --- filtering ---------------------------------------------------------- */
/* A card being filtered out is removed from the layout AND from the
   accessibility tree, so a screen reader never reads a hidden company;
   `[hidden]` in core.css carries the !important that beats `display:flex`. */
.firm[hidden]{display:none}
/* cards arriving back into the grid fade up once, quickly - the same gesture
   the scroll reveal uses, so filtering feels like part of the page */
.firm.is-entering{animation:firmIn var(--dur) var(--ease-out) both}
@keyframes firmIn{
  from{opacity:0;transform:translateY(.625rem)}
  to{opacity:1;transform:none}
}

/* ---------------------------------------------------------------------------
   MISSING-COMPANY NOTE
   ---------------------------------------------------------------------------
   A quiet band between the directory and the closing call to action, on the
   dark ground so it reads as the group speaking rather than as another card.
   --------------------------------------------------------------------------- */
.roster{background:var(--dark-2);color:var(--white)}
.roster__inner{
  display:grid;gap:var(--s-3) var(--gutter);
  grid-template-columns:1fr;align-items:center;
}
@media (min-width:62rem){
  .roster__inner{grid-template-columns:minmax(0,1.3fr) minmax(0,1fr)}
}
.roster__title{margin:0;font-size:var(--fs-h3);color:var(--white)}
.roster__text{
  margin:var(--s-2) 0 0;color:rgba(255,255,255,.76);
  max-width:56ch;
}
.roster__actions{display:flex;flex-wrap:wrap;gap:var(--s-2)}
@media (min-width:62rem){
  .roster__actions{justify-content:flex-end}
}

/* ---------------------------------------------------------------------------
   REDUCED MOTION
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion:reduce){
  .firm,
  .firm::before,
  .firm__plate img,
  .firm__more svg{transition:none}
  .firm:hover,
  .firm:focus-within{transform:none}
  .firm.is-entering{animation:none}
}
