/* ==========================================================================
   BLOCK AND WIDGET POLISH
   Checked against every core block, classic markup and default widget.
   ========================================================================== */

/* No horizontal scroll from full-bleed blocks (100vw includes the scrollbar) */
.site-main {
  overflow-x: clip;
}

/* Space between blocks */
.entry-content,
.rte {
  > :where(figure, .wp-block-image, .wp-block-group, .wp-block-columns, .wp-block-media-text, .wp-block-cover,
  .wp-block-buttons, .wp-block-file, .wp-block-search, .wp-block-social-links, .wp-block-details, .wp-block-table,
  .wp-block-gallery, .wp-block-latest-posts, .wp-block-latest-comments, .wp-block-calendar, .wp-block-archives,
  .wp-block-categories, .wp-block-page-list, .wp-block-tag-cloud, .wp-block-quote, .wp-block-pullquote,
  .wp-block-separator, .wp-block-embed, .wp-block-audio, .wp-block-video, pre, ul, ol, dl, table, address,
  .gallery, .wp-caption, hr) {
    margin-bottom: var(--space-4);
  }

  h1 {
    margin-top: var(--space-5);
  }

  h1:first-child {
    margin-top: 0;
  }

  /* Links in text only: buttons, pills and icons keep their own look */
  a:is(.wp-element-button, .wp-block-button__link, .wp-block-file__button, .button, .wp-block-social-link-anchor, .tag-cloud-link):not(.btn):not(.chip) {
    text-decoration: none;
  }

  /* Aligned images keep a gap to the wrapping text */
  .alignleft,
  figure.alignleft {
    margin: 0.375rem var(--space-3) var(--space-2) 0;
  }

  .alignright,
  figure.alignright {
    margin: 0.375rem 0 var(--space-2) var(--space-3);
  }

  .aligncenter {
    margin-inline: auto;
  }

  .alignfull,
  .alignfull img,
  .wp-block-cover.alignfull {
    border-radius: 0;
  }
}

/* Pages: wide blocks break out of the text column */
.page-content .entry-content.rte > .alignwide {
  width: ~"min(82.5rem, 100vw - 2 * var(--bs-gutter-x))";
  max-width: none;
  margin-inline: ~"calc((100% - min(82.5rem, 100vw - 2 * var(--bs-gutter-x))) / 2)";
}

/* Posts sit next to a contents / sidebar column: wide and full stay in the column */
.article-body {
  .alignwide,
  .alignfull {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
  }
}

/* Drop cap */
.has-drop-cap:not(:focus)::first-letter {
  float: left;
  margin: 0.08em var(--space-1-5) 0 0;
  font-family: var(--font-heading);
  font-size: 4.4em;
  font-weight: var(--fw-regular);
  line-height: 0.8;
  color: var(--color-primary);
  text-transform: none;
}

/* Code: brand colours instead of the Bootstrap pink */
code {
  color: var(--color-primary-dark);
}

pre code,
.wp-block-code code {
  padding: 0;
  background: none;
  color: inherit;
}

.rte,
.entry-content {
  .wp-block-code {
    border: 0;
    border-radius: var(--radius-lg);
    background-color: var(--color-primary-dark);
    color: var(--color-white);
  }

  pre:not(.wp-block-code) {
    border-radius: var(--radius-lg);
    background-color: var(--color-section-sand);
    color: var(--color-text);
  }

  .wp-block-verse {
    padding: var(--space-3);
    font-family: var(--font-heading);
    font-size: var(--font-size-lg);
    line-height: var(--lh-snug);
    white-space: pre-wrap;
  }
}

/* Tables: soft rows instead of the block library's black borders */
.wp-block-table {
  table {
    width: 100%;
    border-collapse: collapse;
  }

  thead,
  tfoot {
    border: 0;
  }

  th,
  td {
    padding: var(--space-1-5);
    border: 0;
    border-bottom: var(--border-width) solid var(--color-border);
  }

  thead th {
    font-size: var(--font-size-xs);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  tfoot td {
    font-weight: var(--fw-semibold);
  }

  &.is-style-stripes {
    border-bottom: 0;

    td {
      border-bottom: 0;
    }
  }

  figcaption {
    margin-top: var(--space-1);
  }
}

/* Calendar (block and widget) */
.wp-calendar-table,
.widget_calendar table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  text-align: center;

  caption {
    padding-bottom: var(--space-1);
    caption-side: top;
    font-weight: var(--fw-semibold);
    color: var(--color-text);
  }

  th {
    padding: var(--space-1) 0;
    border: 0 !important;
    background-color: var(--color-section-sand) !important;
    font-size: var(--font-size-xs);
    font-weight: var(--fw-semibold);
    color: var(--color-text-muted);
  }

  td {
    padding: 0.375rem 0;
    border: 0 !important;
  }

  a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    border-radius: var(--radius-round);
    background-color: var(--color-primary);
    color: var(--color-white) !important;
    font-weight: var(--fw-semibold);
    text-decoration: none !important;
  }

  #today {
    font-weight: var(--fw-semibold);
    color: var(--color-secondary);
  }
}

