/* =============================================================================
 * FILE        : app/static/assets/css/static-site.css
 *               (from src/styles/static-site.css of the Astro site; only these comments changed)
 * PURPOSE     : Everything the static site needs IN ADDITION to the original
 *               Joomla stylesheets (app/static/templates/..., app/static/modules/...), mainly to replace
 *               what the old site did with JavaScript:
 *                 1. small helpers;
 *                 2. the desktop drop-down menu (hover AND keyboard focus);
 *                 3. the mobile menu (<details> element instead of a script);
 *                 4. the slideshows (CSS animation instead of jQuery "Camera");
 *                 5. accessibility (visible keyboard focus).
 * INPUTS      : class names written by app/templates/base.html and the
 *               templates in app/templates/partials/.
 * OUTPUTS     : global styles (loaded on every page, AFTER the original CSS,
 *               so a rule here wins over an equal rule there).
 * HOW TO EDIT : Change values here rather than in the original stylesheets.
 *               CSS reminder: `selector { property: value; }`; a class is
 *               written `.name`, an id `#name`; "!important" forces a value.
 * ========================================================================== */


/* -----------------------------------------------------------------------------
 * 1. Helpers
 * -------------------------------------------------------------------------- */

/* The converted Joomla texts are wrapped in <div class="joomla-html"> (needed
   by Markdown, see docs). display: contents makes this box "invisible": its
   children are laid out exactly as if the wrapper did not exist. */
.joomla-html {
  display: contents;                 /* no box of its own */
}

/* Replaces the old inline style="clear:both" after the menu. */
.ck-clear-both {
  clear: both;                       /* go below floating elements */
}

/* The <nav> elements added around the menus must not change the layout. */
header nav {
  display: block;                    /* behave like the old plain <div> */
}


/* -----------------------------------------------------------------------------
 * 2. Desktop drop-down menu
 * The original rules (moo_maximenuhck.css) open a sub-menu on mouse hover by
 * moving it from left:-999em (off screen) to left:auto. The rules below repeat
 * this with the menu's id (so nothing else can override them) and add the
 * same for keyboard users: when the focus is INSIDE an entry (:focus-within,
 * e.g. after pressing Tab), its sub-menu opens too. Colours and sizes come
 * from the original menu stylesheet (maximenuhck_menuCdppHorizontal.css).
 * -------------------------------------------------------------------------- */

/* The menu block is put in its own layer, ABOVE the banner link that sits
   just above it in the header: the pointer over the menu always reaches the
   menu, never the banner (whose picture changes on hover). The old <div>
   carried an inline style="z-index:10" that had no effect (no position). */
#menuCdppHorizontal {
  position: relative;                /* needed for z-index to apply */
  z-index: 10;                       /* above the banner link (z-index auto) */
}

/* The banner link must never extend outside the banner box. */
.custom_header {
  overflow: hidden;                  /* clip the absolutely placed link */
}

/* Open the sub-menu of the entry under the mouse or containing the focus. */
div#menuCdppHorizontal ul.maximenuck li.maximenuck:hover > div.floatck,
div#menuCdppHorizontal ul.maximenuck li.maximenuck:focus-within > div.floatck {
  left: auto;                        /* bring it back on screen */
}

/* Headings without a page (About, Data, ...): no "hand" pointer. */
#menuCdppHorizontal a:not([href]) {
  cursor: default;                   /* plain arrow, as on the old site */
}


/* -----------------------------------------------------------------------------
 * 3. Mobile menu (screens narrower than 800 px)
 * <details>/<summary>: clicking the summary (the round button) opens or closes
 * the details element; the browser does it, no script is involved.
 * -------------------------------------------------------------------------- */

/* Hidden on wide screens. */
.ck-mobilemenu {
  display: none;                     /* shown again by the media query below */
}

/* Remove the small triangle browsers draw in front of a <summary>. */
.ck-mobilemenu > summary {
  list-style: none;                  /* standard way (Firefox, Chrome) */
}
.ck-mobilemenu > summary::-webkit-details-marker {
  display: none;                     /* older Safari */
}

/* When the menu is open, the round button shows a "close" cross. */
.ck-mobilemenu[open] > summary.mobilebuttonmenuck {
  background: #000 url(/templates/CDPP/images/mobile/close.png) center center no-repeat !important;
}

/* The panel with all the entries (colours come from the original CSS). */
.ck-mobilemenu > .mobilemaximenuck {
  position: fixed;                   /* stays in place when scrolling */
  top: 0;                            /* from the top of the screen */
  left: 0;                           /* from the left edge */
  width: 90%;                        /* as in the original template */
  max-height: 100vh;                 /* never taller than the screen */
  overflow-y: auto;                  /* scroll inside the panel if needed */
  z-index: 440;                      /* below the button (450), above the page */
}

/* Below 800 px: hide the desktop menu, show the mobile one.
   (The old site had exactly these rules in an inline <style>.) */
