/* ============================================================
   SciFY Annual Report — mobile responsive layer
   Desktop layout (≥ 1000px) is left completely untouched.
   All rules below only apply on small screens and override the
   inline desktop styles via structural / attribute selectors.
   ============================================================ */

/* ---- Reserve room at top-right for the language switcher ---- */
@media (min-width: 1000px) {
  header nav { padding-right: 58px; }
}

/* ---- Coverflow photo galleries: the row of 5 photos (up to ~1556px
        total: 240+300+388+300+240px + gaps) is meant to be windowed
        around the enlarged centre photo, but its wrapper never actually
        clipped the overflow - causing real page-wide horizontal scroll
        on any window narrower than ~1650px (laptops, non-maximised
        browsers), at every screen size, not just mobile. ---- */
[data-gal-wrap] { overflow: hidden; }

/* ---- Mobile nav accordion toggle button (added by nav-menu.js):
        hidden on desktop, where the hover dropdown + inline arrow
        (inside the link) are used instead. ---- */
.wwd-toggle { display: none; }

/* ---- Mobile nav burger button: hidden on desktop, where the full
        nav is always shown inline. ---- */
.nav-burger { display: none; }

/* ---- Impact-area hover info box ---- */
.impact-icon { position: relative; cursor: help; }
.impact-icon::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 230px;
  max-width: 46vw;
  background: #231f20;
  color: #ffffff;
  font-family: 'Ubuntu', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(30,20,50,0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 200;
}
.impact-icon::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #231f20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s ease;
  z-index: 201;
}
.impact-icon:hover::after,
.impact-icon:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.impact-icon:hover::before,
.impact-icon:focus-visible::before {
  opacity: 1;
  visibility: visible;
}
/* Tell before/after apart: the title of the impact area on top */
.impact-icon::after { white-space: normal; }

/* The tooltip above extends up to 115px past each icon's own edges
   (230px wide, centred on a 58px icon). Even while invisible
   (opacity:0/visibility:hidden), that absolutely-positioned box still
   inflates the row's own scrollWidth, leaking real page-wide
   horizontal overflow at desktop widths where the row is the widest
   thing on the page (e.g. ~1024px). Clip horizontally only - overflow-y
   stays visible so the tooltip itself is untouched when it actually
   opens on hover/focus, since it opens *upward* off the row. Applies
   at every width, not just mobile (where ::after/::before are hidden
   outright below, since hover/focus don't exist on touch anyway). */
div:has(> .impact-icon) { overflow-x: clip; }

/* ---- Global accessibility rules (apply at every width) ---- */

/* Visible keyboard focus indicator on all interactive elements */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #fdbd11 !important;
  outline-offset: 2px;
  border-radius: 3px;
}

