@layer tokens, reset, base, layout, contract, components, utilities;

@layer tokens {
  :root {
    /* Brand green: fills, the hamburger button, the skewed pill, the focus ring.
       4.74:1 on white — AA for body-size text, so white ink on it (--clr-brand-dark)
       is readable; body text on white uses --clr-link. */
    --clr-brand:      #508000;
    --clr-brand-dark: #ffffff;
    --clr-accent:     #ffc72b;
    /* link / text-on-white green: 4.81:1 on white (AA for normal-size text) */
    --clr-link:       #5a7d00;
    --clr-text:       #333;
    /* 5.33:1 on white (prod's #7b7b7b was 4.23:1 and failed AA for body-size text) */
    --clr-muted:      #6b6b6b;
    /* decorative separators/card edges only — exempt from WCAG 1.4.11 */
    --clr-border:     #e6e9ed;
    /* outlines that identify an interactive control must be >=3:1 on white (1.4.11) */
    --clr-border-strong: #767676;
    --clr-bg:         #fff;
    --clr-bg-dark:    #232323;
    --clr-on-dark:    #fff;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
                 Arial, "Noto Sans", sans-serif;

    --container: 1140px;
    --gutter: 1.5rem;
    --radius: 4px;

    --fs-xs: 0.875rem;
    --fs-sm: 1rem;
    --fs-md: 1.125rem;
    --fs-lg: 1.5rem;

    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2rem;
    --space-5: 3rem;
    --space-6: 4rem;

    --shadow-card: 0 0 0 1px var(--clr-border);
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
  }
  body { margin: 0; }
  img, svg, video { display: block; max-inline-size: 100%; height: auto; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; background: transparent; border: 0; }
  ul[class], ol[class] { list-style: none; margin: 0; padding: 0; }
  svg:not(:root) { overflow: hidden; }
}

@layer base {
  html { position: relative; min-height: 100%; background: var(--clr-bg-dark); }
  body {
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--clr-text);
    background: var(--clr-bg);
    /* The footer's dark background has to reach the bottom of the SCREEN even
       while browser UI overlays it (Safari's bottom bar). `dvh` shrinks as that
       UI appears, so sizing against it leaves an uncovered strip below the footer
       that exposes body's white -- the strip the Safari bar then sits over.
       `lvh` is the tallest viewport state, so the footer always covers it.
       Since lvh >= dvh always, this only ever makes body taller, never shorter.
       Footer *content* is kept clear of the bar separately, by .site-footer's
       env(safe-area-inset-bottom) padding. */
    min-block-size: 100vh;              /* fallback for browsers without lvh */
    min-block-size: 100lvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-wrap: break-word;         /* long words/URLs must not force sideways scroll (1.4.10) */
  }
  a { color: var(--clr-link); text-decoration: underline; }
  a:hover, a:focus-visible { text-decoration: underline; }
  [id] { scroll-margin-block-start: 5rem; }   /* jumped-to anchors clear the sticky header */
  h1, h2, h3, h4, h5, h6 {
    margin-block: var(--space-4) var(--space-2);
    line-height: 1.2;
    text-wrap: balance;
  }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.17rem; }
  h4 { font-size: 1rem; }
  h5 { font-size: 0.875rem; }
  h6 { font-size: 0.8125rem; }
  p { margin-block: 0 var(--space-2); }
  hr { border: 0; border-block-start: 1px solid var(--clr-border); margin-block: var(--space-3); }
  svg.icon { width: 1em; height: 1em; vertical-align: -0.125em; fill: currentColor; }
  :focus-visible { outline: 2px solid var(--clr-brand); outline-offset: 2px; }
}

@layer layout {
  /* .container moved to contract.css (it is emitted by DB content as well as
     every theme shell); the nav/brand overrides of it stay below. */
  .grid { display: grid; gap: var(--gutter); }
  .grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
  .grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
  @media (min-width: 768px) {
    .grid--2--fixed { grid-template-columns: repeat(2, 1fr); }
    .grid--3--fixed { grid-template-columns: repeat(3, 1fr); }
  }
}

