/* ==========================================================================
   layout.css
   The parts shared by every page: header, menu, main area, sections, footer.
   Loaded on every page, after base.css.

   Breakpoints used on this site
     ≤ 860px   tablet and phone: menu collapses behind the "Menu" button
     ≤ 640px   phone: single-column content (see home.css)
     ≥ 1400px  large screen: wider page and slightly larger text (see base.css)

   Contents
     1. Page width and margins
     2. Header and site name (sticky, with reading-progress bar)
     3. Main menu
     4. Submenu (Connect)
     5. Collapsed menu (tablet and phone)
     6. Main content area
     7. Sections and section labels
     8. Footer
     9. Top / Bottom buttons
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Page width and margins
   Header, main content and footer share the same width and side margins.
   The max() keeps content clear of the iPhone notch in landscape.
   -------------------------------------------------------------------------- */

.header-inner,
main,
.footer-inner {
  max-width: var(--max);
  margin-right: auto;
  margin-left: auto;
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  padding-left: max(var(--gutter), env(safe-area-inset-left));
}

/* Everything inside the page content keeps to one width on every page
   (--content-max in base.css): text, lists, sections and their dividers. */
main > * {
  max-width: var(--content-max);
}


/* --------------------------------------------------------------------------
   2. Header and site name
   -------------------------------------------------------------------------- */

/* As on the reference site, the header stays at the top while scrolling.
   site.js measures its height into --header-height, so in-page jumps
   (e.g. a News year, "Top") stop just below it instead of underneath. */
html {
  scroll-padding-top: var(--header-height, 140px);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: var(--rule);
  box-shadow: 0 3px 12px var(--shadow);
}

/* Reading progress: a thin bar along the bottom of the header that fills
   from left to right as the page is scrolled (width set by site.js). */
.reading-progress {
  position: absolute;
  bottom: -1px;                        /* sits on the header's bottom rule */
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

@media (forced-colors: active) {
  .reading-progress {
    background: Highlight;
  }
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
  padding-top: clamp(1.25rem, 3.5vw, 2.25rem);
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .1rem .75rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-name {
  font-family: var(--heading);
  font-size: clamp(1.45rem, 1.1rem + 1.6vw, 1.85rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.02em;
}

.brand-tagline {
  font-family: var(--heading);
  font-size: clamp(.95rem, .9rem + .3vw, 1.05rem);
  font-weight: 500;
  color: var(--ink-soft);
}

.brand-tagline span {
  color: var(--accent);
}

/* Örebro University logo, top right (set in site-config.js) */
.header-logo {
  display: block;
  align-self: center;
  margin-left: auto;
  line-height: 0;
}

.header-logo img {
  width: auto;
  height: 44px;
  margin: -6px 0;                      /* keeps the header row from growing */
  mix-blend-mode: multiply;            /* hides the logo's white box on the page colour */
}

@media (forced-colors: active) {
  .header-logo img {
    mix-blend-mode: normal;
  }
}


/* --------------------------------------------------------------------------
   3. Main menu
   -------------------------------------------------------------------------- */

.site-nav {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  gap: 0 clamp(1rem, 2.2vw, 1.6rem);
  margin-top: 1rem;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-family: var(--heading);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--ink);
}

/* Current page: underline drawn with box-shadow, which high-contrast mode removes cleanly */
.site-nav a[aria-current="page"],
.nav-group.is-active > a,
.nav-group-menu-only.is-active > .nav-parent {
  color: var(--ink);
  /* Current page: a yellow underline below the word, as on the reference site
     (the blue is kept for the reading-progress bar) */
  text-decoration: underline;
  text-decoration-color: var(--current-mark);
  text-decoration-thickness: 2px;
  text-underline-offset: .65em;
}

/* "Menu" button: only shown on tablet and phone (see section 5) */
.menu-button {
  display: none;
}

@media (forced-colors: active) {
  .site-nav a[aria-current="page"],
  .nav-group.is-active > a {
    text-decoration: underline;
  }
}


/* --------------------------------------------------------------------------
   4. Submenu (Connect)
   Opens on hover (mouse) or by tapping the small arrow button (touch, keyboard).
   -------------------------------------------------------------------------- */

.nav-group {
  position: relative;
  display: flex;
  align-items: center;
}

.sub-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: var(--tap);
  margin-left: .1rem;
  padding: 0;
  color: var(--ink-soft);
  background: none;
  border: 0;
  cursor: pointer;
}

.sub-toggle svg {
  width: 10px;
  height: 10px;
  transition: transform .15s ease;
}

.sub-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.nav-sub {
  position: absolute;
  top: 100%;
  left: -1rem;
  z-index: 10;
  display: none;
  min-width: 11rem;
  padding: .25rem 1rem;
  background: var(--paper);
  border: var(--rule);
  box-shadow: 0 6px 18px var(--shadow);
}

.nav-sub a {
  display: flex;
}

.nav-group.is-open .nav-sub {
  display: block;
}

/* Hover opening only on devices with a real mouse */
@media (hover: hover) {
  .nav-group:hover .nav-sub {
    display: block;
  }
}

/* A menu label that only opens its submenu (e.g. Connect): looks like the
   other menu items, with the small arrow after it */
.nav-parent {
  width: auto;
  gap: .35rem;
  margin-left: 0;
  padding: 0;
  font-family: var(--heading);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink-soft);
}

.nav-parent:hover,
.nav-parent[aria-expanded="true"] {
  color: var(--ink);
}

@media (forced-colors: active) {
  .nav-sub {
    border-color: CanvasText;
  }
}


