/*
 * Mink Campers – base styles, ported from the original Next.js site
 * (styles/base.scss, _theme.scss, variables.scss, mixins/*). Fonts, colours and text
 * styles also live in app/elemental/design-system.json for the builder.
 *
 * Each Mink builder component has its own file in css/components/ (loaded by
 * PageController). Shared helpers for them are here:
 *   .mk-container  – the original container() mixin
 *   .mk-segment    – segment() vertical padding
 *   .mk-grid       – 12 column grid() mixin
 *   .mk-copy       – render-copy() (rich text)
 *   (headings and every other text style: app/elemental/design-system.json)
 */

:root {
    font-size: 62.5%;
    --scrollbar-width: 0px;

    /* variables.scss */
    --page-width: 129rem;
    --grid-gutter: 3rem;
    --grid-column-count: 12;
    --container-gutter: clamp(2rem, calc(2rem + 5 * ((100vw - 48rem) / 80)), 7rem);
    --container-gutter-offset: calc(var(--container-gutter) * -1);
    --segment-padding: clamp(5rem, calc(5rem + 5 * ((100vw - 48rem) / 80)), 10rem);
    --font-family: 'Montserrat', sans-serif;
    --font-family-headline: 'Monument Extended', sans-serif;
    --font-size: clamp(1.4rem, calc(1.4rem + 0.2 * ((100vw - 48rem) / 80)), 1.6rem);
    --line-height: 1.875;
    --font-size-h1: clamp(4.8rem, calc(4.8rem + 3.5 * ((100vw - 48rem) / 80)), 8.3rem);
    --font-size-h2: clamp(4.2rem, calc(4.2rem + 2.8 * ((100vw - 48rem) / 80)), 7rem);
    --font-size-h3: clamp(3rem, calc(3rem + 2 * ((100vw - 48rem) / 80)), 5rem);
    --font-size-h4: clamp(1.44rem, calc(1.44rem + 0.96 * ((100vw - 48rem) / 80)), 2.4rem);
    --font-size-h5: clamp(1.6rem, calc(1.6rem + 0.2 * ((100vw - 48rem) / 80)), 1.8rem);
    --font-size-h6: clamp(1.6rem, calc(1.6rem + 0.1 * ((100vw - 48rem) / 80)), 1.7rem);
    --transition-duration-enter: 200ms;
    --transition-duration-leave: 500ms;

    /* _theme.scss: the original's colour names, read from the design system's tokens
       (app/elemental/design-system.json) – its color.dark palette is the winter mode. */
    --color-font: var(--color-text);
    --color-font-light: var(--color-text-light);
    --color-font-dark: var(--color-black);
    --color-background: var(--color-surface);
    --color-background-nav: var(--color-nav);
    --color-background-alt: var(--color-white);
    --color-background-form: var(--color-surface-alt);
    --color-background-toggle: var(--color-gray);
    --color-brand: var(--color-accent);
    --color-accent-primary: var(--color-accent);
    --color-accent-primary-darker: var(--color-accent-dark);
    --color-border: var(--color-primary);
    --color-placeholder: var(--color-gray);
    --color-winter: #251f15;
    --color-summer: #ebebe3;
    --color-font-alt: var(--color-contrast);
    --color-outlines: var(--color-outline);
    /* --color-link-decoration: the design system's token of the same name */
}

@media (min-aspect-ratio: 3/2) {
    :root { font-size: clamp(calc(62.5% * 0.8), calc((62.5% * 0.45) + 0.6vh), 62.5%); }
}

/* Winter mode: the design system's color.dark palette (.dark-mode on <html>, set by the switch). */

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

