/* ==========================================================================
   layout, contract, components, utilities
   --------------------------------------------------------------------------
   contract.css — the core-owned front-end "contract" layer.

   It styles exactly the class families that the CMS itself emits on the front
   end, so any theme renders CMS content and installed module markup correctly
   without re-implementing it. Inventory (locked):

     - A1 .about* .alert* .card* .cards* .contact* .container .prose .section*
          .u-*         (emitted by DB page content)
     - A2 .nav__* .dropdown* .gallery* .contact-info .hours*
          form-control .search* .btn* .u-visually-hidden
                      (emitted by module front-end views; last line = optional tier)
     - A3 .alert .alert-danger .alert-success   (core `$bat.notify`, single dash)

   Inventory lock: a selector may only enter this file if it matches a class in
   the inventory above. No framework creep, no theme branding — token fallbacks
   below are neutral greys, never a theme's palette. Themes declare the real
   token values; the fallbacks only keep a "bare" theme legible.

   Precedence: this file is appended by Inc\Core\Site after the theme's own
   <link>, so it must not rely on load order. A theme that layers its skin
   declares the order `tokens, reset, base, layout, contract, components,
   utilities` — its own remaining rules still win at equal specificity, exactly
   as before the extraction. A theme that declares no @layer (the blog skin)
   has its skin win regardless, because unlayered styles beat every layer.

   See docs/DECISIONS.md (contract layer entry) and
   docs/frontend-contract-and-themes/03-design-system.md.
   ========================================================================== */

@layer contract;