.wp-calendar-nav {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-1);
  font-size: var(--font-size-sm);

  a {
    color: var(--color-primary);
    text-decoration: none !important;
  }
}

/* Tag cloud as pills (block and widget) */
.wp-block-tag-cloud,
.tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);

  a {
    display: inline-flex;
    margin: 0 !important;
    padding: 0.375rem 0.875rem;
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-pill);
    background-color: var(--color-surface);
    color: var(--color-text);
    font-size: var(--font-size-xs) !important;
    line-height: 1.4;
    text-decoration: none !important;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);

    &:hover {
      border-color: var(--color-primary);
      background-color: var(--color-primary);
      color: var(--color-white);
    }
  }
}

/* Lists of links (archives, categories, pages, latest posts and comments) */
.wp-block-archives-list,
.wp-block-categories-list,
.wp-block-page-list,
.wp-block-latest-posts,
.wp-block-latest-comments {
  padding-left: 0 !important;
  list-style: none;

  li {
    margin: 0;
    padding-block: 0.3rem;
  }

  ul {
    padding-left: var(--space-2);
    list-style: none;
  }

  a {
    text-decoration: none !important;
    transition: color var(--transition-fast);

    &:hover {
      color: var(--color-secondary);
    }
  }
}

.wp-block-latest-posts {
  &__post-title {
    font-weight: var(--fw-semibold);
  }

  &__featured-image img {
    border-radius: var(--radius-lg);
  }

  &__post-date,
  &__post-author {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
  }

  &__post-excerpt {
    margin-top: var(--space-0-5);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
  }

  &.is-grid li {
    margin-bottom: var(--space-3);
  }
}

.wp-block-latest-comments {
  &__comment {
    margin-bottom: var(--space-2) !important;
  }

  &__comment-meta {
    font-size: var(--font-size-sm);
  }

  &__comment-date {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
  }

  &__comment-excerpt p {
    margin: var(--space-0-5) 0 0;
    font-size: var(--font-size-sm);
  }

  .avatar {
    border-radius: var(--radius-round);
  }
}

/* Widgets */
.widget_recent_entries .post-date {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.widget .wp-caption-text {
  text-align: left;
}

.widget_nav_menu .sub-menu,
.widget_pages .children,
.widget_categories .children {
  padding-left: var(--space-1-5);
}

/* Block widgets: their headings look like the classic widget titles */
.sidebar .widget_block {
  .wp-block-heading,
  h2,
  h3 {
    margin: 0 0 var(--space-1-5);
    font-family: var(--font-body);
    font-size: var(--font-size-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-secondary);
  }
}

.footer-widget.widget_block {
  .wp-block-heading,
  h2,
  h3 {
    margin: 0 0 var(--space-2);
    font-family: var(--font-body);
    font-size: var(--font-size-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--color-white);
  }
}

/* Widgets on the dark footer */
.footer-widget {
  .sub-menu,
  .children {
    padding-left: var(--space-1-5);
    font-size: var(--font-size-sm);
  }

  .post-date,
  .count {
    color: var(--color-on-dark-muted);
    opacity: 0.7;
  }

  .tagcloud a,
  .wp-block-tag-cloud a {
    border-color: var(--color-on-dark-border);
    background-color: transparent;
    color: var(--color-on-dark-muted);

    &:hover {
      border-color: var(--color-white);
      background-color: var(--color-white);
      color: var(--color-primary-dark);
    }
  }

  .wp-calendar-table th,
  .widget_calendar th {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: var(--color-on-dark-muted);
  }
}

/* Widgets and blocks that print forms */
.widget_search .search-form,
.wp-block-search {
  max-width: none;
}

.widget select,
.wp-block-archives-dropdown select,
.wp-block-categories-dropdown select {
  .aurelle-select();
}

.wp-block-search__button {
  margin-left: 0;
}

.wp-block-search__button-inside .wp-block-search__inside-wrapper {
  padding: 0.25rem;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background-color: var(--color-surface);

  .wp-block-search__input {
    min-height: 2.5rem;
    border: 0;
  }
}

.comment-form-cookies-consent input {
  margin-top: 0.2em;
  accent-color: var(--color-primary);
}

/* Nested widget lists: one indent step, not two */
.widget :is(.sub-menu, .children) li {
  padding-left: 0;
}

/* Footer column widgets (Navigation Menu, Text, Custom HTML, blocks) in the
   design's footer link style */
.site-footer__col {
  .footer-widget + .footer-widget {
    margin-top: var(--space-4);
  }

  .widget ul:not(.site-footer__contact) {
    display: flex;
    flex-direction: column;
    gap: var(--space-1-5);
  }

  .widget li {
    padding: 0;
  }

  .widget a {
    color: inherit;
    text-decoration: none;

    &:hover {
      color: var(--color-highlight);
    }
  }

  .wp-block-heading {
    .site-footer__heading-style();
  }

  p {
    margin-bottom: var(--space-1-5);
  }

  address {
    font-style: normal;
  }
}

.site-footer__heading-style() {
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-white);
  margin-bottom: var(--space-2);
}

