/* «Fri seksjon»: free sections added under Nettsiden in admin (core crm.md → Nettsiden → «Fri seksjon»).
   The structure and the 12-column grid, the same on every site; the markup comes from api/lib/site_free_render.php.
   SHARED FILE: this is the source; a brand site's site/css/free-section.css is a byte-identical copy
   (tools/test-site-free.php fails when they differ): edit here, then copy it there.
   No colour, font or size of a site is written here: headings, text, buttons, quotes and films carry the site's own
   classes, and the --fri-* tokens below are set by each site from its own tokens
   (the private-customer company: css/free-section-em.css; a business workspace: css/site.css). The fallbacks are sizes only. */

.fri {
  background: var(--fri-ground, transparent);
  padding-block: var(--fri-pad-m, 4rem);
  padding-inline: var(--fri-side, 1.5rem);
}
.fri--pad-s { padding-block: var(--fri-pad-s, 2rem); }
.fri--pad-l { padding-block: var(--fri-pad-l, 6rem); }
/* Lys and Mørk take the shape of the site's own coloured panels: --fri-radius, and --fri-panel-gap above and below
   (sibling margins collapse, so two panels in a row keep exactly the site's gap between them) */
.fri--bg-lys { background: var(--fri-tint, transparent); border-radius: var(--fri-radius, 0); margin-block: var(--fri-panel-gap, 0); }
.fri--bg-mork { background: var(--fri-deep, transparent); color: var(--fri-on-deep, inherit); border-radius: var(--fri-radius, 0); margin-block: var(--fri-panel-gap, 0); }

/* the container, inside the section's side padding (--fri-side), each width as the site itself does it:
   Normal = the container of the site's own content sections (--fri-max-normal, centred; none = the full width);
   Bred = the site's widest content container (--fri-max-bred);
   Smal = a text measure (--fri-max-smal) inside the normal container, placed where the site puts narrow text:
   --fri-smal-place «auto» = centred, «0 auto» = at the normal container's left edge. */
.fri__in { max-width: var(--fri-max-normal, 74rem); margin-inline: auto; }
.fri--w-bred .fri__in { max-width: var(--fri-max-bred, 90rem); }
.fri--w-smal .fri__grid { max-width: var(--fri-max-smal, 44rem); margin-inline: var(--fri-smal-place, auto); }

/* the grid: 12 equal columns, rows as needed; the blocks in their order, each spanning --w columns (from --x when set) */
.fri__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--fri-gap, 1.5rem);
  align-items: start;
}
.fri__grid > .fri-b { grid-column: span var(--w, 12); margin: 0; min-width: 0; }
.fri__grid > .fri-b--at { grid-column: var(--x, auto) / span var(--w, 12); }
.fri__grid > .fri-va--top { align-self: start; }
.fri__grid > .fri-va--center { align-self: center; }
.fri__grid > .fri-va--bottom { align-self: end; }
/* a block placed on its own row (--y, numbered 1 … n by the renderer) and a block with a height of its own (--h, in rem):
   a picture or film fills that height (cropped to fit), a spacer is that tall, any other block is at least that tall */
.fri__grid > .fri-b--row { grid-row: var(--y, auto); }
/* a block beside a stack (--s rows from its own; the renderer's em_free_stack): the grid's rows come from the renderer (--rows), every row it
   spans but the last as tall as its own blocks, so its extra height goes under the stack in the other columns, not between those blocks.
   A cropped picture clips without becoming a scroll box (overflow: clip), so its height still counts when the rows are sized. */
.fri__grid--span { grid-template-rows: var(--rows, none); }
.fri__grid > .fri-b--span { grid-row: var(--y, auto) / span var(--s, 1); }
.fri__grid > .fri-b--span.fri-crop { overflow: clip; }
.fri__grid > .fri-b--h { min-height: calc(var(--h, 0) * 1rem); }
.fri__grid > .fri-b--bilde.fri-b--h img, .fri__grid > .fri-b--film.fri-b--h :is(video, iframe) { height: calc(var(--h, 0) * 1rem); aspect-ratio: auto; object-fit: cover; }
.fri__grid > .fri-b--luft.fri-b--h { height: calc(var(--h, 0) * 1rem); }
/* a phone: every block the full width, one under the other, in their order; a height of its own gives way to the content
   (a picture keeps its own shape or the chosen format, a spacer at most 6rem) */
