/*
Theme Name: NA Croatia
Description: Website theme for Narcotics Anonymous Croatia.
Version: 0.1.0
Requires at least: 6.5
Requires PHP: 8.1
Text Domain: nacroatia
*/

/* ==========================================================================
   Fonts: system fonts, nothing is downloaded. Georgia ships with Windows, macOS and iOS;
   Helvetica Neue only with Apple systems. Elsewhere the next font in each stack is used
   (Arial on Windows, the system serif / sans-serif on Android and Linux).
   ========================================================================== */

/* ==========================================================================
   Design tokens. Colors here are fallbacks; the Customizer overrides them
   (inline style, see inc/customizer.php). Only place hex values may appear.
   ========================================================================== */
:root {
  --color-primary: #091d73;
  --color-secondary: #c5d4ff;
  --color-text: #0f1a44;
  --color-background: #ffffff;
  --color-on-primary: #ffffff;
  --color-on-secondary: #111111;

  --font-heading: Georgia, "Times New Roman", Times, serif;
  --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;

  --fs-body: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --fs-h1: clamp(1.75rem, 1.3rem + 2vw, 2.75rem);
  --fs-h2: clamp(1.5rem, 1.2rem + 1.4vw, 2.25rem);
  --fs-h3: clamp(1.2rem, 1.05rem + 0.7vw, 1.5rem);

  --gutter: 16px;
  --container: 1200px;
  --header-base: 64px;   /* minimum header row height */
  --header-height: calc(var(--header-base) + 1px); /* fallback; the real height is measured in main.js */
  --section-space: clamp(2.5rem, 2rem + 3vw, 5rem);
  --radius-pill: 999px;
}

/* ==========================================================================
   Reset & base (mobile-first; breakpoints 600 / 900 / 1200)
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  overflow-wrap: anywhere; /* long words and URLs break instead of widening the page */
}
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.2; margin: 0 0 1em; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
p { margin: 0 0 1em; }
img, svg, iframe, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
section[id], #main { scroll-margin-top: var(--header-height); }
/* Controls scrolled into view by Tab / Shift+Tab stay clear of the sticky header. Only inside
   main and the footer: the header's own links are always in view and must not scroll the page. */
main :is(a, button, iframe), .site-footer a { scroll-margin: calc(var(--header-height) + 8px) 0 8px; }
/* Anchor targets take programmatic focus (main.js); no ring on non-interactive containers. */
[tabindex="-1"]:focus { outline: none; box-shadow: none; }

/* Focus: two-tone (outline + halo) so it shows on navy and on white. */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--color-background);
}

/* ==========================================================================
   Layout & utilities
   ========================================================================== */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
section { padding-block: var(--section-space); }

.section--primary { background: var(--color-primary); color: var(--color-on-primary); }
.section--secondary { background: var(--color-secondary); color: var(--color-on-secondary); }
.section--primary :focus-visible { outline-color: var(--color-on-primary); box-shadow: 0 0 0 5px var(--color-primary); }
.section--secondary :focus-visible { outline-color: var(--color-on-secondary); box-shadow: 0 0 0 5px var(--color-secondary); }

/* Skewed NA logo behind the content: full width, centred vertically (cropped when the band is
   shorter). Tinted from the band's own text colour, so it follows the Customizer colours. */
.logo-bg { position: relative; isolation: isolate; }
.logo-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, currentColor 7%, transparent);
  -webkit-mask: url("assets/img/na-logo-bg.svg") center / 100% auto no-repeat;
  mask: url("assets/img/na-logo-bg.svg") center / 100% auto no-repeat;
  pointer-events: none;
}
/* Narrower screens: wider than the band, so only part of the logo shows and it stays in the background. */
@media (max-width: 1024px) {
  .logo-bg::before { -webkit-mask-size: calc(100% + 400px) auto; mask-size: calc(100% + 400px) auto; }
}

.pill {
  display: block;
  min-height: 44px;
  padding: 0.6em 1.25em;
  border-radius: var(--radius-pill);
  background: var(--color-secondary);
  color: var(--color-primary);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

/* Backgrounds are dropped in forced-colors mode; keep the pill shape visible. */
@media (forced-colors: active) { .pill { border: 2px solid; } }

.visually-hidden,
.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 1000;
  padding: 0.75em 1.25em;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 700;
}
.skip-link:focus { top: var(--gutter); }

/* ==========================================================================
   Hero: message band, map + address, meetings
   ========================================================================== */