/* Make the nav dropdowns openable by keyboard, not just hover */
.wwd-drop:focus-within .wwd-menu {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Lift muted grey copy to meet WCAG AA contrast on white */
[style*="color:#8a8790"] { color: #6a6770 !important; }

@media (max-width: 999px) {

  /* Unlock the fixed desktop min-width so the page can shrink */
  [style*="min-width:1000px"] { min-width: 0 !important; }

  /* impact-icon tooltips (::after, 230px wide) only ever open on
     :hover/:focus-visible - neither exists on touch, and the icon
     <span> has no tabindex so it can't even receive focus. Even
     invisible (opacity:0), the absolutely-positioned tooltip still
     inflates its relatively-positioned parent's scrollWidth, causing
     real horizontal page overflow on project pages. Hide it outright. */
  .impact-icon::after,
  .impact-icon::before {
    display: none !important;
  }

  /* Rows of 5 impact-icon circles (58px + 14px gap = 346px) are wider
     than most mobile viewports even after the tooltip fix above -
     let them wrap instead of forcing the row wider than the page. */
  div:has(> .impact-icon) {
    flex-wrap: wrap !important;
    row-gap: 10px !important;
  }

  /* Editorial page: the pull-quote <aside> is sticky so it stays pinned
     next to the letter's text column on desktop. Once the 2-column grid
     collapses to one column on mobile, aside + text share the same
     scroll flow, so "sticky" would float the aside on top of the text
     scrolling underneath it instead of just sitting above it in order. */
  aside[style*="position:sticky; top:104px;"] { position: static !important; }

  /* Collapse every multi-column grid to a single stacked column.
     minmax(0, ...) - not a bare 1fr - so the track actually shrinks to
     fit; a bare 1fr keeps an implicit auto minimum, letting unshrinkable
     content (e.g. the fixed-width revenue bar chart) force the column
     wider than the viewport and get clipped by an overflow:hidden
     ancestor instead of wrapping/scrolling in place.
     article[...] catches the highlighted-talks.html event cards, which
     use <article> (150px date column + content) instead of <div>. */
  div[style*="grid-template-columns"],
  article[style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 28px !important;
  }

  /* Event card date box: the right border divider (built for sitting
     beside the content) becomes a stray vertical line once stacked
     above the content - swap it for a bottom border, and drop the
     centred layout so the date reads like a normal heading. */
  article[style*="grid-template-columns:150px 1fr"] > div:first-child {
    text-align: left !important;
    border-right: none !important;
    padding-right: 0 !important;
    padding-bottom: 16px !important;
    border-bottom: 1px solid #ece8f3 !important;
    margin-bottom: 16px !important;
  }

  /* Revenue analysis charts: the 3-pie row and the bar chart (bars +
     year labels, with "780.000 €"-style value labels) both have a real
     minimum content width that won't fit on narrow screens. Scroll them
     horizontally within their own card instead of shrinking labels to
     illegible sizes or clipping data.
     .bar-chart-scroll wraps BOTH the bars row and the "2023/2024/2025"
     labels row (see index.html) so they scroll together and stay
     aligned - scrolling the bars alone would leave the year labels
     behind, misaligning them from their own bars. */
  div[style*="justify-content:space-around; gap:16px;"],
  .bar-chart-scroll {
    overflow-x: auto !important;
    padding-bottom: 8px !important;
  }
  .bar-chart-scroll > div { min-width: 394px !important; }


  /* "Our Impact at a Glance" bars: their fixed pixel heights only make
     sense compared side-by-side in columns. Stacked full-width blocks of
     arbitrary height read as noise, so switch to a 2-column grid of
     compact stat cards (icon + number + thin accent line + label)
     instead of tall colour blocks. */
  div.impact-bars {
    grid-template-columns: 1fr 1fr !important;
    gap: 28px 16px !important;
  }
  .impact-bars > div > div {
    height: 8px !important;
    border-radius: 4px !important;
    margin-top: 10px !important;
    width: 100% !important;
  }
  /* Widths keep the same proportions as the desktop bars' heights
     (340/214/84/40/24px), so relative magnitude still reads at a glance. */
  .impact-bars > div:nth-child(2) > div { width: 63% !important; }
  .impact-bars > div:nth-child(3) > div { width: 25% !important; }
  .impact-bars > div:nth-child(4) > div { width: 12% !important; }
  .impact-bars > div:nth-child(5) > div { width: 7% !important; }

  /* Tighten side padding on the wide centered containers */
  div[style*="margin:0 auto"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* Headings scale down for narrow screens */
  h1[style] { font-size: 32px !important; line-height: 1.15 !important; }
  h2[style] { font-size: 26px !important; }

  /* ---- Navigation: stack the bar and expand submenus inline
          (hover dropdowns don't work on touch). The header keeps its
          desktop `position: sticky` — now that the nav collapses behind
          a burger, the collapsed bar stays compact enough to pin. ---- */
  header > div {
    flex-wrap: wrap !important;
    gap: 22px 16px !important;
    padding: 12px 20px !important;
  }
  /* Burger button: shown on mobile, pushed toward the row's right edge.
     margin-right clears the fixed-position language switch button
     (i18n.js, top:16px/right:18px, ~90px wide) so the two never overlap. */
  .nav-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    margin-left: auto;
    margin-right: 90px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
  }
  .nav-burger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #3d3d3f;
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Nav collapses behind the burger by default; opens on click (nav-menu.js). */
  header nav {
    display: none !important;
    flex-wrap: wrap !important;
    gap: 18px !important;
    margin-left: 0 !important;
    width: 100%;
  }
  header nav.nav-open { display: flex !important; }
  header nav > a { font-size: 17px !important; }
  .wwd-drop { position: relative; width: 100%; }

  /* Wrapper (added by nav-menu.js) around just the link + toggle button,
     so the button's height always matches the link's own row - even
     while the submenu below is open and .wwd-drop itself grows tall. */
  .wwd-head {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 0;
  }
  .wwd-head > a { padding-right: 48px !important; font-size: 17px !important; }

  /* Toggle button: expands/collapses the submenu independently of the
     link's own navigation target. The arrow is a CSS triangle (not a
     Unicode glyph) so its size stays crisp and consistent instead of
     shrinking to a dot on some devices' fonts. */
  .wwd-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 100%;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.15s ease;
  }
  .wwd-toggle::after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 8px solid #3d3d3f;
  }
  .wwd-toggle[aria-expanded="true"] { transform: rotate(180deg); }
  /* The desktop arrow (inside the link) would otherwise duplicate the toggle's own arrow */
  .wwd-head > a > span { display: none !important; }

  .wwd-menu {
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    padding-top: 4px !important;
    min-width: 0 !important;
    display: none;
  }
  .wwd-drop.wwd-open .wwd-menu { display: block !important; }
  .wwd-menu-inner {
    box-shadow: none !important;
    border: none !important;
    padding: 2px 0 6px 14px !important;
  }

  /* ---- Photo coverflow galleries: show only the centre frame.
          #pwd-track (inspiring-projects.html) is the same widget but with
          its own inline JS keyed off a plain id instead of the
          [data-gal-track] convention used elsewhere - included here too
          so it gets the same mobile treatment. ---- */
  [data-gal-track], #pwd-track { height: auto !important; gap: 0 !important; }
  [data-gal-track] > [data-pos], #pwd-track > [data-pos] { display: none !important; }
  [data-gal-track] > [data-pos="2"], #pwd-track > [data-pos="2"] {
    display: block !important;
    /* 100vw minus: 20px page padding x2, and the two 36px nav
       buttons + their 10px gaps (2 x (36+10)) on either side. */
    width: calc(100vw - 132px) !important;
    height: 200px !important;
  }

  /* The row wrapping the gallery (prev button, track, next button):
     shrink the buttons/gap on mobile so the row's total width matches
     the track's calc() above instead of overflowing the viewport. */
  div[style*="justify-content:center; gap:22px;"] {
    gap: 10px !important;
  }
  div[style*="justify-content:center; gap:22px;"] > button[data-pwd-nav],
  div[style*="justify-content:center; gap:22px;"] > button[data-gal-nav] {
    width: 36px !important;
    height: 36px !important;
    font-size: 18px !important;
  }
}

/* ---- Narrow phones only: tablets like iPad Mini (768px) have plenty of
        room for the hero CTA buttons side by side; only phones narrow
        enough to wrap the pill text ("Ο Αντίκτυπός..." breaking after
        "Ο") need them stacked. ---- */
@media (max-width: 600px) {
  div[style*="gap:16px; margin-top:44px;"] {
    flex-direction: column !important;
  }
  div[style*="gap:16px; margin-top:44px;"] > a {
    text-align: center !important;
  }
}