/* Native checkboxes and radios (comment form, plugins' forms): one look.
   :where() keeps this easy to override; the design's .check boxes and the
   WooCommerce block checkboxes have their own styles. */
:where(input[type='checkbox'], input[type='radio']):where(:not(.check__input, .wc-block-components-checkbox__input, .wc-block-components-radio-control__input)) {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0.15em 0 0;
  accent-color: var(--color-primary);
  vertical-align: top;
  cursor: pointer;
}

/* Phones: 16px text in fields, or iOS zooms the page when one is tapped */
@media (max-width: 47.99em) {
  input:not([type='checkbox'], [type='radio'], [type='submit'], [type='button'], [type='range']),
  select,
  textarea {
    font-size: max(1rem, 16px) !important;
  }
}

/* WooCommerce "Product Search" block: the core Search block look */
.wc-block-product-search {
  margin-bottom: var(--space-3);

  .wc-block-product-search__label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: var(--fw-semibold);
  }

  .wc-block-product-search__fields {
    display: flex;
    gap: var(--space-1);
  }

  /* Extra weight: WooCommerce's block stylesheet loads after the theme */
  .wc-block-product-search__fields .wc-block-product-search__field {
    .aurelle-field();
    flex: 1;
    min-width: 0;
    border-radius: var(--radius-pill);
  }

  .wc-block-product-search__fields .wc-block-product-search__button {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--radius-round);
    background-color: var(--color-primary);
    color: var(--color-white);
    cursor: pointer;
    transition: background-color var(--transition-fast);

    &:hover {
      background-color: var(--color-primary-dark);
    }

    svg {
      width: var(--icon-sm);
      height: var(--icon-sm);
      fill: currentColor;
    }
  }
}

/* Long unbroken words (test strings, URLs, German compounds) wrap inside
   their box instead of widening the layout. Normal text is unaffected:
   a word only breaks when it is longer than the line. */
h1,
h2,
h3,
h4,
h5,
h6,
.crumbs__item,
.post-card__title,
.post-card__excerpt,
.entry-content,
.rte,
.comment-content,
.widget {
  overflow-wrap: break-word;
}

.post-grid > *,
.crumbs__item,
.content-layout > *,
.page-hero__grid > * {
  min-width: 0;
}

/* WordPress admin bar (logged-in users): fixed at the top from 601px
   (32px, 46px up to 782px), it scrolls away on phones. Sticky and fixed
   parts of the theme start below it. */
:root:has(> body.admin-bar) {
  --admin-bar-h: 32px;
}

@media (max-width: 782px) {
  :root:has(> body.admin-bar) {
    --admin-bar-h: 46px;
  }
}

@media (max-width: 600px) {
  :root:has(> body.admin-bar) {
    --admin-bar-h: 0px;
  }
}

.admin-bar {
  .site-header {
    top: var(--admin-bar-h, 0px);
  }

  .scroll-progress,
  .mobile-menu,
  .cart-drawer {
    top: var(--admin-bar-h, 0px);
  }
}

/* Phones: the admin bar scrolls with the page instead of staying fixed, so
   a full-screen panel opened near the top of the page would sit under it.
   The panels keep the bar's height free at their top. */
@media (max-width: 600px) {
  .admin-bar {
    .mobile-menu {
      padding-top: calc(46px + var(--space-1-5));
    }

    .cart-drawer,
    .filters {
      padding-top: 46px;
    }
  }
}