.hero { padding-block: 0; }
.hero__band { padding-block: var(--section-space); }
.hero__band h1 { max-width: 30ch; }
.hero__text { max-width: 60ch; }
.hero__text > :last-child { margin-bottom: 0; }

.hero__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding-block: var(--section-space);
}
.hero__map {
  aspect-ratio: 4 / 3;
  background: var(--color-secondary);
}
.hero__map iframe { width: 100%; height: 100%; border: 0; }

.hero__address {
  display: flex;
  gap: 12px;
  font-style: normal;
  font-weight: 400;
}
.hero__pin { flex: none; width: 28px; height: 28px; color: var(--color-primary); }
.hero__maps-link { display: flex; align-items: center; width: fit-content; min-height: 44px; color: var(--color-primary); }

.hero__meetings h2 { text-align: center; text-transform: uppercase; }
.meetings { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.meeting { font-size: 0.95rem; text-transform: none; }
.meeting__day { text-transform: uppercase; }
/* On its own line, but only the text is clickable. */
.meeting__link { display: block; width: fit-content; max-width: 100%; margin: 0.35em auto 0; font-weight: 400; }
.meeting__note { display: block; margin-top: 0.15em; font-size: 0.8125rem; font-weight: 400; }

@media (min-width: 900px) {
  .hero__body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "map meetings" "address .";
    column-gap: 48px;
  }
  .hero__map { grid-area: map; }
  .hero__address { grid-area: address; }
  /* Centred on the map. A list taller than the map makes the row grow instead. */
  .hero__meetings { grid-area: meetings; align-self: center; }
}

/* ==========================================================================
   Header, navigation, language switch
   Without JS the menu is always visible (wraps under the brand on mobile and
   the header scrolls away). With `html.js` it collapses below 900px.
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-background);
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-secondary);
}
.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: var(--header-base);
  padding-block: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 0%;
  min-width: 0;
  min-height: 44px;
  color: var(--color-primary);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}
.brand__logo { flex: none; width: auto; height: 44px; max-width: 160px; object-fit: contain; }
.brand__name { overflow-wrap: anywhere; }
/* Uploaded logo with the name in the artwork: let it be wide, and shrink on narrow screens. */
.brand--logo-only .brand__logo { flex: 0 1 auto; min-width: 0; height: auto; max-height: 48px; max-width: 100%; }

.menu-toggle { order: 1; }
.lang-switch { order: 2; }
.site-nav { order: 3; flex: 0 0 100%; }

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav__list a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.35em 1.25em;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-pill);
  color: var(--color-primary);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}
.site-nav__list a:hover { background: var(--color-secondary); }
.site-nav__list a[aria-current="true"] { background: var(--color-primary); color: var(--color-on-primary); }

.menu-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-pill);
  color: var(--color-primary);
  text-decoration: none;
}
.menu-toggle { display: none; border: 2px solid var(--color-primary); background: transparent; cursor: pointer; }
.menu-toggle:hover { background: var(--color-secondary); }

/* Language switch: decorative globe, then "hr | en". The current language is plain bold text,
   the other one an underlined link, so they differ by more than colour. */
.lang-switch { display: flex; flex: none; align-items: center; gap: 4px; color: var(--color-primary); }
.lang-switch__icon { display: none; flex: none; width: 28px; height: 28px; }
.lang-switch__list { display: flex; align-items: center; margin: 0; padding: 0; list-style: none; }
.lang-switch__list li + li { border-left: 2px solid currentColor; }
.lang-switch__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 24px;
  padding: 0 8px;
  color: inherit;
  font-size: 0.9375rem;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lang-switch__item[aria-current] { font-weight: 700; }
a.lang-switch__item { position: relative; text-decoration: underline; text-underline-offset: 0.2em; }
a.lang-switch__item:hover { text-decoration-thickness: 2px; }
/* 44px touch target without making the row taller. */
a.lang-switch__item::after { content: ""; position: absolute; inset: -10px 0; }
@media (min-width: 480px) { .lang-switch__icon { display: block; } }
.menu-toggle[aria-expanded="true"] { background: var(--color-primary); color: var(--color-on-primary); }

@media (max-width: 899px) {
  /* No JS: static header, so the extra nav row does not eat the viewport. */
  html:not(.js) { --header-height: 0px; }
  html:not(.js) .site-header { position: static; }

  .js .menu-toggle { display: inline-flex; }
  .js .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 16px var(--gutter) 20px;
    background: var(--color-background);
    border-bottom: 1px solid var(--color-secondary);
  }
  .js .site-nav.is-open { display: block; }
  .js .site-nav__list { flex-direction: column; }
}

