/*
 * EDGE content pages
 * Small, framework-independent styles for articles, resources and calculators.
 * Load after the site's existing stylesheet.
 */

:root {
    color-scheme: light;
    --edge-ink: #17324d;
    --edge-ink-deep: #10283d;
    --edge-blue: #2563eb;
    --edge-blue-dark: #1d4ed8;
    --edge-blue-pale: #eef4f8;
    --edge-yellow: #facc15;
    --edge-paper: #f7f9fb;
    --edge-surface: #ffffff;
    --edge-line: #d6e0e8;
    --edge-muted: #526579;
    --edge-copy: #263b4f;
    --edge-success-bg: #edf7f1;
    --edge-success-line: #a9d3b9;
    --edge-notice-bg: #fff8df;
    --edge-notice-line: #e6c653;
    --edge-danger-bg: #fff1ee;
    --edge-danger-line: #e2a79a;
    --edge-radius: 0.75rem;
    --edge-shadow: 0 0.35rem 1.2rem rgb(23 50 77 / 8%);
    --edge-content-width: 72rem;
    --edge-reading-width: 46rem;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5.5rem;
}

body {
    margin: 0;
    background: var(--edge-paper);
    color: var(--edge-copy);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1rem;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
}

img,
video,
iframe {
    max-width: 100%;
}

img {
    height: auto;
}

a {
    color: var(--edge-blue-dark);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--edge-ink-deep);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--edge-blue);
    outline-offset: 3px;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
input[type="submit"],
input[type="button"] {
    cursor: pointer;
}

::selection {
    background: #dceaff;
    color: var(--edge-ink-deep);
}

.container {
    width: min(var(--edge-content-width), calc(100% - 2.5rem));
    margin-inline: auto;
}

header {
    position: relative;
    z-index: 2;
    background: var(--edge-surface);
    color: var(--edge-ink);
    border-bottom: 1px solid var(--edge-line);
}

body > header > .container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem 2rem;
    padding-block: 0.75rem;
}

body > header > .container > a img {
    display: block;
    height: auto;
}

.result:empty {
    display: none;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -5rem;
    z-index: 10;
    padding: 0.75rem;
    background: white;
}

.skip-link:focus {
    top: 0.5rem;
}

footer nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

header nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    min-height: 4.25rem;
}

header nav a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    color: var(--edge-ink);
    font-weight: 650;
    text-decoration: none;
}

header nav a:hover,
header nav a[aria-current="page"] {
    color: var(--edge-blue-dark);
}

header nav img {
    display: block;
    width: auto;
    max-height: 2.5rem;
}

main {
    min-height: 55vh;
    padding-block: clamp(2rem, 5vw, 4.5rem);
}

main > .container > :first-child {
    margin-top: 0;
}

article,
.article-body {
    width: min(100%, var(--edge-reading-width));
    margin-inline: auto;
}

article > header,
.article-body > header {
    margin-bottom: 2rem;
    padding: 0 0 1.5rem;
    background: transparent;
    border: 0;
    border-bottom: 2px solid var(--edge-line);
}

h1,
h2,
h3,
h4 {
    color: var(--edge-ink);
    font-weight: 750;
    line-height: 1.2;
    text-wrap: balance;
}

h1 {
    margin: 0 0 1rem;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: -0.035em;
}

h2 {
    margin: 2.6rem 0 0.9rem;
    font-size: clamp(1.45rem, 3vw, 2rem);
    letter-spacing: -0.02em;
}

h3 {
    margin: 1.8rem 0 0.65rem;
    font-size: clamp(1.15rem, 2.5vw, 1.4rem);
}

h4 {
    margin: 1.4rem 0 0.5rem;
    font-size: 1.05rem;
}

p {
    margin: 0 0 1.15rem;
}

.article-body {
    color: var(--edge-copy);
    font-size: 1.0625rem;
    line-height: 1.8;
}

.article-body > p:first-of-type {
    color: var(--edge-muted);
    font-size: 1.15rem;
}

