/* HEMAJoensuu – sivuston tyylit. Värit ja mitat on koottu muuttujiksi alle.
   The six editable colours (--bg, --panel, --accent, --link, --btn-accent, --btn-primary)
   are overridden from the CMS (Asetukset → Värit) by an inline <style> in base.njk,
   after a contrast check in src/_data/themeVars.js. The values here are the defaults. */
:root {
  --bg: #232323;
  --panel: #353535;
  --text: #fafafa;
  --muted: #c8c8c8;
  /* Headings (large text, ≥3:1) */
  --accent: #ff6666;
  /* Links and small red text: ≥4.5:1 on all dark backgrounds */
  --link: #ff8080;
  /* Button backgrounds: white text on these is ≥4.5:1 */
  --btn-accent: #c93c3c;
  --btn-primary: #3d6fd1;
  /* Hover shades follow whatever colours are chosen in the CMS.
     Lighter link / darker button only ever increase contrast. */
  --link-hover: color-mix(in oklab, var(--link), white 40%);
  --btn-accent-hover: color-mix(in oklab, var(--btn-accent), black 18%);
  --btn-primary-hover: color-mix(in oklab, var(--btn-primary), black 15%);
  --card: #fafafa;
  --card-text: #232323;
  --card-link: #2f63c4;
  --nav-h: 70px;
  --container: 1140px;
  --font: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- Jost, hosted on this site (SIL OFL 1.1, see /fonts/OFL.txt) ----------
   Served from our own domain instead of Google Fonts, so visitors' IP addresses are not
   sent to Google (GDPR). One variable font file covers every upright weight. */
@font-face {
  font-family: "Jost";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/jost-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Jost";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/jost-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Jost";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/jost-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Jost";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/jost-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  /* main and footer share one grid cell, so the footer overlays the bottom of the page's background image */
  display: grid;
  grid-template: 1fr / 100%;
  font-family: var(--font);
  /* Scale fallback fonts to Jost's x-height so text doesn't jump when Jost loads. */
  font-size-adjust: from-font;
  font-size: 1.125rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}
main { grid-area: 1 / 1; display: flex; flex-direction: column; }
/* Basis auto (not 0): a section with a min-height must still grow to fit its content. */
main > * { flex: 1 0 auto; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.preview-banner {
  position: fixed;
  top: calc(var(--nav-h) + .5rem);
  left: 50%;
  z-index: 150;
  translate: -50% 0;
  margin: 0;
  padding: .4rem 1rem;
  border-radius: 4px;
  background: #ffd84d;
  color: #1a1a1a;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 200; }
.skip-link:focus { left: 1rem; top: 1rem; padding: .5rem 1rem; background: #fff; color: #000; }

/* ---------- Navigation ---------- */
.site-header { position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
.navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: var(--nav-h);
  padding: 0 1rem;
  background: rgba(0, 0, 0, .5);
  transition: background-color .3s;
}
.navbar.is-scrolled, .navbar.is-open { background: #000; }
.brand {
  margin-right: auto;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}
.brand:hover { color: #fff; }
.nav-menu { display: flex; align-items: center; gap: 1rem; }
.nav-list { display: flex; list-style: none; margin: 0; padding: 0; }
.nav-list a, .dropdown-toggle {
  display: block;
  padding: .5rem .75rem;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.nav-list a:hover, .dropdown-toggle:hover, .nav-list [aria-current="page"] { color: var(--link); }
/* Current page is marked by more than colour alone (WCAG 1.4.1). */
.nav-list [aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .35em; }
.dropdown-toggle::after {
  content: "";
  display: inline-block;
  margin-left: .4em;
  vertical-align: .2em;
  border: .3em solid transparent;
  border-top-color: currentColor;
  border-bottom: 0;
}
.has-dropdown { position: relative; }
.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 12rem;
  margin: 0;
  padding: .5rem 0;
  list-style: none;
  background: #000;
}
.has-dropdown.is-open .dropdown { display: block; }
@media (hover: hover) and (min-width: 992px) {
  .has-dropdown:hover .dropdown { display: block; }
}
.social { display: flex; gap: .25rem; }
.social a { display: inline-flex; padding: .5rem; color: #fff; }
.social a:hover { color: var(--link); }
.social svg { width: 24px; height: 24px; fill: currentColor; }

.nav-toggle { display: none; }

@media (max-width: 991.98px) {
  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 44px;
    height: 44px;
    padding: 8px;
    border: 0;
    background: none;
    cursor: pointer;
  }
  .nav-toggle span { display: block; height: 2px; background: #fff; transition: transform .2s, opacity .2s; }
  .navbar.is-open .nav-toggle span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
  .navbar.is-open .nav-toggle span:nth-child(2) { opacity: 0; }
  .navbar.is-open .nav-toggle span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
  .nav-menu { display: none; width: 100%; flex-direction: column; align-items: stretch; padding: .5rem 0 1rem; }
  .navbar.is-open .nav-menu { display: flex; }
  .nav-list { flex-direction: column; text-align: center; }
  .dropdown-toggle { width: 100%; }
  .dropdown { position: static; padding: 0; background: transparent; }
  .dropdown a { color: var(--muted); font-size: 1rem; }
  .social { justify-content: center; }
}

/* ---------- Page sections ---------- */
.hero, .section {
  position: relative;
  /* bottom padding leaves room for the overlaid footer (up to two lines on small phones) */
  padding: calc(var(--nav-h) + 4rem) 0 6rem;
  background-color: var(--panel);
  background-position: center;
  background-size: cover;
}
.hero { display: flex; align-items: center; min-height: 100vh; min-height: 100svh; }
@media (min-width: 992px) and (hover: hover) {
  .hero, .section--bg { background-attachment: fixed; }
}
.overlay { position: absolute; inset: 0; background: #000; pointer-events: none; }
.hero__inner, .section > .container { position: relative; }
.hero__content { max-width: 42rem; }
.hero__content--wide { max-width: 60rem; }

.page-title {
  margin: 0 0 1.5rem;
  font-size: clamp(2.26rem, 1.2rem + 4.2vw, 4.6rem);
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.title--light { color: var(--text); }
.title--accent { color: var(--accent); }

.prose { font-size: clamp(1.07rem, 1rem + .3vw, 1.2rem); }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose h2, .prose h3 { line-height: 1.25; margin: 1.5em 0 .5em; }

.faq__a p { margin: 0 0 1em; }

.actions { margin: 2rem 0 0; }
.btn {
  display: inline-block;
  padding: .85rem 2rem;
  border-radius: 4px;
  box-shadow: 0 2px 2px rgba(0, 0, 0, .2);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .2s, box-shadow .2s;
}
.btn:hover { color: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .3); }
.btn--accent { background: var(--btn-accent); }
.btn--accent:hover { background: var(--btn-accent-hover); }
.btn--primary { background: var(--btn-primary); }
.btn--primary:hover { background: var(--btn-primary-hover); }
/* Secondary action: white outline, readable on any dark photo */
.btn--outline { background: rgba(0, 0, 0, .35); border: 2px solid #fff; padding: calc(.85rem - 2px) calc(2rem - 2px); box-shadow: none; }
.btn--outline:hover { background: rgba(0, 0, 0, .6); }
.actions { display: flex; flex-wrap: wrap; gap: .75rem 1rem; }

/* ---------- Front-page info box ---------- */
.info-box {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 4px 4px 0;
  background: rgba(0, 0, 0, .55);
}
.info-box__title { margin: 0 0 .5rem; font-size: 1.25rem; line-height: 1.3; }
.info-box .prose { font-size: 1.05rem; }
.info-box .prose > :last-child { margin-bottom: 0; }

/* ---------- Section builder (Omat sivut) ---------- */
.custom-page { max-width: 60rem; }
.page-section { margin-top: 3rem; }
.page-section > :first-child { margin-top: 0; }
.page-section .info-box, .page-section .faq, .page-section .actions { margin-top: 0; }
.page-section--gallery { max-width: none; }
.section-heading { margin: 0 0 1rem; font-size: clamp(1.5rem, 1.25rem + 1vw, 2.1rem); line-height: 1.2; color: var(--accent); }
.image-text { display: grid; gap: 1.5rem 2.5rem; align-items: center; }
.image-text__image img { width: 100%; border-radius: 4px; }
@media (min-width: 768px) {
  .image-text { grid-template-columns: 1fr 1fr; }
  .image-text--right .image-text__image { order: 2; }
}

/* ---------- FAQ accordion (native <details>) ---------- */
.faq { margin-top: 2rem; border-top: 1px solid rgba(255, 255, 255, .25); }
.faq__item { border-bottom: 1px solid rgba(255, 255, 255, .25); }
.faq__q {
  display: flex;
  align-items: baseline;
  gap: .6ch;
  padding: 1rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
  list-style: none; /* removes the default triangle */
  cursor: pointer;
}
.faq__q::-webkit-details-marker { display: none; }
.faq__q:hover { color: var(--link-hover); }
/* Chevron right before the label; rotated to point down when open */
.faq__q::before {
  content: "";
  flex-shrink: 0;
  inline-size: .8em;
  block-size: .8em;
  background-color: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 8l8 8 8-8' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  rotate: -90deg;
}
.faq__item[open] > .faq__q::before { rotate: 0deg; }
.faq__a { padding: 0 0 1rem calc(.8em + .6ch); }
.faq__a > :last-child { margin-bottom: 0; }
/* Slide open/closed where supported; otherwise items open instantly. */
.faq__item::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}
.faq__item:not([open])::details-content { block-size: 0; }
@media (prefers-reduced-motion: no-preference) {
  .faq__q::before { transition: rotate .2s; }
  .faq__item::details-content {
    transition: block-size .3s ease-in-out, content-visibility .3s, display .3s;
    transition-behavior: allow-discrete;
  }
}

/* ---------- News cards ---------- */
.cards { display: grid; grid-template-columns: 1fr; gap: 2rem; margin-top: 2rem; }
@media (min-width: 768px) { .cards { grid-template-columns: 1fr 1fr; } }
.card { display: flex; flex-direction: column; overflow: hidden; border-radius: 4px; background: var(--card); color: var(--card-text); }
.card__img img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card__body { display: flex; flex: 1; flex-direction: column; padding: 1.5rem 2rem 2rem; }
.card__body p { margin: 0 0 1rem; }
.card__title { margin: 0 0 .25rem; font-size: clamp(1.35rem, 1.2rem + .6vw, 2rem); line-height: 1.3; }
.card__title a, .card__more a { color: var(--card-link); text-decoration: none; }
.card__title a:hover, .card__more a:hover { text-decoration: underline; }
.card__meta { font-size: 1rem; }
.card__meta time { font-style: italic; }
.card__more { margin-top: auto !important; font-weight: 600; }

/* ---------- Article ---------- */
.article { display: grid; gap: 2.5rem; align-items: center; }
.article:not(.article--split) .article__text { width: 100%; max-width: 50rem; margin: 0 auto; }
@media (min-width: 992px) { .article--split { grid-template-columns: 7fr 5fr; } }
.article__image img { width: 100%; border-radius: 4px; }
.article__title { margin: 0 0 .5rem; color: var(--accent); font-size: clamp(1.7rem, 1.3rem + 1.6vw, 3rem); line-height: 1.15; }
.article__meta { margin: 0 0 1.5rem; color: var(--muted); font-style: italic; }
.back { margin-top: 2rem; }
.back a { color: var(--muted); }

/* ---------- Gallery carousel ---------- */
.carousel { --dots-h: 2.5rem; position: relative; margin-top: 1rem; }
.carousel__track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: 4px;
  background: #000;
  touch-action: manipulation;
}
@media (prefers-reduced-motion: no-preference) {
  .carousel__track { scroll-behavior: smooth; }
}
/* Buttons sit over the track; the container lets clicks/swipes through to the track. */
.carousel__controls {
  position: absolute;
  inset: 0 0 var(--dots-h) 0;
  z-index: 1;
  pointer-events: none;
}
.carousel__controls .carousel__btn { pointer-events: auto; touch-action: manipulation; }
.carousel__track::-webkit-scrollbar { display: none; }
.carousel__slide {
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  scroll-snap-align: center;
}
.carousel__slide picture { display: flex; justify-content: center; width: 100%; }
.carousel__slide img { width: auto; max-height: 80vh; object-fit: contain; }
.carousel__slide figcaption { padding: .5rem 1rem; color: var(--muted); font-size: .9rem; }
.carousel__btn {
  position: absolute;
  top: 50%;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 2.25rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}
.carousel__btn:hover { background: rgba(0, 0, 0, .8); }
.carousel__btn--prev { left: 12px; }
.carousel__btn--next { right: 12px; }
.carousel__dots { display: flex; justify-content: center; align-items: center; gap: .25rem; height: var(--dots-h); padding-top: 1rem; }
/* 24px tap target around a 12px dot */
.carousel__dots button {
  width: 24px;
  height: 24px;
  padding: 6px;
  border: 0;
  border-radius: 50%;
  background: #777 content-box;
  cursor: pointer;
  touch-action: manipulation;
}
.carousel__dots button[aria-current="true"] { background-color: var(--accent); }

/* ---------- Footer ---------- */
/* Same see-through black as the header; sits over the last section's bottom padding. */
.site-footer {
  grid-area: 1 / 1;
  align-self: end;
  position: relative;
  z-index: 1;
  padding: .75rem 16px;
  background: rgba(0, 0, 0, .5);
  text-align: center;
}
.site-footer p { margin: 0; font-size: 1rem; line-height: 1.4; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