@media (min-width: 900px) {
  .site-header__inner { flex-wrap: nowrap; gap: 16px; }
  .brand { flex: 0 1 auto; margin-right: auto; font-size: 1rem; }
  .brand--logo-only .brand__logo { max-height: 56px; }
  /* Five menu items plus the language switch: tighter pills until there is room, so the logo keeps its size. */
  .site-header__inner { gap: 12px; }
  .site-nav__list { gap: 6px; }
  .site-nav__list a { padding-inline: 0.8em; font-size: 0.8125rem; letter-spacing: 0.02em; }
  .site-nav { order: 0; flex: 0 0 auto; }
  .site-nav__list { flex-wrap: nowrap; }
  .lang-switch { order: 0; }
}

@media (min-width: 600px) { :root { --gutter: 24px; } }
@media (min-width: 900px) { :root { --gutter: 32px; --header-base: 80px; } }
@media (min-width: 1200px) { :root { --gutter: 32px; } }
@media (min-width: 1100px) {
  .site-header__inner { gap: 16px; }
  .site-nav__list { gap: 8px; }
  .site-nav__list a { padding-inline: 1.25em; font-size: 0.875rem; letter-spacing: 0.04em; }
}

/* ==========================================================================
   Contact, about, region, footer
   ========================================================================== */
.contact { padding-block: 32px; }
.contact__label { margin: 0 0 12px; font-size: 1.5rem; }
.contact__address { font-style: normal; }
/* Two columns, left-aligned: labels, then values. */
.contact__list { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 0 16px; margin: 0; }
.contact__item { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; }
.contact__item dt { font-weight: 700; }
.contact__item dd { margin: 0; min-width: 0; }
.contact a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; overflow-wrap: anywhere; }

.about__inner { max-width: calc(70ch + 2 * var(--gutter)); text-align: center; }
.about__body { text-align: center; }
.about__body > :last-child { margin-bottom: 0; }

.region h2 { text-align: center; }
.region__grid { display: grid; gap: 32px; align-items: center; }
.region__links { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
/* Only links or only the NA.org block: centre it instead of leaving half the row empty. */
.region__grid > :only-child { grid-column: 1 / -1; justify-self: center; }
.region__grid > .region__links:only-child { width: min(100%, 36rem); }
.region__links .pill { background: var(--color-primary); color: var(--color-on-primary); }
.region__na-org {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--color-primary); font-weight: 700; text-decoration: none;
}
.region__globe { width: 120px; height: 120px; }
.region__na-org:hover span { text-decoration: underline; }
@media (min-width: 900px) {
  .region__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .region__globe { width: 180px; height: 180px; }
}

.site-footer { padding-block: 32px; }
.site-footer a { color: inherit; }
.site-footer__text > :first-child { margin-top: 0; }
.site-footer__text > :last-child { margin-bottom: 0; }
.site-footer__copyright { margin: 16px 0 0; font-size: 0.875rem; }

/* ==========================================================================
   Carousel (Swiper) and literature covers
   Without JS the track is a horizontal scroll-snap row; Swiper takes over once
   it adds .swiper-initialized to the viewport.
   ========================================================================== */
.literature h2 { text-align: center; }
.carousel { position: relative; }
/* The viewport clips its overflow; the padding leaves room for the focus ring of the slides. */
.carousel__viewport { margin: -8px; padding: 8px; }
.carousel__viewport:not(.swiper-initialized) {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 8px; /* snap inside the padding */
  padding-bottom: 12px;
}
.carousel__track { margin: 0; padding: 0; list-style: none; }
.carousel { --carousel-gap: 16px; --carousel-per-view: 2; }
.carousel__viewport:not(.swiper-initialized) .carousel__track { display: flex; gap: var(--carousel-gap); }
.carousel__viewport:not(.swiper-initialized) .carousel__slide {
  flex: 0 0 calc((100% - (var(--carousel-per-view) - 1) * var(--carousel-gap)) / var(--carousel-per-view));
  scroll-snap-align: start;
}
@media (min-width: 600px) { .carousel { --carousel-gap: 20px; --carousel-per-view: 3; } }
@media (min-width: 900px) { .carousel { --carousel-gap: 24px; --carousel-per-view: 5; } }
.carousel__slide { height: auto; }