.article-body h2,
.article-body h3,
.article-body h4 {
    scroll-margin-top: 5.5rem;
}

.article-body ul,
.article-body ol {
    margin: 0 0 1.5rem;
    padding-left: 1.5rem;
}

.article-body li + li {
    margin-top: 0.45rem;
}

.article-body blockquote {
    margin: 1.75rem 0;
    padding: 1rem 1.25rem;
    color: var(--edge-ink);
    background: var(--edge-blue-pale);
    border-left: 4px solid var(--edge-blue);
    border-radius: 0 var(--edge-radius) var(--edge-radius) 0;
}

.article-body blockquote > :last-child {
    margin-bottom: 0;
}

.article-body img,
.article-body figure {
    margin-block: 1.75rem;
}

.article-body figure img {
    display: block;
    width: 100%;
    border-radius: var(--edge-radius);
}

.article-body figcaption {
    margin-top: 0.5rem;
    color: var(--edge-muted);
    font-size: 0.9rem;
}

.article-body table {
    display: block;
    width: 100%;
    margin: 1.5rem 0;
    overflow-x: auto;
    border-collapse: collapse;
    border: 1px solid var(--edge-line);
    background: var(--edge-surface);
}

.article-body th,
.article-body td {
    min-width: 8rem;
    padding: 0.7rem 0.85rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--edge-line);
}

.article-body th {
    color: var(--edge-ink);
    background: var(--edge-blue-pale);
    font-weight: 700;
}

.article-body code,
.article-body pre {
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.article-body code {
    padding: 0.1em 0.35em;
    background: #eaf0f5;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

.article-body pre {
    max-width: 100%;
    padding: 1rem;
    overflow: auto;
    color: #f2f6fa;
    background: var(--edge-ink-deep);
    border-radius: var(--edge-radius);
    font-size: 0.9rem;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 1.15rem;
    align-items: stretch;
}

.card {
    min-width: 0;
    padding: clamp(1.15rem, 3vw, 1.65rem);
    background: var(--edge-surface);
    border: 1px solid var(--edge-line);
    border-top: 3px solid var(--edge-blue);
    border-radius: var(--edge-radius);
    box-shadow: var(--edge-shadow);
}

.card > :first-child {
    margin-top: 0;
}

.card > :last-child {
    margin-bottom: 0;
}

.card h2,
.card h3 {
    margin-top: 0;
}

.calculator {
    width: min(100%, 52rem);
    margin: 1.5rem auto;
    padding: clamp(1.15rem, 4vw, 2rem);
    background: var(--edge-surface);
    border: 1px solid var(--edge-line);
    border-radius: calc(var(--edge-radius) + 0.2rem);
    box-shadow: var(--edge-shadow);
}

.calculator > :first-child {
    margin-top: 0;
}

.calculator > :last-child {
    margin-bottom: 0;
}

.calculator fieldset {
    min-width: 0;
    margin: 0 0 1.25rem;
    padding: 0;
    border: 0;
}

.calculator legend {
    margin-bottom: 0.65rem;
    color: var(--edge-ink);
    font-weight: 700;
}

.field {
    display: grid;
    gap: 0.4rem;
    min-width: 0;
    margin-bottom: 1rem;
}

.field label,
.field > label,
.field .field-label {
    color: var(--edge-ink);
    font-size: 0.96rem;
    font-weight: 700;
}

.field input,
.field select,
.field textarea,
.calculator input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
.calculator select,
.calculator textarea {
    display: block;
    width: 100%;
    min-height: 2.9rem;
    padding: 0.65rem 0.75rem;
    color: var(--edge-copy);
    background: #fff;
    border: 1px solid #9aabba;
    border-radius: 0.45rem;
}

.field textarea,
.calculator textarea {
    min-height: 7rem;
    resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder,
.calculator input::placeholder {
    color: #697d90;
    opacity: 1;
}

.field input:disabled,
.field select:disabled,
.calculator input:disabled,
.calculator select:disabled {
    cursor: not-allowed;
    background: #edf1f4;
    opacity: 0.75;
}

.field small,
.field .help,
.calculator .help {
    color: var(--edge-muted);
    font-size: 0.875rem;
    line-height: 1.45;
}

.unit-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-block: 0.5rem 1rem;
}

.unit-picker label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.75rem;
    padding: 0.45rem 0.75rem;
    color: var(--edge-ink);
    background: var(--edge-surface);
    border: 1px solid #9aabba;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 650;
}

.unit-picker input {
    accent-color: var(--edge-blue);
}

.unit-picker label:has(input:checked) {
    background: var(--edge-blue-pale);
    border-color: var(--edge-blue);
}

.calculator button,
.calculator input[type="submit"],
.calculator input[type="button"],
.calculator .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.9rem;
    padding: 0.65rem 1.1rem;
    color: #fff;
    background: var(--edge-blue);
    border: 1px solid var(--edge-blue);
    border-radius: 0.5rem;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
}