/* Filters are a drawer below lg, a sticky sidebar (own offset) from lg */
@media (max-width: 61.99em) {
  .admin-bar .filters {
    top: var(--admin-bar-h, 0px);
  }
}

/* Footer wordmark: the design size, smaller for long site names so the
   whole name fits (about 0.56em per letter in DM Serif Display). */
.site-footer > .container {
  container-type: inline-size;
}

.site-footer__wordmark {
  font-size: ~"min(var(--font-size-wordmark), calc(100cqi / (var(--chars, 7) * 0.56)))";
}

/* Statement: the floating images stay beside the text, not on it. The
   design placed the first one over the "Our philosophy" label at every width
   and over the text below ~1200px. They show only when the section is wide
   enough (1200px) for them,
   sit beside the statement (bottom left, top right), and the text stays on
   top of them. */
.statement {
  .eyebrow,
  .statement__text {
    position: relative;
    z-index: 1;
  }

  .statement__float {
    display: none;

    &--1 {
      top: auto;
      bottom: 12%;
      left: 3%;
    }

    &--2 {
      top: 16%;
      right: 3%;
      bottom: auto;
    }
  }
}

/* The section's own width decides (it can sit in a narrower page-builder box) */
.statement {
  container-type: inline-size;
}

@container (min-width: 75em) {
  .statement__float {
    display: block !important;
  }
}

/* Collections: the text tile ("Not sure where to start?") grows when its
   text needs more room than the 4:5 photo tiles (narrow phones), instead of
   cutting the heading off. */
.bento__item.quiz-card {
  aspect-ratio: auto;
  min-height: 100%;
}

@media (max-width: 35.99em) {
  .bento .quiz-card {
    padding: var(--space-2);

    .quiz-card__title {
      font-size: var(--font-size-lg);
    }

    .quiz-card__spark {
      width: 2.5rem;
      height: 2.5rem;
    }
  }
}

/* Comment author and date links: plain, colour on hover */
.comment-author a,
.comment-metadata a {
  text-decoration: none;

  &:hover {
    color: var(--color-secondary);
  }
}

/* Header image (Appearance > Header): a full-width banner under the header */
.site-header-image {
  /* Starts right under the announcement bar: the floating menu pill sits
     on top of the image (the header keeps its own space above it). */
  position: relative;
  z-index: 0;
  margin-top: calc((var(--header-height) + var(--space-1-5) * 2) * -1);

  /* Soft overlay in the theme's dark green: stronger at the top, where the
     menu pill sits, lighter towards the bottom. */
  &::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(var(--color-primary-rgb), 0.6) 0%, rgba(var(--color-primary-rgb), 0.28) 55%, rgba(var(--color-primary-rgb), 0.5) 100%);
    pointer-events: none;
  }

  img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 26rem;
    object-fit: cover;
  }
}

/* Header menu items stay on one line; very long labels (or page titles in
   the no-menu fallback) are shortened with "…" instead of wrapping. Plain
   links (no dropdown arrow) are blocks so the "…" works. */
.site-nav__link,
.site-header__logo {
  white-space: nowrap;
}