.carousel__btn {
  position: absolute;
  top: calc(50% - 22px);
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.carousel__btn--prev { left: -8px; }
.carousel__btn--next { right: -8px; }
.carousel__btn--next .carousel__icon { transform: scaleX(-1); }
.carousel__icon { width: 24px; height: 24px; }
.swiper-initialized ~ .carousel__btn { display: inline-flex; }
.swiper-initialized ~ .carousel__btn.is-locked { display: none; }
.carousel__btn.is-disabled { opacity: 0.35; cursor: default; }
@media (min-width: 1300px) {
  .carousel__btn--prev { left: -56px; }
  .carousel__btn--next { right: -56px; }
}

.cover {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  color: var(--color-on-secondary);
  text-align: center;
  text-decoration: none;
}
.cover img { display: block; width: 100%; height: auto; aspect-ratio: 360 / 510; object-fit: cover; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.cover__title { font-weight: 700; font-size: 0.95rem; overflow-wrap: anywhere; }
.cover:hover .cover__title { text-decoration: underline; }

/* ==========================================================================
   Events carousel (navy band) and lightbox dialog
   ========================================================================== */
.events h2 { text-align: center; }
.events .carousel { --carousel-per-view: 1; }
@media (min-width: 600px) { .events .carousel { --carousel-per-view: 2; } }
@media (min-width: 900px) { .events .carousel { --carousel-per-view: 3; } }
/* Arrows would disappear on the navy band in the default (primary) color. */
.section--primary .carousel__btn { background: var(--color-on-primary); color: var(--color-primary); }

.event-link { display: block; color: inherit; cursor: zoom-in; }
/* Mixed image shapes share one frame; contain keeps posters uncropped. */
.event-link img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: color-mix(in srgb, var(--color-on-primary) 10%, transparent);
}
.event-link:hover img { opacity: 0.9; }
/* Two-tone ring drawn inside the image (the Swiper viewport clips anything outside the
   slide); outlines paint above the image, so it shows on light and dark pictures. */
.section--primary .event-link:focus-visible { outline-offset: -3px; box-shadow: none; }
.event-link:focus-visible img { outline: 3px solid var(--color-primary); outline-offset: -6px; }

html.has-modal { overflow: hidden; }

.lightbox {
  width: fit-content;
  max-width: 95vw;
  max-height: 90vh;
  max-height: 90dvh;
  padding: 0;
  border: 0;
  border-radius: 4px;
  overflow: auto;
  background: var(--color-background);
  color: var(--color-text);
}
.lightbox::backdrop { background: color-mix(in srgb, var(--color-primary) 85%, transparent); }
/* The figure fills the dialog, so a click on the dialog itself is a backdrop click. */
.lightbox__figure { position: relative; display: flex; flex-direction: column; width: min-content; min-width: min(20rem, 95vw); margin: 0; }
.lightbox__img {
  width: auto;
  max-width: 95vw;
  height: auto;
  max-height: calc(90vh - 4.5rem);
  max-height: calc(90dvh - 4.5rem);
  margin-inline: auto;
  object-fit: contain;
}
.lightbox__caption { padding: 12px 16px; font-weight: 700; overflow-wrap: anywhere; }

.lightbox__close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--color-on-primary);
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.lightbox__close:hover { background: var(--color-text); }
.lightbox__icon { width: 24px; height: 24px; }

/* Loading: keep a sensible box with a spinner until the image's load event. */
.lightbox.is-loading .lightbox__figure { justify-content: flex-end; min-height: min(50vh, 20rem); }
.lightbox.is-loading .lightbox__img { visibility: hidden; }
.lightbox.is-loading .lightbox__figure::before {
  content: "";
  position: absolute;
  top: calc(50% - 20px);
  left: calc(50% - 20px);
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-secondary);
  border-top-color: var(--color-primary);
  border-radius: 50%;
}

@media (prefers-reduced-motion: no-preference) {
  .lightbox.is-loading .lightbox__figure::before { animation: lightbox-spin 0.8s linear infinite; }
  .lightbox[open] { animation: lightbox-in 0.2s ease-out; }
  .lightbox[open]::backdrop { animation: lightbox-fade 0.2s ease-out; }
}
@keyframes lightbox-spin { to { transform: rotate(360deg); } }
@keyframes lightbox-in { from { opacity: 0; transform: scale(0.97); } }
@keyframes lightbox-fade { from { opacity: 0; } }