@media only screen and (max-width: 800px) {
  #menuCdppHorizontal {
    display: none !important;        /* no drop-down menu on small screens */
  }
  .ck-mobilemenu {
    display: block;                  /* the round button appears */
  }
  body {
    padding-top: 40px !important;    /* room for the top of the mobile menu */
  }
  /* FIX of an original template bug (horizontal scroll on phones): the thin
     white line under each slideshow (::after) gets left:30% from the
     <=1200 px rules, then width:60% + margin-left:20% from the <=800 px
     rules, so it ends at 30+20+60 = 110 % of the slideshow width and sticks
     out on the right (34 px at 420 px wide). Resetting `left` gives the
     centred 20 %-80 % line the <=800 px rules intended. Desktop unchanged. */
  .moduletableSlideAccueil::after,
  .moduletableSlideOutils::after,
  .moduletableSlideToulouse::after {
    left: 0;                         /* start from the slideshow's left edge */
  }
}


/* -----------------------------------------------------------------------------
 * 4. Slideshows (app/templates/partials/modules.html, macro slideshow)
 * All images are stacked; each one fades in, stays, fades out, then waits for
 * the others. With n images the cycle has n slots: the animation "ck-fade-n"
 * keeps the image visible during 1/n of the cycle (plus a short cross-fade).
 * Each image starts one slot after the previous one (animation-delay, set in
 * the component). One @keyframes per possible number of images (1 to 10).
 * -------------------------------------------------------------------------- */

/* The frame: its height is a fixed proportion of its width (34.2 %, the value
   given to the old slideshow plugin), so the page does not jump while the
   images load. */
.ck-slideshow .camera_target {
  position: relative;                /* reference for the stacked images */
  width: 100%;                       /* full width of the module */
  padding-bottom: 34.2%;             /* height = 34.2 % of the width */
  overflow: hidden;                  /* cut what goes beyond the rounded corners */
}

/* The Toulouse slideshow (Presentation page) is taller: 53.5 %. */
.slideshowckSlideToulouse.ck-slideshow .camera_target {
  padding-bottom: 53.5%;             /* height = 53.5 % of the width */
}

/* Every image fills the frame. */
.ck-slideshow .ck-slide {
  position: absolute;                /* stacked on top of each other */
  inset: 0;                          /* top/right/bottom/left = 0 */
  width: 100%;                       /* fill the frame... */
  height: 100%;
  object-fit: cover;                 /* ...without distortion (crop if needed) */
  opacity: 0;                        /* hidden until its turn comes */
}

/* The first image is visible even without animation. */
.ck-slideshow .ck-slide:first-child {
  opacity: 1;                        /* default picture */
}

/* The animation runs only if the visitor did not ask for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .ck-slideshow .ck-slide {
    animation-timing-function: ease-in-out;  /* smooth fades */
    animation-iteration-count: infinite;     /* loop for ever */
    animation-fill-mode: both;               /* keep first/last state */
  }
  /* With 2+ images, the first one is animated like the others. */
  .ck-slideshow:not(.ck-n-1) .ck-slide:first-child {
    opacity: 0;                              /* the animation shows it */
  }
}