/* --------------------------------------------------------------------------
   5. Collapsed menu (tablet and phone, ≤ 860px)
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {

  .header-inner {
    align-items: flex-start;
    padding-bottom: 1rem;
  }

  .brand {
    flex: 1 1 0;
    flex-direction: column;
  }

  .header-logo img {
    height: 34px;
  }

  .menu-button {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    padding: 0 1.1rem;
    font: 600 var(--fs-small) var(--heading);
    color: var(--ink);
    background: none;
    border: var(--rule);
    border-radius: 999px;
    cursor: pointer;
  }

  /* The open menu drops down as a panel below the sticky header and scrolls
     on its own if it is taller than the screen (as on the reference site). */
  .site-nav {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    flex-direction: column;
    max-height: calc(100vh - var(--header-height, 120px));
    max-height: calc(100dvh - var(--header-height, 120px));
    margin: 0;
    padding: .25rem max(var(--gutter), env(safe-area-inset-right)) 1rem max(var(--gutter), env(safe-area-inset-left));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--paper);
    border-bottom: 1px solid var(--ink);
    box-shadow: 0 12px 24px var(--shadow);
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav a {
    width: 100%;
    border-bottom: var(--rule);
  }

  .site-nav a[aria-current="page"],
  .nav-group.is-active > a {
    color: var(--ink);
    text-underline-offset: .4em;
  }

  /* Submenu is always shown, indented, inside the open menu */
  .nav-group {
    display: block;
  }

  .sub-toggle {
    display: none;
  }

  /* A label-only group (Connect) shows as a heading above its pages */
  .nav-parent {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    min-height: var(--tap);
    border-bottom: var(--rule);
    pointer-events: none;              /* its pages are always listed below it here */
  }

  .nav-parent svg {
    display: none;
  }

  .nav-group-menu-only.is-active > .nav-parent {
    color: var(--ink);
    text-underline-offset: .4em;
  }

  .nav-sub,
  .nav-group:hover .nav-sub {
    position: static;
    display: block;
    min-width: 0;
    padding: 0 0 0 1rem;
    background: none;
    border: 0;
    box-shadow: none;
  }
}

@media (max-width: 860px) and (forced-colors: active) {
  .menu-button {
    border-color: CanvasText;
  }
}


/* --------------------------------------------------------------------------
   6. Main content area
   -------------------------------------------------------------------------- */

main {
  padding-top: calc(var(--space) * 1.2);
  padding-bottom: calc(var(--space) * 1.5);
  overflow-wrap: break-word;           /* long words wrap instead of overflowing */
}

main a {
  overflow-wrap: anywhere;             /* long URLs wrap too */
}

.page-title {
  margin: 0 0 2.5rem;
  font-family: var(--heading);
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.02em;
}


/* --------------------------------------------------------------------------
   7. Sections and section labels
   A .section is a block separated by a thin rule.
   A .label is the small "/ HEADING /" title; the slashes are added here.
   -------------------------------------------------------------------------- */

.section {
  padding: calc(var(--space) * .6) 0 var(--space);   /* a little less space just below the dividing line */
  border-top: var(--rule);
}

.section p {
  max-width: var(--measure);
  margin: 0 0 1.1rem;
}

.section p:last-child {
  margin-bottom: 0;
}

.label {
  display: block;
  margin: 0 0 1.1rem;
  font-family: var(--heading);
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--ink);
}

.label::before,
.label::after {
  color: var(--accent);
}

.label::before {
  content: "/\00a0\00a0";
}

.label::after {
  content: "\00a0\00a0/";
}


/* --------------------------------------------------------------------------
   8. Footer
   Affiliations on the left (separated by an accent dot), copyright and email
   on the right; stacked on phones.
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: var(--rule);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem 2rem;
  padding-top: 1.75rem;
  padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

.footer-inner p {
  margin: 0;
}

.footer-affiliations {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--heading);
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink);
}

.footer-affiliations li + li::before {
  content: "·";
  margin: 0 .7em;
  font-weight: 800;
  color: var(--accent);
}

.footer-affiliations a {
  color: inherit;
  text-decoration: none;
}

.footer-affiliations a:hover {
  color: var(--accent);
}

/* Phones: the logo moves from the header bar into the bottom of the open
   menu panel, so the name and tagline keep their space */
.nav-logo {
  display: none;
}

@media (max-width: 480px) {
  .header-logo {
    display: none;
  }

  .nav-logo {
    display: block;
    padding: 1rem 0 .25rem;
    line-height: 0;
  }

  .nav-logo img {
    width: auto;
    height: 40px;
    mix-blend-mode: multiply;
  }
}

@media (max-width: 640px) {
  .footer-inner {
    flex-direction: column;
    gap: .4rem;
  }
}


/* --------------------------------------------------------------------------
   9. Top / Bottom buttons
   Floating at the bottom right, as on the reference site. Added by site.js.
   -------------------------------------------------------------------------- */

.scroll-aids {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .4rem;
}

.scroll-aid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-width: 64px;
  min-height: 48px;
  padding: .65rem .9rem;
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  background: var(--paper);
  border: var(--rule);
  border-radius: 999px;
  box-shadow: 0 4px 18px var(--shadow-strong);
  transition: background-color .15s ease;
}

.scroll-aid[hidden] {
  display: none;
}

.scroll-aid:hover {
  color: var(--accent);
  background: var(--accent-tint);
}

/* The jump targets receive focus; no outline needed around the whole area */
#main:focus,
.site-footer:focus {
  outline: none;
}

@media (forced-colors: active) {
  .scroll-aid {
    border-color: ButtonText;
  }
}

@media print {
  .scroll-aids {
    display: none !important;
  }
}