@layer contract {
  /* .container — DB content + every theme shell (A1) */
  .container {
    /* self-sufficient: the width/padding pair below assumes border-box, so the
       contract must not depend on the theme shipping a global reset */
    box-sizing: border-box;
    width: 100%;
    max-inline-size: var(--container, 1140px);
    margin-inline: auto;
    /* gutter inside the safe area: zero inset = normal gutter, notched side = gutter + inset */
    padding-inline: calc(var(--gutter, 1.5rem) + env(safe-area-inset-left)) calc(var(--gutter, 1.5rem) + env(safe-area-inset-right));
  }

  /* .nav__* — navigation module items (A2). The nav *shell* (.nav, .nav__list,
     [data-nav-toggle], .nav--open, breakpoints) stays in each theme. */
  .nav__item { position: relative; }
  .nav__link {
    display: block;
    padding: 10px var(--gutter, 1.5rem);
    line-height: 1.25;
    text-transform: uppercase;
    color: inherit;
    text-decoration: none;
  }
  .nav__item--active > .nav__link,
  .nav__link.active,
  .nav__link:hover,
  .nav__link:focus-visible {
    background: var(--clr-brand, #444);
    color: var(--clr-brand-dark, #fff);
    text-decoration: none;
  }
  .nav__link:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px #fff;
  }

  /* .dropdown* — navigation submenus (A2); behavior in contract.js */
  .dropdown { position: relative; }
  .dropdown__menu {
    display: none;
    position: absolute;
    inset-block-start: 100%;
    inset-inline-start: 0;
    min-inline-size: 200px;
    background: #fff;
    border: 1px solid var(--clr-border, #ddd);
    z-index: 30;
  }
  .dropdown--open .dropdown__menu { display: block; }
  .dropdown__item { border-block-end: 1px solid var(--clr-border, #ddd); }
  .dropdown__item:last-child { border-block-end: 0; }
  .dropdown__link {
    display: block;
    padding: var(--space-2, 1rem) var(--space-3, 1.5rem);
    color: inherit;
    text-decoration: none;
  }
  .dropdown__link:hover,
  .dropdown__link:focus-visible {
    background: var(--clr-brand, #444);
    color: var(--clr-brand-dark, #fff);
    text-decoration: none;
  }
  .dropdown__caret {
    display: inline-block;
    margin-inline-start: 4px;
    border-block-start: 4px solid currentColor;
    border-inline: 4px solid transparent;
  }

  @media (max-width: 767px) {
    .dropdown__menu {
      position: static;
      border: 0;
      background: #f9f9f9;
    }
  }

  /* .section* — DB content only (the footer-cap spacing rule stays in the
     theme: it is shell-dependent) */
  .section { padding-block: 32px 32px; position: relative; }
  .section--light { background: #fff; }
  .section__header { text-align: center; margin-block-end: var(--space-2, 1rem); }
  .section__header h1,
  .section__header h2 {
    font-size: 2rem;                   /* level is demoted for the outline; size pinned */
    text-transform: uppercase;
    letter-spacing: 0.25rem;
    font-weight: 600;
    margin: 0;
  }
  .section__header hr {
    inline-size: 80px;
    height: 3px;
    border: 0;
    background: var(--clr-muted, #555);
    display: inline-block;
    margin-block: var(--space-2, 1rem);
  }

  /* .cards* / .card* — DB content */
  .cards {
    display: grid;
    gap: var(--gutter, 1.5rem);
    grid-template-columns: 1fr;
  }
  @media (min-width: 768px) {
    .cards { grid-template-columns: repeat(3, 1fr); }
  }
  .card {
    background: #fff;
    border: 1px solid var(--clr-border, #ddd);
    padding: var(--space-3, 1.5rem);
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 1rem);
  }
  .card__icon {
    display: block;                    /* self-sufficient: no theme img reset needed */
    inline-size: 80px;
    block-size: 80px;
    margin-inline: auto;
  }
  .card__title {
    font-size: 1.17rem;                /* cards are h2 in content now; keep the h3 size */
    text-align: center;
    text-transform: uppercase;
    margin: 0;
    font-weight: 600;
  }
  .card__body { color: var(--clr-muted, #555); }
  .card__body p { font-size: var(--fs-sm, 1rem); line-height: 1.75; margin: 0 0 var(--space-2, 1rem); }
  .card__body ul { padding-inline-start: 1.25rem; margin-block-end: var(--space-2, 1rem); }
  .card__body li { margin-block-end: var(--space-1, 0.5rem); }

  @media (min-width: 768px) {
    .cards--offer { grid-template-columns: repeat(2, 1fr); }
  }
  .cards--offer .card__head {
    display: flex;
    align-items: center;
    gap: var(--space-2, 1rem);
  }
  .cards--offer .card__icon {
    inline-size: 40px;
    block-size: 40px;
    margin: 0;
  }
  .cards--offer .card__title { text-align: left; }

  .card--intro { margin-block-end: var(--space-4, 2rem); }

  /* .about* — DB content (the #about bottom-padding tweak stays in the theme:
     it targets the content id, not a contract class) */
  .about {
    display: grid;
    gap: var(--space-4, 2rem);
  }
  .about__media { display: block; inline-size: 100%; }
  @media (min-width: 992px) {
    .about { grid-template-columns: 1fr 1fr; }
    .about__content { grid-column: 2; }
    .about__media {                      /* full-bleed left band, prod-style */
      position: absolute;
      inset-block: 0;
      inset-inline-start: 0;
      inline-size: 44.4%;
      block-size: 100%;
      object-fit: cover;
      object-position: center;
    }
  }
  @media (max-width: 991.98px) {
    .about__media {
      block-size: auto;                  /* height follows the image aspect ratio */
      margin-block-start: var(--space-4, 2rem);
    }
  }

  /* .btn* — optional tier (searchbox) + any theme that wants the shared button */
  .btn {
    display: inline-block;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius, 4px);
    text-transform: uppercase;
    font-weight: 700;
    transition: background-color .2s, border-color .2s, color .2s;
    text-decoration: none;
  }
  .btn:hover, .btn:focus-visible { text-decoration: none; }
  .btn--primary {
    background: var(--clr-accent, #444);
    border-color: var(--clr-accent, #444);
    color: var(--clr-brand-dark, #fff);
  }
  .btn--primary:hover,
  .btn--primary:focus-visible {
    background: var(--clr-brand-dark, #fff);
    border-color: var(--clr-brand-dark, #fff);
    color: #fff;
  }

  /* .search* — optional tier (searchbox module) */
  .search {
    display: flex;
    gap: var(--space-1, 0.5rem);
  }
  .search__field {
    flex: 1 1 auto;
    min-inline-size: 0;
    padding: 8px 12px;
    border: 1px solid var(--clr-border-strong, #767676);
    border-radius: var(--radius, 4px);
  }
  .search__button { display: inline-flex; align-items: center; }
  /* the searchbox markup puts an inline SVG in the button; size it here so the
     contract needs no theme base reset to be self-sufficient */
  .search__button svg { inline-size: 1em; block-size: 1em; fill: currentColor; }
  .search-results__item { margin: 0 0 var(--space-3, 1.5rem); }
  .search-results__item dt { font-weight: 700; }
  .search-results__item dd { margin: 0; }

  /* .alert* — DB content (--warning) + core notify (single-dash danger/success) */
  .alert {
    padding: var(--space-3, 1.5rem);
    border: 1px solid var(--clr-border, #ddd);
    border-radius: var(--radius, 4px);
    margin-block-end: var(--space-3, 1.5rem);
    background: #f9f9f9;
  }
  .alert--warning { background: #fcf8e3; border-color: #faebcc; color: #8a6d3b; }
  /* $bat.notify interpolates `alert alert-{type}` (danger|success) */
  .alert-danger  { background: #f2dede; border-color: #ebccd1; color: #a94442; }
  .alert-success { background: #dff0d8; border-color: #d6e9c6; color: #3c763d; }

  /* .gallery* — galleries module (PhotoSwipe wiring stays in the module) */
  .gallery {
    display: grid;
    gap: var(--gutter, 1.5rem);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  }
  .gallery__item { background: #fff; }
  .gallery__link { display: block; }
  .gallery__caption { display: none; }
  .gallery__img {
    display: block;                    /* self-sufficient: no theme img reset needed */
    inline-size: 100%;
    /* the width/height attributes reserve the ratio box before the bytes
       arrive; block-size:auto lets that ratio win over the height attribute */
    block-size: auto;
    background: var(--clr-border, #ddd);   /* neutral placeholder while loading */
    box-shadow: 4px 4px 10px 1px #ddd;
  }
  /* unreadable original: no measured ratio, reserve the photographic default */
  .gallery__img:not([width]) { aspect-ratio: 3 / 2; }

  /* .hours* — business module opening-hours widget */
  .hours__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-1, 0.5rem);
    margin-block-end: var(--space-1, 0.5rem);
  }
  .hours__label { text-align: end; }
  .hours__special-title {
    font-size: 1rem;                   /* demoted h4 -> h3; keep the h4 size */
    margin-block: var(--space-3, 1.5rem) var(--space-2, 1rem);
  }

  /* .contact — DB content block */
  .contact {
    display: grid;
    gap: var(--space-4, 2rem);
    margin-block-start: var(--space-4, 2rem);
  }
  @media (min-width: 992px) {
    .contact { grid-template-columns: 1fr 1fr; }
  }

  /* .prose — DB content */
  .prose { max-inline-size: 70ch; margin-inline: auto; }
  .prose h2 { margin-block-start: var(--space-5, 3rem); }
  .prose ul { padding-inline-start: 1.25rem; margin-block-end: var(--space-2, 1rem); }
  .prose li { margin-block-end: var(--space-1, 0.5rem); }

  /* optional tier: langswitcher emits a bare <select class="form-control"> */
  .form-control {
    padding: 8px 12px;
    border: 1px solid var(--clr-border-strong, #767676);
    border-radius: var(--radius, 4px);
    background: #fff;
    color: inherit;
  }

  /* .u-* — the utilities used by content/module markup (others stay in themes) */
  .u-center { text-align: center; }
  .u-visually-hidden {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
