/* =============================================================
   ITI Design System — Interior page shell
   Masthead + body grid + sidebar frame, shared by every redesigned
   interior page.

   css/iti-announcement.css already carries its own copy of this under
   .ann-* names. It is deliberately left alone: it works, and rewriting a
   finished page to use these classes would be churn with nothing to show
   for it. New pages use .iti-mast / .iti-page / .iti-rail instead, so the
   duplication stops here rather than growing with each page.
   ============================================================= */

/* =========================================================
   Masthead
   ========================================================= */

.iti-mast {
  position: relative;
  overflow: hidden;
  background: var(--iti-ink-900);
  color: var(--iti-on-dark);
}
.iti-mast__bg {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
}
.iti-mast__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg,
    rgba(4, 18, 31, .96) 0%,
    rgba(4, 18, 31, .88) 38%,
    rgba(4, 18, 31, .5) 70%,
    rgba(4, 18, 31, .25) 100%);
}
.iti-mast__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(to right, var(--iti-grid-line) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(to bottom, var(--iti-grid-line) 0 1px, transparent 1px 72px);
  mask-image: linear-gradient(105deg, transparent 0%, #000 45%, #000 100%);
}
.iti-mast__inner {
  position: relative;
  padding-block: clamp(2.25rem, 1.4rem + 3.2vw, 4rem);
}

/* breadcrumb trail */
.iti-crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--iti-s-2);
  margin-bottom: var(--iti-s-5);
  font-size: var(--iti-fs-xs);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--iti-on-dark-faint);
}
.iti-crumbs a { color: var(--iti-on-dark-muted); text-decoration: none; }
.iti-crumbs a:hover { color: var(--iti-electric); }
.iti-crumbs__sep { opacity: .5; }