.site-nav__list > li:not(.has-dropdown) > .site-nav__link {
  display: block;
  max-width: 13rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Desktop menu that does not fit on one line (many or long items): the
   script adds .is-nav-overflow and the header uses its mobile layout, with
   the menu button and the slide-out menu. */
@media @bp-lg {
  .is-nav-overflow {
    .site-header__bar {
      grid-template-columns: 1fr auto 1fr;
      gap: var(--space-1);
      padding-inline: var(--space-1);
    }

    .site-header__logo {
      justify-self: center;
    }

    .site-header__menu-btn {
      display: inline-flex;
    }

    .site-nav {
      display: none;
    }

    .mobile-menu {
      display: flex;
    }
  }
}

/* Text inside cover blocks takes the cover's colour (white by default, or the
   colour picked in the editor), not the muted article paragraph colour. */
.wp-block-cover.wp-block-cover,
.wp-block-cover-image.wp-block-cover-image {
  :is(p, li, h1, h2, h3, h4, h5, h6, cite, figcaption, dd, dt):not(.has-text-color) {
    color: inherit;
  }
}

/* Hero: a longer highlighted phrase wraps instead of pushing the text column
   under the image (the design's single word stays on one line anyway). */
.hero__highlight {
  white-space: normal;
}

.hero__intro,
.hero__visual {
  min-width: 0;
}

/* The decorative wordmark's large letter box reaches up over the last row of
   footer links; it never takes clicks, and the links sit above it. */
.site-footer__wordmark {
  pointer-events: none;
}

.site-footer .row {
  position: relative;
  z-index: 1;
}

/* ---------- Bootstrap tokens: the theme palette everywhere ----------
   Any Bootstrap rule that reads a --bs-* colour gets the Aurelle colour, so
   nothing falls back to Bootstrap blue / grey. */
:root {
  --bs-primary: var(--color-primary);
  --bs-primary-rgb: var(--color-primary-rgb);
  --bs-secondary: var(--color-secondary);
  --bs-secondary-rgb: 168, 90, 53;
  --bs-success: var(--color-success);
  --bs-success-rgb: 46, 125, 79;
  --bs-danger: var(--color-error);
  --bs-danger-rgb: 179, 38, 30;
  --bs-warning: var(--color-rating);
  --bs-warning-rgb: 183, 134, 43;
  --bs-info: var(--color-primary);
  --bs-info-rgb: var(--color-primary-rgb);
  --bs-light: var(--color-background);
  --bs-dark: var(--color-text);
  --bs-blue: var(--color-primary);
  --bs-body-color-rgb: 28, 28, 26;
  --bs-body-bg-rgb: 250, 247, 242;
  --bs-emphasis-color: var(--color-text);
  --bs-secondary-color: var(--color-text-muted);
  --bs-tertiary-color: var(--color-text-muted);
  --bs-secondary-bg: var(--color-accent-soft);
  --bs-tertiary-bg: var(--color-section-sand);
  --bs-border-color-translucent: var(--color-border);
  --bs-heading-color: inherit;
  --bs-link-color: var(--color-primary);
  --bs-link-color-rgb: var(--color-primary-rgb);
  --bs-link-hover-color: var(--color-secondary);
  --bs-link-hover-color-rgb: 168, 90, 53;
  --bs-highlight-bg: var(--color-highlight);
  --bs-focus-ring-color: var(--color-focus);
  --bs-form-valid-color: var(--color-success);
  --bs-form-valid-border-color: var(--color-success);
  --bs-form-invalid-color: var(--color-error);
  --bs-form-invalid-border-color: var(--color-error);
}

.pagination {
  --bs-pagination-color: var(--color-text);
  --bs-pagination-hover-color: var(--color-primary);
  --bs-pagination-focus-color: var(--color-primary);
  --bs-pagination-focus-box-shadow: 0 0 0 0.25rem var(--color-focus);
  --bs-pagination-active-bg: var(--color-primary);
  --bs-pagination-active-border-color: var(--color-primary);
}

.progress {
  --bs-progress-bar-bg: var(--color-primary);
}

/* Native checkboxes, radios and range sliders use the theme colour */
input[type='checkbox'],
input[type='radio'],
input[type='range'],
progress {
  accent-color: var(--color-primary);
}

/* ---------- Select dropdown list ----------
   Browsers that support customizable selects (Chrome / Edge 135+) draw the
   open list in the theme style; others keep their system list. */
@supports (appearance: base-select) {
  /* !important: several field rules set appearance: none on selects */
  select:not([multiple]):not([size]),
  select:not([multiple]):not([size])::picker(select) {
    appearance: base-select !important;
  }

  /* base-select sizes to the chosen option, not the longest one: keep the
     sort menu as wide as before */
  .woocommerce-ordering select.orderby {
    min-width: 14rem;
  }

  select:not([multiple]):not([size]) {
    /* base-select lays the button out as flex: keep the text centred */
    align-items: center;

    &::picker-icon {
      display: none; /* the theme draws its own arrow */
    }

    &::picker(select) {
      margin-top: 0.25rem;
      padding: 0.25rem;
      border: var(--border-width) solid var(--color-border);
      border-radius: var(--radius-lg);
      background-color: var(--color-surface);
      box-shadow: var(--shadow-md);
    }

    option {
      padding: 0.5rem 0.75rem;
      border-radius: var(--radius-md);
      color: var(--color-text);
      font-size: var(--font-size-sm);

      &::checkmark {
        display: none;
      }

      &:hover,
      &:focus-visible {
        background-color: var(--color-accent-soft);
        color: var(--color-text);
        outline: none;
      }

      &:checked {
        background-color: var(--color-primary);
        color: var(--color-white);
        font-weight: var(--fw-semibold);
      }

      &:disabled {
        color: var(--color-text-muted);
        opacity: 0.6;
      }
    }
  }
}
