/*
Theme Name: Arbocatalogus
Theme URI:
Author: GI Merijn
Author URI:
Description: Basis voor Arbocatalogus (Orsima en WIZZ). Kies de site via define( 'ARBO_SITE', 'orsima' | 'wizz' ) in wp-config.php.
Requires at least: 7.0
Tested up to: 7.0
Requires PHP: 8.0
Version: 0.2.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: arbocatalogus
Tags:
*/

/*
 * Design tokens live in theme.json (+ /variants/{site}.json), not here.
 * WordPress outputs them as CSS custom properties:
 *
 *   Colors     var(--wp--preset--color--text | accent | primary | secondary | tertiary
 *                   | background-dark | background-medium | background-light | white)
 *   Gradients  var(--wp--preset--gradient--gradient-1 | gradient-2 | gradient-3)
 *   Font sizes var(--wp--preset--font-size--small | normal | normal-medium | medium
 *                   | large-medium | large | extra-large)
 *   Shadow     var(--wp--preset--shadow--drop)
 *   Radius     var(--wp--custom--radius--small | medium | large | extra-large)
 *   Home tiles var(--wp--custom--home-tile--{dark|medium|light}--{background|border|text})
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/*
 * Top-level template sections (header, hero, main, footer) sit flush against
 * each other. Core adds the root blockGap between them via
 * `:where(.wp-site-blocks) > *`, which leaves white bars. Spacing between
 * sections is handled by the sections themselves.
 */
.wp-site-blocks > * {
  margin-block-start: 0;
}

/* Elements that bleed to the screen edge use 100vw, which includes the
   scrollbar; clip (not hidden) so sticky positioning keeps working. */
body {
  overflow-x: clip;
}

/*
 * Content area with a sidebar (templates: group.arbo-content > sidebar +
 * group.arbo-content__main). Two columns; the sidebar is sticky (see
 * blocks/sidebar/style.css). Full-width parts (e.g. teasers) come after
 * .arbo-content, so the sidebar stops before them.
 */
.arbo-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(
      var(--wp--custom--sidebar--width),
      40%
    );
  column-gap: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}
.arbo-content > .arbo-content__main {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  margin-block-start: 0;
}
.arbo-content > .arbo-sidebar {
  grid-column: 2;
  grid-row: 1;
}
/* Small screens: one column, the sidebar below the content. */
@media (max-width: 900px) {
  .arbo-content {
    display: flex;
    flex-direction: column;
  }
  .arbo-content > .arbo-content__main {
    order: 1;
  }
  .arbo-content > .arbo-sidebar {
    width: 100%;
    order: 2;
  }
}

/*
 * Wide parts of the content run under the sidebar column, to the full
 * content width: fold-outs (Details) and anything set to wide/full alignment.
 * The sidebar gets pushed up when it reaches them (blocks/sidebar/view.js).
 * 100cqw = the width of .arbo-content.
 */
.arbo-content {
  container-type: inline-size;
}
@media (min-width: 901px) {
  .arbo-content__main > :is(.wp-block-details, .alignwide, .alignfull),
  .arbo-content__main
    > .wp-block-post-content
    > :is(.wp-block-details, .alignwide, .alignfull) {
    width: 100cqw;
    max-width: none;
  }
}

.arbo-content__main img {
  max-width: 100%;
}

/* =====================================================================
 * Content typography (sizes/colours of headings and links: theme.json)
 * ===================================================================== */

/* Containers whose direct children are content blocks. */
:is(
  .wp-block-post-content,
  .arbo-content__main,
  .wp-block-details,
  .wp-block-group,
  .wp-block-column
) {
  /* Headings: more space above, little below, so they belong to the text
     that follows. First child / right after a fold-out bar: left alone. */
  & > :is(h1, h2, h3, h4, h5, h6):not(:first-child):not(summary + *) {
    margin-block-start: 2.25rem;
  }
  & > :is(h4, h5, h6):not(:first-child):not(summary + *) {
    margin-block-start: 1.75rem;
  }
  & > :is(h1, h2, h3, h4, h5, h6) + * {
    margin-block-start: 0.5rem;
  }
  /* Heading straight after a heading: keep them together too. */
  & > :is(h1, h2, h3, h4, h5, h6) + :is(h1, h2, h3, h4, h5, h6) {
    margin-block-start: 0.75rem;
  }
}

/* Lists: aligned with the text, markers inside the content edge, wrapped
   lines aligned with the text of the first line (hanging indent). */
.wp-block-list {
  padding-inline-start: 1.15em;

  & li::marker {
    color: var(--wp--preset--color--accent);
  }
  & li + li {
    margin-block-start: 0.3em;
  }
  /* Nested lists indent one step from their parent text. */
  & .wp-block-list {
    margin-block: 0.3em 0;
  }
}
ol.wp-block-list {
  padding-inline-start: 1.6em;

  & li::marker {
    font-weight: 600;
  }
}

/* Links that open in a new tab: small "external" icon after the text.
   Skips buttons and links around images. The icon carries the text
   "opent in nieuw tabblad" for screen readers. */
:is(.wp-block-post-content, .arbo-content__main, .wp-site-blocks > footer)
  a[target='_blank']:not(.wp-element-button):not(:has(img))::after {
  content: '' / ' (opent in nieuw tabblad)';
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-inline-start: 0.25em;
  vertical-align: baseline;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 2h5v5M14 2 7.5 8.5M12 9.5V13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3.5'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* ---------- Arrow link list (sidebar, accordions, lists) ---------- */

.arbo-link-list {
  --arrow: var(--wp--preset--color--accent);

  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;

  & li {
    position: relative;
    padding-inline-start: 1.5rem;
  }
  /* Diagonal arrow ↗ */
  & li::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0.3em;
    width: 0.85rem;
    height: 0.85rem;
    background: var(--arrow);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 13 13 3M5 3h8v8'/%3E%3C/svg%3E")
      center / contain no-repeat;
  }
  & a {
    color: inherit;
    text-decoration: none;
  }
  & a:hover,
  & a:focus-visible {
    text-decoration: underline;
  }
}

/* ---------- Print the page itself ---------- */

@media print {
  .wp-site-blocks > header,
  .wp-site-blocks > footer,
  .arbo-sidebar,
  .arbo-hero__image,
  .arbo-hero__breadcrumbs,
  .arbo-hero__icon {
    display: none !important;
  }
  .arbo-hero,
  .arbo-hero__banner {
    min-height: 0 !important;
    padding: 0 !important;
    color: var(--wp--preset--color--text) !important;
    background: none !important;
  }
  .arbo-hero__banner::before {
    display: none;
  }
}