@layer components {
  .skip-link {
    position: absolute;
    inset-block-start: -100px;
    inset-inline-start: 8px;
    z-index: 100;
    background: #fff;
    color: var(--clr-text);
    padding: 10px 16px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    transition: inset-block-start .2s ease-in-out;
  }
  .skip-link:focus { inset-block-start: 8px; text-decoration: none; }

  /* the hero logo box is desktop-only now; on mobile the logo lives in the .nav bar */
  .brand { display: none; }

  /* Desktop header mode is opt-out: site.js adds `nav-compact` on <body> when the
     menu cannot fit (dynamic breakpoint), which drops the whole site back to the
     mobile header. `:not()` keeps this working without JS. */
  @media (min-width: 768px) {
    body:not(.nav-compact) .brand {
      display: block;
      position: absolute;
      inset-inline: 0;
      inset-block-start: 0;
      z-index: 10;
      background: transparent;
    }
    .brand .container { display: flex; justify-content: flex-start; }
    .brand__link {
      display: inline-block;
      background: #fff;
      padding: 15px;
      position: relative;
      z-index: 2;
    }
    .brand__link::before {
      content: "";
      position: absolute;
      inset-block: 0;
      inset-inline-start: -899px;
      inline-size: 900px;
      background: #fff;
      z-index: -2;
    }
    .brand__link::after {
      content: "";
      transform: skewX(19deg);
      position: absolute;
      inset-block: 0;
      inset-inline-end: -22px;
      inline-size: 50px;
      background: #fff;
      z-index: -1;
    }
    .brand__logo { height: 80px; width: auto; }
  }

  /* the nav is first in the DOM so it can host the mobile top bar; on desktop it
     must still render below the hero (prod layout) — body is a flex column */
  @media (min-width: 768px) {
    body:not(.nav-compact) .hero,
    body:not(.nav-compact) .page-hero { order: -2; }
    body:not(.nav-compact) .nav { order: -1; }
  }

  .nav {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    border-block-end: 1px solid var(--clr-border);
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  }
  .nav .container {
    max-inline-size: none;
    padding-inline: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  .nav__brand { display: flex; align-items: center; margin: 8px; }
  .nav__brand img { height: 40px; width: auto; }
  .nav__toggle {
    display: block;
    background: var(--clr-brand);
    border: 1px solid var(--clr-brand);
    border-radius: var(--radius);
    padding: 14px 11px;
    margin: 8px;
    margin-inline-start: auto;
  }
  .nav__bar {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
  }
  .nav__bar + .nav__bar { margin-block-start: 4px; }
  .nav__list {
    /* Out of flow in the mobile layout: the list overlays the page below the bar instead of
       growing it, so the document height is identical in every state of the slide. That is
       what makes it safe to close the menu on `scroll` (site.js, D-035): a height change here
       makes Chrome re-anchor and fire `scroll` events nobody caused — on open the menu slammed
       itself shut again, on close the page jumped by the menu's height. `background` replaces
       what `.nav`'s own white used to paint behind the list. Desktop mode goes static again. */
    position: absolute;
    inset-block-start: 100%;
    inset-inline: 0;
    background: #fff;
    /* on the base rule, not on `.nav--open`: the class is dropped before the collapse
       animates, so a shadow attached to it would pop off while the panel is still sliding.
       `visibility: hidden` hides it entirely once collapsed, and desktop cancels it. */
    box-shadow: 0 10px 16px rgba(0, 0, 0, .14);
    flex: 1 0 100%;
    max-block-size: 0;
    overflow: hidden;
    visibility: hidden;
    transition: max-block-size .3s ease-in-out, visibility 0s linear .3s;
  }
  .nav--open .nav__list {
    max-block-size: 100vh;
    visibility: visible;
    transition: max-block-size .3s ease-in-out, visibility 0s;
  }

  @media (min-width: 768px) {
    body:not(.nav-compact) .nav__brand { display: none; }
    body:not(.nav-compact) .nav__toggle { display: none; }
    body:not(.nav-compact) .nav__list {
      position: static;                    /* the desktop bar is a real row, not an overlay */
      box-shadow: none;                     /* no floating edge on the desktop bar */
      display: flex;
      flex-wrap: wrap;
      flex: 1 1 auto;
      justify-content: center;
      /* room for the skewed active box, so it never bleeds past the viewport edge;
         site.js measures the exact overhang and sets --skew-room */
      padding-inline: var(--skew-room, 12px);
      max-block-size: none;
      overflow: visible;
      visibility: visible;
      transition: none;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    .nav__list { transition: none; }
  }

  /* .nav__item / .nav__link (and .dropdown*) moved to contract.css: they are
     emitted by the navigation module, not by the theme shell. The
     `body:not(.nav-compact)` desktop styling below stays here — it is roldrop's
     skin (skew, sizes, breakpoint). */

  @media (min-width: 768px) {
    body:not(.nav-compact) .nav__list { position: relative; z-index: 10; }
    body:not(.nav-compact) .nav__item { padding-inline-end: 6px; }
    body:not(.nav-compact) .nav__link {
      font-size: 1.25rem;
      line-height: 1;                  /* keeps the 60px bar height with 20px block padding */
      padding-block: 20px;
      position: relative;
    }
    body:not(.nav-compact) .nav__link::before {
      content: "";
      position: absolute;
      inset: 0;
      transform: skewX(19deg);
      background: transparent;
      z-index: -1;
      transition: background-color .3s;
    }
    body:not(.nav-compact) .nav__link:hover::before,
    body:not(.nav-compact) .nav__link:focus-visible::before,
    body:not(.nav-compact) .nav__item--active > .nav__link::before,
    body:not(.nav-compact) .nav__link.active::before {
      background: var(--clr-brand);
    }
    body:not(.nav-compact) .nav__item--active > .nav__link,
    body:not(.nav-compact) .nav__link.active,
    body:not(.nav-compact) .nav__link:hover,
    body:not(.nav-compact) .nav__link:focus-visible {
      background: transparent;
    }
    /* on desktop the fill lives on the skewed ::before, so move the focus ring there too —
       an inset ring traces the same parallelogram as the active background */
    body:not(.nav-compact) .nav__link:focus-visible {
      outline: none;
      box-shadow: none;
    }
    body:not(.nav-compact) .nav__link:focus-visible::before {
      box-shadow: inset 0 0 0 2px #fff;
    }
  }

  .hero {
    position: relative;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;   /* we handle horizontal drags (swipe) ourselves */
  }
  .hero__viewport {
    overflow: hidden;
    position: relative;
    block-size: 220px;
  }
  .hero__slide {
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    transition: transform .9s ease-in-out;
    background-size: cover;
    background-position: center;
    z-index: 1;
  }
  .hero__slide--active { transform: translateX(0); z-index: 2; }
  .hero__slide--from-right { transform: translateX(100%); }
  .hero__slide--from-left  { transform: translateX(-100%); }
  .hero__slide--to-left    { transform: translateX(-100%); }
  .hero__slide--to-right   { transform: translateX(100%); }
  .hero__slide--no-transition { transition: none; }
  .hero__slide:first-of-type { background-position: center; }
  .hero__slide:nth-of-type(3) { background-position: center bottom; }
  @media (prefers-reduced-motion: reduce) {
    .hero__slide { transition: none; }
  }
  .hero__caption {
    position: absolute;
    inset-inline: 0;
    inset-block-start: 55%;
    transform: translateY(-50%);
    inline-size: fit-content;
    max-inline-size: 70%;
    margin-inline: auto;
    text-align: left;
    color: #fff;
    z-index: 10;
    text-shadow: none;
  }
  .hero__title {
    font-size: 2.25rem;
    line-height: 1.1;
    margin: 0 0 15px;
    font-weight: 700;
    color: #fff;
  }
  .hero__text {
    font-size: 1rem;
    margin: 0;
    font-weight: 400;
    color: #fff;
  }
  @media (min-width: 768px) {
    .hero__viewport { block-size: 450px; }
    .hero__title {
      font-size: 4.5rem;
      /* was 60px on a 72px title (0.83) — Polish ogonek/descenders collided with the
         next line; 1.05 keeps the tight prod look without the overlap */
      line-height: 1.05;
      text-transform: uppercase;
    }
    .hero__text {
      font-size: 1.5rem;
      line-height: 1.2;
      text-transform: uppercase;
    }
  }

  .hero__caption > * {
    animation-duration: 1s;
    animation-fill-mode: both;
  }
  .hero__slide--active .hero__title { animation-name: fadeInLeft; }
  .hero__slide--active .hero__text  { animation-name: fadeInRight; }
  @media (prefers-reduced-motion: reduce) {
    .hero__caption > * { animation: none; }
  }

  @keyframes fadeInLeft {
    from { opacity: 0; transform: translate3d(-100%, 0, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
  }
  @keyframes fadeInRight {
    from { opacity: 0; transform: translate3d(100%, 0, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
  }

  .hero__indicators {
    position: absolute;
    inset-inline: 0;
    inset-block-end: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    z-index: 15;
  }
  /* The list items are only wrappers — taking them out of the box model keeps
     the row exactly as tall as the buttons. */
  .hero__indicators > li { display: contents; }
  /* The button IS the target: 24x24, so it meets WCAG 2.5.8 (the audit
     measures the element's own box — a pseudo-element overlay does not count).
     The visible dot is drawn in the middle of that box, which keeps the
     original 10px rhythm between the dots. */
  .hero__indicator {
    position: relative;
    inline-size: 24px;
    block-size: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
  }
  .hero__indicator::before {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #fff;
  }
  .hero__indicator--active::before {
    background: #fff;
  }

  .hero__control {
    position: absolute;
    inset-block: 0;
    inline-size: 15%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    z-index: 9;
    opacity: 0.5;
    transition: opacity 0.15s;
  }
  .hero__control svg.icon {
    inline-size: 36px;
    block-size: 36px;
  }
  .hero__control--prev {
    inset-inline-start: 0;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0, rgba(0, 0, 0, 0.0001) 100%);
  }
  .hero__control--next {
    inset-inline-end: 0;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0.0001) 0, rgba(0, 0, 0, 0.5) 100%);
  }
  .hero__control:hover,
  .hero__control:focus-visible { opacity: 0.9; }
  /* The hero sits on a photo, so the brand-green focus ring is unreadable
     there: the controls get a white ring instead (the arrows are white too).
     The ring is drawn around the glyph, not around the full-width button. */
  .hero__control:focus-visible {
    outline: none;
  }
  .hero__control:focus-visible svg.icon {
    outline: 2px solid #fff;
    outline-offset: 4px;
    border-radius: 50%;
  }
  .hero__indicator:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
  }
  @media (max-width: 991px) {
    .hero__control { display: none; }
  }

  .page-hero {
    position: relative;
    min-block-size: 150px;
    overflow: hidden;
    background: url("../img/header_bg.jpg") center 70% / cover no-repeat;
  }
  .page-hero__map {
    inline-size: 100%;
    block-size: 300px;
  }
  @media (min-width: 768px) {
    .page-hero { min-block-size: 300px; }
  }

  /* Footer cap spacing: this one stays here — it targets roldrop's own `#main`
     shell and the dynamic `nav-compact` breakpoint, not the contract. */
  @media (min-width: 992px) {
    body:not(.nav-compact) #main > .section:last-of-type { padding-block-end: 100px; }
  }

  /* .section* / .section__header*, .cards* / .card*, .about*, .btn* / .btn--primary,
     .search*, .alert* / .alert--warning, .gallery*, .hours*, .contact and .prose
     all moved to contract.css — they are emitted by DB content or module views,
     not by this theme. `.btn--hidden` and the `.alert--*` notify variants stay
     below: they are roldrop's own markup (`alert alert--{type}`). */

  .btn--hidden { display: none; }

  /* roldrop's own notify markup is `alert alert--{type}` — keep the variants */
  .alert--success { background: #dff0d8; border-color: #d6e9c6; color: #3c763d; }
  .alert--danger  { background: #f2dede; border-color: #ebccd1; color: #a94442; }
  .alert--info    { background: #d9edf7; border-color: #bce8f1; color: #31708f; }

  /* content id, not a contract class: keep the about section's bottom tweak */
  @media (max-width: 991.98px) {
    #about { padding-block: var(--space-4) 0; }   /* regular top padding, flush to footer */
  }

  .pagination {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    margin-block: var(--space-4);
  }
  .pagination__link {
    padding: 5px 14px;
    border: 1px solid var(--clr-border-strong);
    border-radius: 15px;
    color: inherit;
    text-decoration: none;
    display: inline-block;
  }
  .pagination__link:hover,
  .pagination__link:focus-visible {
    background: var(--clr-brand);
    color: var(--clr-brand-dark);
    border-color: var(--clr-brand);
    text-decoration: none;
  }

  /* .gallery*, .hours*, .contact and .prose moved to contract.css (module /
     content classes). */

  .article { margin-block-end: var(--space-2); }
  .article--short {
    background: #fff;
    border: 1px solid var(--clr-border);
    padding: 15px;
  }
  .article__grid {
    display: grid;
    gap: var(--gutter);
  }
  @media (min-width: 992px) {
    .article__grid { grid-template-columns: 1fr 3fr; }
    .article__grid--text { grid-template-columns: 1fr; }
  }
  .article__media {
    background: #fff;
    border: 1px solid var(--clr-border);
    padding: 15px;
  }
  .article__media img {
    display: block;
    inline-size: 100%;
    block-size: auto;
  }
  @media (max-width: 991.98px) {
    .article__media { display: none; }
  }
  .article__title { margin-block: 0 var(--space-2); }
  .article--short .article__title {
    margin-block: 0;
    text-transform: uppercase;
    font-weight: 600;
  }
  .article__meta {
    display: flex;
    gap: var(--space-3);
    color: var(--clr-muted);
    font-size: var(--fs-xs);
    margin-block-end: var(--space-2);
  }
  .article--short .article__meta { color: inherit; font-weight: 600; }
  .article__date { display: flex; align-items: center; gap: 4px; }
  .article--short .article__date svg.icon { color: var(--clr-accent); }
  .article__content { margin-block-end: var(--space-2); }

  .site-footer {
    background: var(--clr-bg-dark);
    color: var(--clr-on-dark);
    padding-block: 30px;
    padding-block-end: calc(30px + env(safe-area-inset-bottom));
    font-size: 1.125rem;
    font-weight: 400;                  /* white-on-dark at 300 reads lighter than it is */
    position: relative;
    margin-block-start: auto;
  }
  /* angled top cap. Bleeds off the viewport edge on purpose (-20px tucks the slanted
     left corner off-screen so no seam shows), so — unlike the nav's indicator — it needs
     no reserved room. Wide mode only, and it follows the nav's dynamic breakpoint. */
  .site-footer::before {
    content: "";
    display: none;
    position: absolute;
    background: var(--clr-bg-dark);
    transform: skewX(19deg);
    block-size: 50px;
    inline-size: 50%;
    inset-block-start: -50px;
    inset-inline-start: -20px;
  }
  .site-footer__inner {
    display: grid;
    gap: var(--space-2);
    align-items: center;
    text-align: center;
  }
  /* the global link colour (dark green) only reaches 3.2:1 on the dark footer */
  .site-footer a { color: var(--clr-on-dark); }
  .site-footer a:hover,
  .site-footer a:focus-visible { color: var(--clr-accent); }
  .site-footer__credits img {
    inline-size: 28px;
    block-size: auto;
    margin-inline: auto;
    opacity: 0.7;
  }
  /* 3 columns need their own 992px, but the nav can force the mobile header wider than
     that (~1010px), in which case the footer follows and stacks — one "desktop mode" */
  @media (min-width: 992px) {
    body:not(.nav-compact) .site-footer::before { display: block; }
    body:not(.nav-compact) .site-footer__inner {
      grid-template-columns: repeat(3, 1fr);
    }
    body:not(.nav-compact) .site-footer__address { text-align: left; }
    body:not(.nav-compact) .site-footer__copyright { text-align: center; }
    body:not(.nav-compact) .site-footer__credits { text-align: right; }
    body:not(.nav-compact) .site-footer__credits img { margin-inline: auto 0; }
  }

  /* The cookie banner (cookie/cookie-alert.js + cookie-alert.css) ships its
     own styles and icons; the theme does not restyle it (yet — the library
     exposes .cookie-alert* classes for that). */
}

@layer utilities {
  /* .u-center and .u-visually-hidden moved to contract.css (used by content /
     module markup). */
  .u-text-start { text-align: start; }
  .u-text-end { text-align: end; }
  @media (max-width: 767px) {
    .u-hide-mobile { display: none !important; }
  }
}