@media (max-width: 640px) {
  .fri__grid > .fri-b, .fri__grid > .fri-b--at { grid-column: 1 / -1; }
  .fri__grid > .fri-b--row { grid-row: auto; }
  .fri__grid--span { grid-template-rows: none; }
  .fri__grid > .fri-b--h { min-height: 0; }
  .fri__grid > .fri-b--bilde.fri-b--h img { height: auto; }
  .fri__grid > .fri-b--film.fri-b--h :is(video, iframe) { height: auto; aspect-ratio: 16 / 9; }
  .fri__grid > .fri-b--luft.fri-b--h { height: min(calc(var(--h, 0) * 1rem), 6rem); }
}

/* text: a readable measure; centred when chosen */
.fri-al--center { text-align: center; }
.fri-b--overskrift { overflow-wrap: break-word; text-wrap: balance; }
.fri-b--tekst > p { max-width: var(--fri-measure, 68ch); overflow-wrap: break-word; }
.fri-b--tekst > p + p { margin-top: var(--fri-para, 1rem); }
.fri-b--tekst.fri-al--center > p { margin-inline: auto; }

/* pictures and films: the chosen format reserves the space before the file loads */
.fri-b--bilde img { display: block; width: 100%; height: auto; border-radius: var(--fri-media-radius, 0); }
.fri-r--1x1 img { aspect-ratio: 1 / 1; object-fit: cover; }
.fri-r--4x5 img { aspect-ratio: 4 / 5; object-fit: cover; }
.fri-r--3x2 img { aspect-ratio: 3 / 2; object-fit: cover; }
.fri-r--16x9 img { aspect-ratio: 16 / 9; object-fit: cover; }
/* the picture's corners chosen in the block («Hjørner»): square, or rounded whatever the site's own shape is */
.fri-b--bilde.fri-shape--rett img { border-radius: 0; }
.fri-b--bilde.fri-shape--rund img { border-radius: var(--fri-round, 1rem); }
/* the picture's crop with a fixed «Format» (fri-crop: --fx/--fy = the point that stays in view, --zoom = how close, whole per cent) and its
   opacity (fri-op: --op); the frame clips the enlarged picture, with the picture's own corners */
.fri-b--bilde.fri-crop { overflow: hidden; border-radius: var(--fri-media-radius, 0); }
.fri-b--bilde.fri-crop.fri-shape--rett { border-radius: 0; }
.fri-b--bilde.fri-crop.fri-shape--rund { border-radius: var(--fri-round, 1rem); }
.fri-b--bilde.fri-crop img { object-position: calc(var(--fx, 50) * 1%) calc(var(--fy, 50) * 1%); transform: scale(calc(var(--zoom, 100) / 100)); transform-origin: calc(var(--fx, 50) * 1%) calc(var(--fy, 50) * 1%); }
.fri-b--bilde.fri-op img { opacity: calc(var(--op, 100) / 100); }
.fri-b--film video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--fri-deep, transparent); border-radius: var(--fri-media-radius, 0); }

.fri-b--knapp { display: flex; flex-wrap: wrap; }
.fri-b--sitat { min-width: 0; }

/* the spacer */
.fri-luft--s { height: var(--fri-luft-s, 1rem); }
.fri-luft--m { height: var(--fri-luft-m, 3rem); }
.fri-luft--l { height: var(--fri-luft-l, 6rem); }

/* an empty block in the editor's preview: room to click, nothing drawn (the admin draws its own «tom blokk») */
.fri-b--tom { min-height: var(--fri-tom, 4rem); }
