/* ============================================================================
   cb-mobile.css — phone layout for www.casablancabourse.com

   m.casablancabourse.com is gone, so this one document has to serve a 390px
   phone as well as a 1440px desktop. Rather than editing mystyle.css (2 800
   lines, a lot of it !important and load-bearing for other pages), every
   phone-only change lives here and this file is loaded last, so it wins on
   equal specificity. Nothing outside a media query is declared: on a desktop
   this stylesheet is inert.

   Breakpoints
     760px — the phone/small-tablet tier. Everything is here.
     400px — the small-phone tier (iPhone SE / mini). Tightening only.
   ========================================================================== */

@media (max-width: 760px) {

  /* Safari inflates text in landscape unless told not to; with a layout this
     dense that silently breaks every column width below. */
  html { -webkit-text-size-adjust: 100%; }

  /* Nothing on a phone should scroll sideways except the two elements that
     opt into it explicitly (the ticker rail and the nav). */
  body { overflow-x: hidden; }

  /* ==========================================================================
     1. Ticker bar
     A single .s-item was 400–440px wide — wider than the whole screen, so the
     bar showed one company at a time and read as a broken marquee rather than
     a ticker. Shrink it until three or four fit.

     The ticker's own rules live in a <style> block inside <body>, which comes
     after this file in document order, so a plain .s-item would lose the tie
     on equal specificity. The doubled class buys a point and settles it
     without reaching for !important.
     ========================================================================== */

  .sticker-bar.sticker-bar { height: 40px; }
  .sticker-viewport.sticker-viewport {
    -webkit-mask-image: linear-gradient(to right, transparent 0, black 14px, black calc(100% - 14px), transparent 100%);
            mask-image: linear-gradient(to right, transparent 0, black 14px, black calc(100% - 14px), transparent 100%);
  }
  .s-item.s-item { height: 40px; padding: 0 13px; gap: 6px; }
  .s-sym.s-sym     { font-size: 12px; letter-spacing: 0; }
  .s-price.s-price { font-size: 12px; }
  .s-up.s-up, .s-dn.s-dn, .s-flat.s-flat { font-size: 12px; }
  /* The "DH" suffix and the separating dot carry inline style attributes, so
     these are the only two rules in the file that need !important. */
  .s-price span { font-size: 10px !important; }
  .s-item > span[style] { font-size: 12px !important; }

  /* ==========================================================================
     2. Header
     The brand headline was 300px wide, which pushed the two store buttons onto
     a row of their own and made the header 208px tall before any content. Cut
     the headline down until the buttons fit beside it.
     ========================================================================== */

  .menu_header { padding: 8px 16px 10px; }
  .menu_header .brand h1 { font-size: 1.3rem; line-height: 1.2; }
  .menu_header .tagline  { font-size: 0.78rem; }
  .header-appstore { padding: 0; gap: 8px; }
  /* mystyle.css only turns the buttons into 44px circles below 480px; at 600px
     the labelled pills still wrap. Circles from 760px down. */
  .appstore-text { display: none; }
  .appstore-button {
    padding: 10px;
    border-radius: 50%;
    width: 42px; height: 42px;
    justify-content: center;
    margin-left: 0 !important;
  }
  .appstore-button svg { width: 22px; height: 22px; }
  .header-search-wrapper { margin: 10px 0 0; }
  /* 16px is the threshold below which iOS zooms the page on focus. */
  .company-search-input { font-size: 16px !important; padding: 12px 40px 12px 44px !important; }

  /* ==========================================================================
     3. Main navigation
     It already scrolls horizontally, but with no affordance: the last visible
     link was sliced mid-word and looked like a rendering bug. Fade the trailing
     edge so the cut is obviously deliberate, and snap so links land whole.
     ========================================================================== */

  nav.main-nav {
    padding: 0 12px;
    gap: 0;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 34px), transparent 100%);
            mask-image: linear-gradient(to right, black calc(100% - 34px), transparent 100%);
  }
  nav.main-nav::-webkit-scrollbar { display: none; }
  nav.main-nav a {
    scroll-snap-align: start;
    font-size: 13.5px;
    /* 44px tall: the minimum comfortable touch target. */
    padding: 13px 11px;
    border-radius: 0;
  }

  /* ==========================================================================
     4. Page title and the two stats lines
     ========================================================================== */

  h1 { font-size: 1.15rem; line-height: 1.35; padding: 0 16px; }
  .category-stats-bar-index {
    font-size: 13px;
    line-height: 1.7;
    padding: 0 16px;
  }
  /* The pills are given an explicit height: 18px on top of 8px of vertical
     padding, so their text sits proud of the rounded background. Let them size
     to their content instead, and wrap rather than run off the edge. */
  .ranking-bar {
    margin: 0 16px;
    padding: 8px 10px;
    font-size: 13px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .ranking-bar span.option { height: auto; margin-left: 0; padding: 7px 12px; }

  /* ==========================================================================
     5. The classement table — the main event
     81 rows x 9 columns, 11 174px tall, scrolling sideways so that a phone
     showed rank and company name and hid the two numbers anyone actually came
     for. Drop the five columns that cannot be read at this width and let the
     four that matter fit without any horizontal scroll.

     Columns: 1 rank / 2 name / 3 favourite / 4 vol. actions / 5 vol. DH /
              6 capitalisation / 7 prix / 8 aujourd'hui / 9 sparkline

     The cells are hidden, not removed, so :nth-child() indices are unchanged
     and the existing sort script keeps working untouched.
     ========================================================================== */

  .table-responsive { overflow-x: visible; }

  #tableEses {
    width: 100%;
    table-layout: fixed;
    margin: 12px 0 0;
  }

  #tableEses tr > :nth-child(3),
  #tableEses tr > :nth-child(4),
  #tableEses tr > :nth-child(5),
  #tableEses tr > :nth-child(6),
  #tableEses tr > :nth-child(9) { display: none; }

  /* Prix carries a "DH" suffix and Aujourd'hui an arrow glyph, so both need
     more room than the bare figure suggests; short-changing them ran the two
     columns into each other on four-digit prices. The company name absorbs
     the difference and ellipsises. */
  #tableEses tr > :nth-child(1) { width: 30px; }
  #tableEses tr > :nth-child(7) { width: 84px; }
  #tableEses tr > :nth-child(8) { width: 76px; }

  /* The sort arrows are a 16px image beside a label; at this width there is
     room for one or the other. Keep the label — the whole header cell is the
     click target anyway. */
  .marketcap-table thead th {
    padding: 10px 6px;
    font-size: 10.5px;
    letter-spacing: 0.02em;
  }
  .marketcap-table thead th .Sorttable { display: none; }
  .marketcap-table thead th .th_title { white-space: nowrap; }

  /* "Classement" and "Aujourd'hui" are wider than the columns they now label,
     and with table-layout:fixed they spill past the table's right edge. Swap
     in short labels for sighted users. font-size:0 hides the glyphs but leaves
     the original words in the accessibility tree, so a screen reader still
     announces the full column name. */
  #tableEses thead th:nth-child(1) .th_title,
  #tableEses thead th:nth-child(8) .th_title { font-size: 0; }
  #tableEses thead th:nth-child(1) .th_title::after { content: "#";    font-size: 10.5px; }
  #tableEses thead th:nth-child(8) .th_title::after { content: "Var."; font-size: 10.5px; }
  #tableEses thead th:nth-child(8) { text-align: right; }

  .marketcap-table td,
  .table.marketcap-table td,
  table.marketcap-table td {
    padding: 9px 6px;
    font-size: 13px;
    vertical-align: middle;
    white-space: nowrap;
  }

  #tableEses .rank-td {
    font-size: 11px;
    color: #8a8a93;
    text-align: center;
    padding-left: 0;
    padding-right: 0;
  }

  /* The logo floated left and the name sat at 23px, so a two-word company name
     wrapped under the logo and every row grew to ~133px. Put them back on one
     line and clip the overflow instead. */
  table.marketcap-table td.name-td {
    padding: 9px 6px;
    text-align: left;
    overflow: hidden;
  }
  td.name-td > a {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    text-decoration: none;
  }
  .company-logo {
    float: none;
    display: block;
    flex: 0 0 auto;
    width: 24px; height: 24px;
    max-width: 24px;
    object-fit: contain;
  }
  .nom_entreprise {
    padding-left: 0;
    font-size: 13.5px;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Prix and Aujourd'hui: right-aligned, tabular figures, so the decimal
     points line up down the column and nothing jitters when a value updates. */
  #tableEses tbody tr > :nth-child(7),
  #tableEses tbody tr > :nth-child(8) {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 12.5px;
  }
  #tableEses tbody tr > :nth-child(7) strong,
  #tableEses tbody tr > :nth-child(8) strong { font-weight: 600; }

  .MiseaJour_bottom { font-size: 12px; padding: 0 16px; text-align: center; }

  /* ==========================================================================
     6. Market overview block (.cbm) and article slider (.cbs)
     Both already collapse to one column; only the page gutter needs to come
     in, from the 30px that lines up with the desktop nav to the 16px the rest
     of the phone layout uses.
     ========================================================================== */

  .cbm, .cbs { padding: 0 16px; }
  .cbs { margin: 26px 0; }

  /* With nine articles and one card per view there are nine dots. As a single
     non-shrinking flex item they were 274px wide and shoved the arrows 4px off
     the right edge of the screen. Let them wrap. */
  .cbs__dots { flex-wrap: wrap; min-width: 0; row-gap: 6px; }
  .cbs__arrows { flex: 0 0 auto; }
  /* 34px circles are under the 44px touch minimum, and these are the only way
     to drive the carousel by tap. */
  .cbs__arrow { width: 44px; height: 44px; font-size: 17px; }
  .cbs__dot { height: 6px; margin: -1.5px 0; }

  .site-intro { padding: 0 16px; }
  .site-intro h2 { font-size: 1.15rem; }

  /* ==========================================================================
     7. Newsletter opt-in
     Its layout is inline-styled in the markup, so overriding it needs the
     extra weight. The form is a flex row: on a phone each control takes the
     full width instead of being squeezed to a third of it.
     ========================================================================== */

  .email-optin-section { border-radius: 0 !important; padding: 26px 16px !important; margin: 24px 0 !important; }
  .email-optin-section h3 { font-size: 19px !important; }
  .email-optin-section p  { font-size: 13.5px !important; }
  #emailOptinForm { flex-direction: column; gap: 10px !important; }
  #emailOptinForm > * { width: 100% !important; max-width: none !important; }
  #emailInput { font-size: 16px !important; }

  /* ==========================================================================
     8. Footer
     .col-sm-6 is a Bootstrap-style half-width column, but no Bootstrap
     breakpoint is loaded here, so the two halves stayed side by side and were
     175px wide each on a 390px screen. Stack them.
     ========================================================================== */

  .footer-container { padding: 20px 16px; }
  .footer .col-sm-6 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    padding: 0;
  }
  .footer .col-sm-6 + .col-sm-6 { margin-top: 22px; }
  /* An email address is one unbreakable token; at 197px it was the single
     element pushing the document 17px wider than the viewport. */
  .contact-email { overflow-wrap: anywhere; word-break: break-word; }
  .footer-appstore-button { margin-bottom: 8px; }

  /* The floating theme toggle sits bottom-right over the content; keep it
     clear of the last line of the footer. */
  body { padding-bottom: 8px; }
}

/* ==========================================================================
   Small phones — SE, mini, and anything else at 375px or less.
   ========================================================================== */

@media (max-width: 400px) {
  .menu_header .brand h1 { font-size: 1.15rem; }
  .s-item.s-item { padding: 0 10px; }
  h1 { font-size: 1.05rem; }

  #tableEses tr > :nth-child(1) { width: 24px; }
  #tableEses tr > :nth-child(7) { width: 78px; }
  #tableEses tr > :nth-child(8) { width: 72px; }
  .marketcap-table td,
  .table.marketcap-table td,
  table.marketcap-table td { padding: 9px 4px; font-size: 12px; }
  .nom_entreprise { font-size: 12.5px; }
  .company-logo { width: 22px; height: 22px; max-width: 22px; }
}