html, body {
    min-height: 100vh;
    width: 100%;
    background: var(--color-background);
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
@media (min-width: 720px) { html { overflow-y: scroll; } }

body {
    position: relative;
    margin: 0;
    font-family: var(--font-family);
    font-size: var(--font-size);
    line-height: var(--line-height);
    color: var(--color-font);
    text-size-adjust: 100%;
    transition: background-color var(--transition-duration-leave), color var(--transition-duration-leave);
}

img { display: block; max-width: 100%; height: auto; }

::selection { color: #fff; background: var(--color-accent-primary); }

/* ---- Shared helpers (mixins) ------------------------------------------- */

.mk-container {
    padding-left: var(--container-gutter);
    padding-right: var(--container-gutter);
    margin: 0 auto;
    max-width: var(--page-width);
    box-sizing: content-box;
}

/* The editable look (docs/mink-builder.md): --mk-* variables a component's root gets
   from its style settings ($MkVars); unset = the original value. */
.mk-segment { padding-top: var(--mk-space-top, var(--segment-padding)); padding-bottom: var(--mk-space-bottom, var(--segment-padding)); }
.mk-block[style*="--mk-color:"] { color: var(--mk-color); }

.mk-grid {
    --column-count: var(--grid-column-count);
    display: grid;
    row-gap: var(--grid-gutter);
    column-gap: min(var(--grid-gutter), calc(100% / (var(--column-count) - 1)));
    grid-template-columns: repeat(var(--column-count), minmax(0, 1fr));
}


/* render-copy() – used for every rich text field. The builder's richtext atom renders
   <div class="el-richtext …">; inside .mk-copy its own styles are neutralised. */
.mk-copy { color: inherit; font-size: var(--font-size); line-height: var(--line-height); }
/* The rules below also beat the rich text block's own (.el-richtext p …). A text style
   chosen on the block reaches the paragraphs and lists. */
.mk-copy .el-richtext { color: inherit; }
.mk-copy .el-richtext :is(p, li, blockquote) { font-size: inherit; line-height: inherit; }
:is(.mk-copy, .mk-copy .el-richtext) h1, :is(.mk-copy, .mk-copy .el-richtext) h2, :is(.mk-copy, .mk-copy .el-richtext) h3, :is(.mk-copy, .mk-copy .el-richtext) h4, :is(.mk-copy, .mk-copy .el-richtext) h5, :is(.mk-copy, .mk-copy .el-richtext) h6 {
    margin: 0 0 0.8333em; padding: 0; font-family: var(--font-family); column-span: all; color: inherit;
}
:is(.mk-copy, .mk-copy .el-richtext) h1 { font-size: var(--font-size-h1); line-height: 1.2; font-weight: 700; margin-bottom: 0.625em; }
:is(.mk-copy, .mk-copy .el-richtext) h2 { font-size: var(--font-size-h2); line-height: 1.15; font-weight: 700; }
:is(.mk-copy, .mk-copy .el-richtext) h3 { font-size: var(--font-size-h3); line-height: 1.25; font-weight: 700; }
:is(.mk-copy, .mk-copy .el-richtext) h4 { font-size: var(--font-size-h4); line-height: 1.2; font-weight: 500; }
:is(.mk-copy, .mk-copy .el-richtext) p {
    margin: 0 0 1.875em; padding: 0;
    font-size: var(--font-size); font-weight: 400; line-height: var(--line-height); max-width: 80ch;
}
:is(.mk-copy, .mk-copy .el-richtext) p + p { margin-top: -0.875em; }
:is(.mk-copy, .mk-copy .el-richtext) p:last-child { margin-bottom: 0; }
:is(.mk-copy, .mk-copy .el-richtext) p + h1, :is(.mk-copy, .mk-copy .el-richtext) p + h2, :is(.mk-copy, .mk-copy .el-richtext) p + h3 { margin-top: 1.666em; }
:is(.mk-copy, .mk-copy .el-richtext) p + h4 { margin-top: 2.333em; }
:is(.mk-copy, .mk-copy .el-richtext) strong { font-weight: 600; }
:is(.mk-copy, .mk-copy .el-richtext) ul, :is(.mk-copy, .mk-copy .el-richtext) ol { list-style: none; margin: 0 0 1.25em; padding: 0; }
:is(.mk-copy, .mk-copy .el-richtext) ol { counter-reset: ordered-counter; }
:is(.mk-copy, .mk-copy .el-richtext) li {
    position: relative; margin: 0 0 1em; padding-left: 3.6rem;
    font-size: var(--font-size); font-weight: 400; line-height: var(--line-height); max-width: 80ch;
}
:is(.mk-copy, .mk-copy .el-richtext) ul li::before {
    content: ''; position: absolute; top: 1.5ex; left: 0; width: 1.2rem; height: 3px;
    border: 0.1rem solid var(--color-font); background: var(--color-background-form);
}
:is(.mk-copy, .mk-copy .el-richtext) ol li { counter-increment: ordered-counter; }
:is(.mk-copy, .mk-copy .el-richtext) ol li::before {
    content: counter(ordered-counter) '. '; position: absolute; left: 0;
    letter-spacing: 0.1em; font-family: var(--font-family); transform: translateY(0.2em);
}
:is(.mk-copy, .mk-copy .el-richtext) blockquote {
    position: relative; margin: 2em 0; padding: 0;
    font-size: var(--font-size); font-family: var(--font-family); font-weight: 400; line-height: 1.45833333;
}
:is(.mk-copy, .mk-copy .el-richtext) blockquote::before {
    content: '\201C'; position: absolute; top: -0.2em; left: -0.6em; font-size: 3em; line-height: 1; color: var(--color-font);
}
/* TEXT LINKS (@include anchor) – the one rule for every text link on the site: links in
   rich text everywhere (Mink's .mk-copy and the builder's rich text block .el-richtext)
   and the builder's own text links with underline (link component, .el-link--underline).
   Change the link look here and it changes everywhere. */
:is(.el-richtext, .mk-copy) a:not([class]), .el-link.el-link--underline, .mk-link {
    color: var(--color-font);
    text-decoration: underline;
    text-decoration-color: var(--color-link-decoration);
    text-decoration-thickness: 0.2rem;
    transition: text-decoration var(--transition-duration-leave);
    cursor: pointer;
}
:is(:is(.el-richtext, .mk-copy) a:not([class]), .el-link.el-link--underline, .mk-link):is(:hover, :focus-visible) {
    text-decoration-color: var(--color-font);
    transition-duration: var(--transition-duration-enter);
}

/* ---- Builder wrappers ---------------------------------------------------
   Mink sections are a section > layout > column holding one Mink component, which
   does its own layout (container, segment). The wrappers add nothing. */
.el-section:has(.mk-block) { padding: 0 !important; background: transparent; color: inherit; }
.el-section:has(.mk-block) > .el-section__body,
.el-section:has(.mk-block) .el-inner,
.el-section:has(.mk-block) .el-inner__grid,
.el-section:has(.mk-block) .el-inner__col,
.el-section:has(.mk-block) .el-container { display: block; max-width: none; width: auto; padding: 0; margin: 0; gap: 0; }

/* Plain (non-builder) pages, e.g. the default policy pages */
.mk-plain-page { padding: var(--segment-padding) var(--container-gutter); max-width: var(--page-width); margin: 0 auto; box-sizing: content-box; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ==========================================================================
   Global layout (header/footer agent) – components/layout/Layout,
   components/button. Appended; owned by the layout/header/footer port.
   ========================================================================== */

/* The original resets fonts on every element (base.scss: * { font: inherit }) –
   buttons, inputs and selects use the page font. */
button, input, select, textarea { font: inherit; }

/* components/layout/Layout.module.scss: Page.ss wraps header, main and footer. */
.mk-layout {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}
.mk-layout--no-overflow { overflow: visible; }
.mk-layout__main { position: relative; flex: 1 1 auto; }
.mk-layout > .eb-region { display: contents; }
.mk-layout__bg {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}
.mk-layout__bg svg {
    position: absolute;
    max-width: none;
    color: var(--color-outlines);
    pointer-events: none;
}
.mk-layout__bg .mk-layout__background { top: 20vh; left: 30%; }
.mk-layout__bg .mk-layout__background-secondary { top: 280rem; left: 40%; transform: rotate(180deg); }
.mk-layout__bg .mk-layout__background-ternary { top: 520rem; left: -20%; }
/* pages/404.tsx: no pattern */
body.errorpage .mk-layout__bg { display: none; }

/* components/button/Button.module.scss – .mk-button (+ --small, --large, --text) */
.mk-button {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    position: relative;
    vertical-align: baseline;
    margin: 0;
    padding: 1.6rem 2.3em;
    /* Type: the design system's text style (ts-button, ts-button-large, ts-button-dot). */
    text-decoration: none;
    color: var(--color-font);
    cursor: pointer;
    border: 0.1rem solid var(--color-font);
    border-radius: 0;
    background-color: var(--color-background-form);
    transition: background-color 0.2s ease;
    appearance: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.mk-button:focus { outline: none; }
.mk-button:hover { background: var(--color-accent-primary); }
.mk-button--small { padding: 0.7rem 1.8em; }
.mk-button--large { padding: 2.3rem 5rem 2.1rem; }
.mk-button[disabled], .mk-button.is-disabled { pointer-events: none; opacity: 0.5; }
.mk-button__content { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; height: 100%; }
.mk-button--text {
    min-height: 2.6rem;
    padding: 0;
    border: none;
    background: none;
}
.mk-button--text:hover { background: none; }
.mk-button--text::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 2.6rem;
    height: 2.6rem;
    background: var(--color-accent-primary);
    border-radius: 2.6rem;
    transition: width 350ms, box-shadow 550ms;
}
.mk-button--text:is(:hover, :focus-visible)::after { width: calc(100% + 0.5rem); }
.mk-button--text .mk-button__content { padding-left: 0.5rem; }

/* The builder's own buttons (Knap / link styled as a button) as Mink buttons
   (Button.module.scss): thin border, the original's padding, and – outlined in Mink black –
   the darker off-white fill; every button turns yellow on hover. The type is the design
   system's "button" style (Monument Extended, uppercase). */
.el-button { border-width: 0.1rem; transition: background-color 0.2s ease; }
.el-button--sm { padding: 0.7rem 1.8em; }
.el-button--md { padding: 1.6rem 2.3em; }
.el-button--lg { padding: 2.3rem 5rem 2.1rem; }
.el-button[style*="border-color: var(--color-primary)"]:not([style*="background"]) { background-color: var(--color-surface-alt); }
.el-button:not(.el-button--icon-only):is(:hover, :focus-visible) {
    background-color: var(--color-accent) !important;
    border-color: var(--color-primary) !important;
    color: var(--color-primary) !important;
}

/* Headings inside Mink components follow the text colour, so they turn light in winter
   (dark) mode. The builder's design-system CSS colours :where(h1…h6) with
   --color-heading, which is fixed; in dark mode the roles follow the theme too. */
.mk-block :is(h1, h2, h3, h4, h5, h6) { color: inherit; }


/* Text style page-title = h1 with the yellow dot after it (PageHero.module.scss __dot),
   wherever it is used. A section can set its colour (--ts-page-title-dot-color), fade it
   (--ts-page-title-dot-opacity) or hide it (--ts-page-title-dot: none). */
.ts-page-title::after {
    content: var(--ts-page-title-dot, '.');
    margin-left: 0.5rem;
    color: var(--ts-page-title-dot-color, var(--color-accent-primary));
    opacity: var(--ts-page-title-dot-opacity, 1);
}
.mk-block .el-richtext, .mk-block .el-heading, .mk-block .el-text { color: inherit; }