/* Keyframes for 2 to 10 images (generated: fade = a quarter of a slot). */
@keyframes ck-fade-2 { 0% { opacity: 0; } 12.5% { opacity: 1; } 50% { opacity: 1; } 62.5% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-2 .ck-slide { animation-name: ck-fade-2; }
@keyframes ck-fade-3 { 0% { opacity: 0; } 8.33% { opacity: 1; } 33.33% { opacity: 1; } 41.67% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-3 .ck-slide { animation-name: ck-fade-3; }
@keyframes ck-fade-4 { 0% { opacity: 0; } 6.25% { opacity: 1; } 25% { opacity: 1; } 31.25% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-4 .ck-slide { animation-name: ck-fade-4; }
@keyframes ck-fade-5 { 0% { opacity: 0; } 5% { opacity: 1; } 20% { opacity: 1; } 25% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-5 .ck-slide { animation-name: ck-fade-5; }
@keyframes ck-fade-6 { 0% { opacity: 0; } 4.17% { opacity: 1; } 16.67% { opacity: 1; } 20.83% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-6 .ck-slide { animation-name: ck-fade-6; }
@keyframes ck-fade-7 { 0% { opacity: 0; } 3.57% { opacity: 1; } 14.29% { opacity: 1; } 17.86% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-7 .ck-slide { animation-name: ck-fade-7; }
@keyframes ck-fade-8 { 0% { opacity: 0; } 3.12% { opacity: 1; } 12.5% { opacity: 1; } 15.62% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-8 .ck-slide { animation-name: ck-fade-8; }
@keyframes ck-fade-9 { 0% { opacity: 0; } 2.78% { opacity: 1; } 11.11% { opacity: 1; } 13.89% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-9 .ck-slide { animation-name: ck-fade-9; }
@keyframes ck-fade-10 { 0% { opacity: 0; } 2.5% { opacity: 1; } 10% { opacity: 1; } 12.5% { opacity: 0; } 100% { opacity: 0; } }
.ck-n-10 .ck-slide { animation-name: ck-fade-10; }


/* -----------------------------------------------------------------------------
 * 5. Accessibility: keyboard focus must be visible.
 * -------------------------------------------------------------------------- */
a:focus-visible,
summary:focus-visible {
  outline: 2px solid #ffb74b;        /* the template's orange link colour */
  outline-offset: 2px;               /* a little gap around the element */
}


/* -----------------------------------------------------------------------------
 * 6. "Short CV" links on the Team page (app/content/pages/about/team.md)
 *    Each person's notice sits in <details class="short-cv">: the browser
 *    shows only the <summary> line ("Short CV") until it is clicked, with no
 *    JavaScript. To fold another text the same way, wrap it in the same tags.
 * -------------------------------------------------------------------------- */

.short-cv {
  margin: 0 0 14px 0;                /* space before the next person */
}

.short-cv > summary {
  display: inline-block;             /* only as wide as its words */
  cursor: pointer;                   /* hand cursor: it can be clicked */
  color: #ffb74b;                    /* the template's orange link colour */
  font-size: 0.9em;                  /* a little smaller than the notice */
  list-style: none;                  /* hide the default triangle (Firefox) */
}

.short-cv > summary::-webkit-details-marker {
  display: none;                     /* hide the default triangle (Safari, Chrome) */
}

.short-cv > summary::before {
  content: "\25B8\00A0";             /* small right-pointing triangle + space */
}

.short-cv[open] > summary::before {
  content: "\25BE\00A0";             /* small down-pointing triangle once open */
}

.short-cv > summary:hover {
  text-decoration: underline;        /* same feedback as a link */
}

.short-cv > p {
  margin-top: 6px;                   /* small gap under "Short CV" */
}


/* -----------------------------------------------------------------------------
 * 7. Two columns of people on the Team page (app/content/pages/about/team.md)
 *    <div class="team-columns"> holds two <div class="team-column">, side by
 *    side on a wide screen and one under the other below 800 px.
 * -------------------------------------------------------------------------- */

.team-columns {
  display: grid;                                 /* lay the children out on a grid */
  grid-template-columns: 1fr 1fr;                /* two columns of equal width */
  column-gap: 32px;                              /* space between the two columns */
  align-items: start;                            /* each column keeps its own height */
}

.team-column-title {
  margin: 18px 0 4px 0;                          /* space above and below the title */
  color: #ffb74b;                                /* the template's orange accent */
  font-size: 1.05em;                             /* slightly larger than the text */
  text-align: left !important;                   /* the template justifies every <p> */
}

@media (max-width: 800px) {
  .team-columns {
    grid-template-columns: 1fr;                  /* a single column on small screens */
  }
}


/* -----------------------------------------------------------------------------
 * 8. Home-page slideshow: the original template lets its decoration line run
 *    about 32 px past the right edge at desktop widths, which adds a
 *    horizontal scroll bar. Clip it to the slideshow box (no visual change).
 * -------------------------------------------------------------------------- */

.slidersPleinePage {
  overflow-x: clip;                  /* hide what sticks out on the right */
}


/* A discreet sub-heading inside a column, above people who are associated
   with CDPP without a CDPP service task (thin rule + small italic words). */
.team-column-subtitle {
  margin: 16px 0 2px 0;                          /* space above, little below */
  padding-top: 8px;                              /* room under the thin rule */
  border-top: 1px solid rgba(255, 255, 255, 0.18); /* faint separating rule */
  color: rgba(255, 255, 255, 0.55);              /* quieter than the names */
  font-size: 0.85em;                             /* smaller than the text */
  font-style: italic;                            /* reads as a note, not a title */
  text-align: left !important;                   /* the template justifies every <p> */
}


/* -----------------------------------------------------------------------------
 * 9. Page "Publications citing CDPP" (app/templates/citing_cdpp.html)
 *    The chart is an inline SVG; each year of the list is a <details> block.
 * -------------------------------------------------------------------------- */

.pub-note {
  font-size: 0.85em;                 /* smaller than the main text */
  font-style: italic;                /* reads as a note */
  color: rgba(255, 255, 255, 0.6);   /* quieter than the main text */
}

.pub-chart {
  margin: 18px 0 24px 0;             /* space around the chart */
}

.pub-chart svg {
  width: 100%;                       /* the drawing follows the column width */
  height: auto;                      /* and keeps its proportions */
  display: block;                    /* no gap under the drawing */
}

.pub-chart figcaption {
  font-size: 0.8em;                  /* small caption */
  color: rgba(255, 255, 255, 0.6);   /* quiet caption */
  text-align: center;                /* centred under the chart */
}

.pub-year > summary {
  cursor: pointer;                   /* it can be clicked */
  color: #ffb74b;                    /* the template's orange accent */
  font-size: 1.2em;                  /* year as a small heading */
  margin: 12px 0 6px 0;              /* space around the year */
}

.pub-count {
  font-size: 0.75em;                 /* number of publications, smaller */
  color: rgba(255, 255, 255, 0.6);   /* quieter */
}

.pub-year li {
  margin-bottom: 6px;                /* space between references */
  text-align: left;                  /* no justification for references */
}