.iti-mast__meta {
  display: flex;
  align-items: center;
  gap: var(--iti-s-4) var(--iti-s-6);
  flex-wrap: wrap;
  margin-bottom: var(--iti-s-4);
}
.iti-mast__stat {
  display: inline-flex;
  align-items: baseline;
  gap: .45rem;
  font-family: var(--iti-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: .8rem;
  letter-spacing: .08em;
  color: var(--iti-electric);
}
/* The unit reads as a label, not as data. IBM Plex Mono has no Greek
   subset, so any word that can be Greek must take the sans face. */
.iti-mast__stat b {
  font-family: var(--iti-font-sans);
  font-weight: 600;
  font-size: .68rem;
  letter-spacing: var(--iti-track-label);
  text-transform: uppercase;
  color: var(--iti-on-dark-muted);
}

.iti-mast__title {
  max-width: 24ch;
  font-size: clamp(1.75rem, 1.1rem + 2.4vw, 3rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--iti-on-dark);
  text-wrap: balance;
}
.iti-mast__lede {
  max-width: 58ch;
  margin: var(--iti-s-4) 0 0;
  font-size: var(--iti-fs-lead);
  line-height: var(--iti-lh-body);
  color: var(--iti-on-dark-muted);
}

/* =========================================================
   Body
   ========================================================= */

.iti-page {
  padding-block: clamp(2.5rem, 1.6rem + 3vw, 4.5rem);
  background: var(--iti-paper);
}
.iti-page__grid {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: clamp(1.75rem, 1rem + 3vw, 3.5rem);
  align-items: start;
}

/* =========================================================
   Side menus — one accent, site-wide

   Every sidebar on the site shows a single 3px cyan stripe down its left
   edge. The legacy sheets put a 4px #0071bb stripe on three different
   wrappers, each with !important, so those have to be matched to be
   removed — otherwise a page ends up with two stripes in two colours (the
   ΦΟΡΕΑΣ pages did) or the wrong one wins outright (the publications rail
   did). The token below is the one place the colour is set.
   ========================================================= */

:root {
  --iti-rail-accent: var(--iti-electric);
  /* The site header is sticky and 79px tall; anchored headings clear it
     with a little room to spare. Pages with a second sticky element of
     their own raise this locally. */
  --iti-anchor-offset: 100px;
}

/* css/style.css: `.table_of_contents_widget` — the publications rail.
   css/style.css: `.article-menu`            — the ΦΟΡΕΑΣ rail wrapper.
   css/loops-pages.css: `.main-menu`         — the announcements rail. */
.iti-rail .table_of_contents_widget,
.art .article-menu,
.iti-rail .main-menu,
.ann-rail .main-menu {
  border-left: 0 !important;
  box-shadow: none !important;
}
/* .article-menu also carries `color: #fff !important`, which would make
   every label in it invisible once the wrapper stops being dark. */
.art .article-menu { color: inherit !important; padding: 0 !important; }

/* =========================================================
   Sidebar frame
   The rail's contents come from a shortcode, so each page styles the
   markup its own shortcode emits. Only the frame is shared.
   ========================================================= */

.iti-rail {
  position: sticky;
  top: 100px;
  /*
   * A rail taller than the screen used to run off the bottom with no way to
   * reach its last items: it is pinned, so the page scrolling past it does not
   * move it. Cap it to what is actually on screen below the header and let it
   * carry its own scrollbar. `auto` means short rails — most of them — show
   * nothing at all.
   */
  max-height: calc(100vh - 100px - var(--iti-s-6));
  overflow-y: auto;
  /* Reaching the end of the rail should not start scrolling the page behind it. */
  overscroll-behavior: contain;
}
/* Logged in, WordPress pushes everything down by its toolbar. */
.admin-bar .iti-rail {
  max-height: calc(100vh - 100px - 32px - var(--iti-s-6));
}
.iti-rail__title {
  display: flex;
  align-items: center;
  gap: var(--iti-s-3);
  margin: 0 0 var(--iti-s-4);
  font-size: var(--iti-fs-xs);
  font-weight: 600;
  letter-spacing: var(--iti-track-label);
  text-transform: uppercase;
  color: var(--iti-electric-ink);
}
.iti-rail__title::before {
  content: "";
  width: 24px; height: 1px;
  background: var(--iti-electric);
  box-shadow: var(--iti-electric-glow);
  flex: none;
}

/* =========================================================
   Category rail contents — the .s-menu list

   Emitted by the [projects_menu] shortcode on the project pages and
   written out directly by the person template. Both produce the same
   shape, so the styling lives here rather than in either page's sheet.
   ========================================================= */

/* The shortcode emits an unclosed <ul> (functions.php: the first item's
   markup ends `</a><ul>` and is then closed with `</li>`), so the parser
   nests every category inside the first list item:

       ul > li > ( a , ul > li > ( a , ul.sub-menu-projects > li > a ) )

   Fixing the shortcode would re-nest the same rail on single-project.php,
   which still runs the old stylesheet, so the markup is left as it is and
   these selectors are written to not care how deep an item sits. */

/* css/style.css dresses .s-menu for the old design: an 18px capitalised
   list where every top-level item carries a 4px #0071bb bar via
   `.s-menu>ul>li:before`. That bar is the blue stripe, so it has to be
   matched to be removed. */
.iti-rail .s-menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.iti-rail .s-menu > ul {
  background: var(--iti-surface);
  border: 1px solid var(--iti-line);
  border-left: 3px solid var(--iti-rail-accent);
  box-shadow: var(--iti-electric-glow-edge);
  clip-path: var(--iti-clip-sm);
}
.iti-rail .s-menu li {
  margin: 0;
  padding: 0;
  font-size: inherit;
  text-transform: none;
  border-bottom: 1px solid var(--iti-line);
}
.iti-rail .s-menu li:last-child { border-bottom: 0; }
.iti-rail .s-menu li::before { content: none; }

/* Every category is a sibling and reads as one, at whatever depth the
   parser happened to put it. */
.iti-rail .s-menu a {
  display: block;
  padding: .7rem 1rem;
  font-size: .88rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--iti-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background var(--iti-dur) var(--iti-ease),
              border-color var(--iti-dur) var(--iti-ease),
              color var(--iti-dur) var(--iti-ease);
}
.iti-rail .s-menu a:hover {
  background: var(--iti-paper);
  border-left-color: var(--iti-electric-dim);
  color: var(--iti-blue);
}
/* The first item is the page itself — except in a flat menu, which has no
   such row and whose entries are all siblings. */
.iti-rail .s-menu > ul > li > a {
  font-weight: 600;
  color: var(--iti-text);
  letter-spacing: .01em;
}
.iti-rail .s-menu--flat > ul > li > a { font-weight: 500; letter-spacing: normal; }

/* A nested group inside a rail entry — the personnel rail's subcategories
   of "Κύριο Επιστημονικό Προσωπικό". Always visible and set exactly like
   its parent; the indent is the only thing that says it is a level down. */
.iti-rail .s-menu__sub {
  border-top: 1px solid var(--iti-line);
}
.iti-rail .s-menu__sub > li:last-child { border-bottom: 0; }
.iti-rail .s-menu__sub a { padding-left: 2rem; }

/* The subcategories of "Ευρωπαϊκά Έργα" open on hover, as they did before.
   Keyboard users get the same thing on focus-within, which costs nothing
   and is the only way to reach them without a pointer. */
.iti-rail .s-menu li .sub-menu-projects {
  display: block;
  visibility: visible;
  margin-left: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  border-top: 0 solid var(--iti-line);
  transition: max-height .4s var(--iti-ease),
              opacity .25s var(--iti-ease),
              border-width .4s step-end;
}
.iti-rail .s-menu li:hover > .sub-menu-projects,
.iti-rail .s-menu li:focus-within > .sub-menu-projects {
  max-height: 20rem;
  opacity: 1;
  border-top-width: 1px;
  transition: max-height .4s var(--iti-ease),
              opacity .3s var(--iti-ease) .05s,
              border-width 0s;
}
.iti-rail .s-menu li .sub-menu-projects a { padding-left: 2rem; }

/* A touch screen has no hover, and the old sheet hid these outright below
   768px with nothing to open them. Where there is no pointer, they stay
   open. */
@media (hover: none) {
  .iti-rail .s-menu li .sub-menu-projects {
    max-height: none;
    opacity: 1;
    overflow: visible;
    border-top-width: 1px;
  }
}

/* Section currently in view — set by js/iti-projects.js on the project
   listing, and by js/iti-rail-spy.js on every other rail. */
.iti-rail .s-menu a.is-current {
  background: var(--iti-ink-700);
  border-left-color: var(--iti-electric);
  color: var(--iti-on-dark);
  font-weight: 600;
}
.iti-rail .s-menu a.is-current:hover {
  background: var(--iti-ink-600);
  color: var(--iti-on-dark);
}

@media (max-width: 900px) {
  .iti-page__grid { grid-template-columns: minmax(0, 1fr); }
  .iti-rail { position: static; }
}
