/*
 * The shared shell: skip link, header, Päävalikko, content frame and footer.
 * Colours and fonts come from theme.json (--wp--preset--*). One breakpoint, 782px (WordPress's own):
 * below it the nav is the Valikko panel, from it up the nav is a bar.
 *
 * Class convention: `rv-` prefix, BEM-ish (rv-header__bar). Templates compose these classes;
 * other templates add their own `rv-` classes in their own stylesheets or sections below.
 */

:root {
  --rv-gutter: 20px;
  --rv-blue: var(--wp--preset--color--primary);
  --rv-white: var(--wp--preset--color--white);
  --rv-divider: var(--wp--preset--color--divider);
}

@media (min-width: 782px) {
  :root {
    /* 64px, or wider so the content never exceeds 1152px (1280px frame) on big screens. */
    --rv-gutter: max(64px, calc((100% - 1152px) / 2));
  }
}

body {
  margin: 0;
}

/*
 * Visually hidden, kept for screen readers. The one definition for every page: the new-tab notice of external
 * links and the Arkisto's year (.rv-sr-only), and the ": title" core appends to the "Lue lisää" links.
 */
.rv-sr-only,
.rv-entry__more .screen-reader-text,
.rv-feature__more .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wp-site-blocks {
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Focus: blue ring on white, white ring on the blue header. */
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--rv-blue);
  outline-offset: 2px;
}

.rv-header a:focus-visible,
.rv-header button:focus-visible {
  outline-color: var(--rv-white);
}

/*
 * Title links in lists and on Home are one line of heading text, shorter than the 44px hit area the
 * spec asks of every control. Vertical padding on an inline link widens the hit area without moving
 * any line of the layout.
 */
.wp-block-post-title a,
.rv-entry__title a,
.rv-feature__title a,
.rv-teaser__title a {
  padding-block: 8px;
}

/* <main> takes focus from the skip link; it is not a control, so it gets no ring. */
main:focus {
  outline: none;
}

/* Skip link: first focusable element, off-screen until focused. */
.rv-skip {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  padding: 10px 16px;
  background: var(--rv-white);
  color: var(--rv-blue);
  font-size: 16px;
  font-weight: 600;
  z-index: 10;
}

.rv-skip:focus {
  position: static;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 44px;
  width: auto;
  height: auto;
  overflow: visible;
}

/* ---- Header ---- */

.rv-header {
  background: var(--rv-blue);
  padding: 28px var(--rv-gutter) 20px;
}

.rv-site-name {
  margin: 0;
  font-family: var(--wp--preset--font-family--newsreader);
  font-weight: 600;
  font-size: 40px;
  line-height: 44px;
  color: var(--rv-white);
}

.rv-tagline {
  margin: 8px 0 0;
  font-family: var(--wp--preset--font-family--newsreader);
  font-size: 20px;
  line-height: 26px;
  color: var(--wp--preset--color--header-subtitle);
}

.rv-header__bar {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.rv-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  background: var(--rv-white);
  border: 0;
  color: var(--rv-blue);
  font-family: var(--wp--preset--font-family--roboto);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

/* The header photo placeholder (every page, unlinked). 76px here, 152px from the breakpoint up. */
.rv-home-photo {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  box-sizing: border-box;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  line-height: 13px;
  color: var(--rv-white);
}

/* ---- Päävalikko: mobile panel ---- */

.rv-nav {
  background: var(--rv-white);
  border-bottom: 1px solid var(--rv-divider);
  padding: 8px 0;
}

.rv-nav[hidden] {
  display: none;
}

.rv-nav__link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 20px;
  font-size: 18px;
  color: var(--wp--preset--color--body);
  text-decoration: none;
  border-left: 4px solid transparent;
}

.rv-nav__link:hover {
  color: var(--wp--preset--color--link-hover);
}

.rv-nav__link[aria-current='page'] {
  color: var(--rv-blue);
  font-weight: 600;
  border-left-color: var(--rv-blue);
}

@media (prefers-reduced-motion: no-preference) {
  .rv-nav:not([hidden]) {
    animation: rv-slide-down 0.2s ease-out;
  }
}

@keyframes rv-slide-down {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- Content frame: main column, then the Sidebar ---- */

.rv-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 44px;
  padding: 32px var(--rv-gutter) 40px;
}

.rv-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* Page and post titles: the one h1 of every page except Home. */
h1.wp-block-post-title {
  margin: 0;
  font-size: 32px;
  line-height: 38px;
}

/* The Sidebar part can be empty; an empty column must not take space. */
.rv-sidebar:empty {
  display: none;
}

/* ---- Footer ---- */

.rv-footer {
  margin: 0 var(--rv-gutter);
  padding: 16px 0 20px;
  border-top: 1px solid var(--rv-divider);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'copy privacy'
    'social social';
  align-items: center;
  row-gap: 4px;
  font-size: 16px;
  color: var(--wp--preset--color--muted);
}

.rv-footer p {
  margin: 0;
}

.rv-footer__copy {
  grid-area: copy;
}

.rv-footer__privacy {
  grid-area: privacy;
}

.rv-footer__privacy a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.rv-social {
  grid-area: social;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rv-social__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--rv-blue);
  text-decoration: none;
}

.rv-social__ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border: 1px solid var(--wp--preset--color--surface-border);
  border-radius: 50%;
}

.rv-social__link:hover .rv-social__ring {
  background: var(--wp--preset--color--hover-surface);
}

/* ---- From the breakpoint up ---- */

@media (min-width: 782px) {
  .rv-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 40px;
    padding: 40px var(--rv-gutter) 32px;
  }

  .rv-site-name {
    font-size: 60px;
    line-height: 66px;
    letter-spacing: -0.01em;
  }

  .rv-tagline {
    font-size: 24px;
    line-height: 30px;
  }

  /* Only the menu button and the photo live here; from the breakpoint up the button goes and the photo is 152px. */
  .rv-header__bar {
    display: flex;
    margin-top: 0;
  }

  .rv-header__bar .rv-menu-button {
    display: none;
  }

  .rv-home-photo {
    width: 152px;
    height: 152px;
    font-size: 15px;
    line-height: 19px;
  }

  /* The same landmark becomes the bar; `hidden` (mobile closed state) no longer applies. */
  .rv-nav,
  .rv-nav[hidden] {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 64px;
    padding: 0 var(--rv-gutter);
    animation: none;
  }

  .rv-nav__link {
    position: relative;
    height: 64px;
    min-height: 0;
    padding: 0 18px;
    font-size: 16px;
    border-left: 0;
  }

  .rv-nav__link::after {
    content: '';
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 0;
    height: 3px;
    background: transparent;
  }

  .rv-nav__link:hover::after {
    background: var(--wp--preset--color--surface-border);
  }

  .rv-nav__link[aria-current='page']::after {
    background: var(--rv-blue);
  }

  .rv-content {
    flex-direction: row;
    align-items: flex-start;
    gap: 56px;
    padding: 48px var(--rv-gutter) 56px;
  }

  h1.wp-block-post-title {
    font-size: 42px;
    line-height: 48px;
  }

  .rv-main {
    flex: 1 1 0;
    gap: 32px;
  }

  .rv-sidebar {
    flex: 0 0 320px;
  }

  .rv-footer {
    grid-template-columns: 1fr auto auto;
    grid-template-areas: 'copy social privacy';
    column-gap: 28px;
    padding: 24px 0 28px;
  }
}