.calculator button:hover,
.calculator input[type="submit"]:hover,
.calculator input[type="button"]:hover,
.calculator .button:hover {
    background: var(--edge-blue-dark);
    border-color: var(--edge-blue-dark);
}

.result {
    margin-top: 1.25rem;
    padding: 1rem 1.15rem;
    color: var(--edge-ink);
    background: var(--edge-blue-pale);
    border: 1px solid #bdd1e1;
    border-left: 4px solid var(--edge-blue);
    border-radius: 0.55rem;
}

.result > :last-child {
    margin-bottom: 0;
}

.result strong,
.result output {
    font-size: 1.15em;
    font-weight: 750;
}

.notice {
    margin-block: 1.25rem;
    padding: 1rem 1.15rem;
    color: var(--edge-ink);
    background: var(--edge-notice-bg);
    border: 1px solid var(--edge-notice-line);
    border-left-width: 4px;
    border-radius: 0.55rem;
}

.notice > :first-child {
    margin-top: 0;
}

.notice > :last-child {
    margin-bottom: 0;
}

.notice[role="alert"],
.notice.is-error {
    background: var(--edge-danger-bg);
    border-color: var(--edge-danger-line);
}

.notice.is-success {
    background: var(--edge-success-bg);
    border-color: var(--edge-success-line);
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
    gap: 1.25rem;
}

.video {
    min-width: 0;
    overflow: hidden;
    background: var(--edge-surface);
    border: 1px solid var(--edge-line);
    border-radius: var(--edge-radius);
    box-shadow: var(--edge-shadow);
}

.video iframe,
.video video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border: 0;
    background: var(--edge-ink-deep);
}

.video > :not(iframe):not(video) {
    margin-inline: 1rem;
}

.video h2,
.video h3 {
    margin-top: 1rem;
}

.video > :last-child {
    margin-bottom: 1rem;
}

footer {
    padding-block: 2rem;
    color: #e8f0f6;
    background: var(--edge-ink);
}

footer a {
    color: #fff;
}

footer a:hover {
    color: var(--edge-yellow);
}

footer .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
}

@media (max-width: 767px) {
    html {
        scroll-padding-top: 1rem;
    }

    .container {
        width: min(100% - 1.5rem, var(--edge-content-width));
    }

    header nav {
        justify-content: flex-start;
        gap: 0.25rem 0.65rem;
        padding-block: 0.5rem;
    }

    header nav a {
        min-height: 2.5rem;
        font-size: 0.94rem;
    }

    main {
        padding-block: 1.75rem 2.5rem;
    }

    article > header,
    .article-body > header {
        margin-bottom: 1.4rem;
    }

    .article-body {
        font-size: 1rem;
        line-height: 1.72;
    }

    .calculator {
        margin-block: 1rem;
    }

    .calculator button,
    .calculator input[type="submit"],
    .calculator input[type="button"],
    .calculator .button {
        width: 100%;
    }

    footer .container {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 380px) {
    .container {
        width: calc(100% - 1.25rem);
    }

    .unit-picker {
        align-items: stretch;
        flex-direction: column;
    }

    .unit-picker label {
        width: 100%;
        border-radius: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
