/* Cordials Info — site styles. No framework, no build step. */

:root {
    --ink: #1c1d1a;
    --ink-soft: #55574f;
    --paper: #fbfaf6;
    --surface: #ffffff;
    --line: #e3e1d8;
    --line-strong: #1c1d1a;
    --accent: #4d7c0f;
    --accent-ink: #ffffff;
    --accent-soft: #ecf5d9;
    --focus: #65a30d;

    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

    --radius: 10px;
    --radius-sm: 6px;
    --header-h: 64px;
    --wrap: 72rem;
    --gutter: clamp(1rem, 4vw, 2rem);

    /* Fallback category colour; overridden inline per flavour/category. */
    --cat: #e5e7eb;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 4rem);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 1rem/1.6 var(--font-body);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--ink); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

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

.skip-link {
    position: absolute;
    left: 1rem; top: -3rem;
    z-index: 100;
    padding: 0.5rem 1rem;
    background: var(--ink);
    color: var(--paper);
    border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; }

.muted { color: var(--ink-soft); }

/* ---------- Header & navigation ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--line);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-h);
    gap: 1rem;
}

.brand {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -0.01em;
}
.brand:hover { color: var(--accent); }

.nav-toggle {
    display: none;
    width: 2.75rem; height: 2.75rem;
    padding: 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}
.nav-toggle svg { display: block; width: 100%; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }

.site-nav__list,
.dropdown__menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-nav__list { display: flex; gap: 0.5rem; }

.dropdown { position: relative; }

.dropdown__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.dropdown__toggle::after {
    content: "";
    width: 0.45em; height: 0.45em;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: translateY(-25%) rotate(45deg);
    transition: transform 0.15s;
}
.dropdown__toggle:hover,
.dropdown__toggle[aria-expanded="true"] { background: var(--accent-soft); }

/* The section the current page belongs to. */
.dropdown__toggle.is-active {
    color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
}
.dropdown__toggle[aria-expanded="true"]::after { transform: translateY(15%) rotate(-135deg); }

.dropdown__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    min-width: 15rem;
    padding: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px -12px rgb(0 0 0 / 0.25);
    display: none;
}
.dropdown__toggle[aria-expanded="true"] + .dropdown__menu { display: block; }

.dropdown__menu a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--ink);
    text-decoration: none;
}
.dropdown__menu a:hover { background: var(--paper); }
.dropdown__menu a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
.dropdown__menu a[aria-current="true"] { font-weight: 600; }

.has-swatch::before {
    content: "";
    width: 0.8rem; height: 0.8rem;
    border-radius: 50%;
    background: var(--cat);
    border: 1px solid rgb(0 0 0 / 0.15);
}

@media (max-width: 47.99rem) {
    .nav-toggle { display: block; }

    .site-nav {
        display: none;
        position: absolute;
        inset: var(--header-h) 0 auto 0;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        box-shadow: 0 16px 24px -16px rgb(0 0 0 / 0.2);
        padding: 0.5rem var(--gutter) 1rem;
        max-height: calc(100vh - var(--header-h));
        overflow-y: auto;
    }
    .site-nav.is-open { display: block; }

    .site-nav__list { flex-direction: column; gap: 0; }

    .dropdown__toggle { width: 100%; justify-content: space-between; padding: 0.85rem 0.25rem; border-radius: 0; }
    .dropdown__toggle:hover, .dropdown__toggle[aria-expanded="true"] { background: none; }
    .dropdown__toggle.is-active { box-shadow: inset 3px 0 0 var(--accent); padding-left: 0.75rem; }

    .dropdown__menu {
        position: static;
        box-shadow: none;
        border: 0;
        padding: 0 0 0.5rem;
        min-width: 0;
    }
}

/* ---------- Layout ---------- */

.site-main {
    flex: 1;
    outline: none;
    padding-block: clamp(1.5rem, 4vw, 3rem);
}

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 0.9rem;
}
.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding-block: 1.5rem;
}
.site-footer__links { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; }
.site-footer a { color: inherit; }

/* ---------- Typography ---------- */

.page__title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 1.4rem + 2.5vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 0.75rem;
}

.page__intro {
    font-size: 1.125rem;
    color: var(--ink-soft);
    max-width: 44rem;
    margin: 0 0 1.75rem;
}

.prose { max-width: 44rem; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose h2, .prose h3, .prose h4, .prose h5 {
    font-family: var(--font-display);
    line-height: 1.2;
    margin: 1.75em 0 0.5em;
}
.prose h2 { font-size: 1.6rem; }
.prose h3 { font-size: 1.35rem; }
.prose h4, .prose h5 { font-size: 1.15rem; }
.prose a { word-break: break-word; }
.prose blockquote {
    margin: 1.5em 0;
    padding-left: 1rem;
    border-left: 3px solid var(--accent);
    color: var(--ink-soft);
}

.calculator + .prose,
.flavour-toolbar + .prose { margin-top: 2.5rem; }

/* ---------- Form controls ---------- */

.input-unit {
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.input-unit:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.input-unit input {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 0.8rem;
    border: 0;
    background: none;
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: inherit;
    outline: none;
}
.input-unit span {
    display: grid;
    place-items: center;
    padding-inline: 0.8rem;
    background: var(--paper);
    border-left: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.button {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    border: 1px solid var(--ink);
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--paper);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.button:hover { background: var(--accent); border-color: var(--accent); }

/* ---------- Calculators ---------- */

.calculator {
    margin: 0 0 1rem;
    padding: clamp(1rem, 3vw, 1.75rem);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: 0 1px 0 rgb(0 0 0 / 0.03), 0 18px 40px -28px rgb(0 0 0 / 0.25);
}

.calculator__input {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--ink);
    color: var(--paper);
    border-radius: var(--radius);
}
.calculator__input label { font-weight: 700; font-size: 1.1rem; }
.calculator__input .input-unit { color: var(--ink); border-color: transparent; font-size: 1.25rem; }

.calculator__results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
    gap: 0.75rem;
}
@media (min-width: 60rem) {
    .calculator__results { grid-template-columns: repeat(var(--cols), 1fr); }
}

.result-card {
    padding: 1rem 1.1rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.result-card__title {
    margin: 0 0 0.5rem;
    font-family: var(--font-display);
    font-size: 1.2rem;
}
.result-card dl { margin: 0; }
.result-card__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.4rem 0;
    border-top: 1px dashed var(--line);
}
.result-card dt { color: var(--ink-soft); }
.result-card dd { margin: 0; }
.result-card output {
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.calculator__reference { margin-top: 1rem; }
.calculator__reference summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink-soft);
    padding: 0.25rem 0;
}
.calculator__reference summary:hover { color: var(--ink); }

.table-scroll { overflow-x: auto; margin-top: 0.5rem; }
.table-scroll table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}
.table-scroll th,
.table-scroll td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}
.table-scroll th:first-child { text-align: left; }
.table-scroll thead th { font-family: var(--font-display); border-bottom-color: var(--ink); }
.table-scroll tbody th { font-weight: 400; color: var(--ink-soft); }

/* PPM */

.ppm-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 0.75rem;
}
.ppm-step {
    margin: 0;
    padding: 1rem 1.1rem 0.5rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.ppm-step legend {
    padding: 0 0.4rem;
    margin-left: -0.4rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
}
.field { margin-bottom: 0.9rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field small { display: block; color: var(--ink-soft); margin-top: 0.25rem; font-size: 0.85rem; }

.ppm-result {
    --level: hsl(66 75% 42%);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.6rem;
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    background: color-mix(in srgb, var(--level) 14%, white);
    border: 2px solid var(--level);
    border-radius: var(--radius);
    transition: background 0.2s, border-color 0.2s;
}
.ppm-result__label { flex-basis: 100%; font-weight: 600; color: var(--ink-soft); }
.ppm-result__value { font-size: 2.75rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ppm-result__unit { font-weight: 600; }
/* Dark text on the scale colour: readable at every point from green to red. */
.ppm-result__verdict {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--level) 45%, white);
    border: 1px solid var(--level);
    color: var(--ink);
    font-weight: 700;
}

.ppm-scale { margin-top: 0.85rem; }
.ppm-scale__bar {
    position: relative;
    height: 0.6rem;
    border-radius: 999px;
    /* 0, 100 and 200ppm on a 0–250 bar. */
    background: linear-gradient(to right, hsl(130 75% 42%) 0%, hsl(45 75% 42%) 40%, hsl(0 75% 42%) 80%, hsl(0 75% 42%) 100%);
}
.ppm-scale__marker {
    position: absolute;
    top: 50%;
    left: var(--pos);
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--ink);
    transform: translate(-50%, -50%);
    transition: left 0.2s;
}
.ppm-scale__bands {
    display: flex;
    margin: 0.4rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8rem;
    color: var(--ink-soft);
}
.ppm-scale__bands li {
    flex: var(--w) 1 0;
    padding: 0.2rem 0.4rem 0 0;
    border-left: 1px solid var(--line);
    padding-left: 0.4rem;
}
.ppm-scale__bands li:first-child { border-left: 0; padding-left: 0; }

/* ---------- Flavours ---------- */

.flavour-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    margin: 1.5rem 0;
}
.flavour-toolbar__note { margin: 0; flex: 1 1 20rem; color: var(--ink-soft); }

.search {
    display: flex;
    flex: 0 1 26rem;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0.25rem;
}
.search:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.search input {
    flex: 1;
    min-width: 0;
    padding: 0.55rem 0.9rem;
    border: 0;
    background: none;
    font: inherit;
    outline: none;
}
.search button {
    padding: 0.55rem 1.1rem;
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.search button:hover { background: var(--accent); }

.letters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 1.5rem;
}
.letters a {
    display: grid;
    place-items: center;
    min-width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}
.letters a:hover { border-color: var(--ink); background: var(--ink); color: var(--paper); }

.letter-group { margin-bottom: 1rem; }
.letter-group__heading {
    position: sticky;
    top: var(--header-h);
    z-index: 10;
    margin: 0 0 0.75rem;
    padding: 0.35rem 1rem;
    background: var(--ink);
    color: var(--paper);
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 1.5rem;
}

.flavour-card {
    margin-bottom: 0.75rem;
    background: color-mix(in srgb, var(--cat) 22%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--cat) 60%, var(--ink) 15%);
    border-radius: var(--radius);
    overflow: hidden;
}
.flavour-card__title {
    margin: 0;
    padding: 0.85rem 1.1rem;
    background: var(--cat);
    font-family: var(--font-display);
    font-size: 1.35rem;
    line-height: 1.2;
}
.flavour-card__title a { color: var(--ink); text-decoration: none; }
.flavour-card__title a:hover { text-decoration: underline; }
.flavour-card__body { padding: 0.5rem 1.1rem 1rem; }
.flavour-card__lede { margin: 0.5rem 0 0.25rem; }

.flavour-card--single .flavour-card__title { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.5rem); padding: 1.1rem 1.25rem; }
.flavour-card--single .flavour-card__body { padding: 0.75rem 1.25rem 1.25rem; }

.pairing-group { padding-top: 0.75rem; }
.pairing-group__title {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
}

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }

.tag {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    background: var(--cat);
    border: 1px solid rgb(0 0 0 / 0.12);
    border-radius: 999px;
    color: var(--ink);
    font-size: 0.925rem;
    text-decoration: none;
    transition: transform 0.1s, box-shadow 0.1s;
}
.tag:hover {
    color: var(--ink);
    background: color-mix(in srgb, var(--cat), black 8%);
    box-shadow: 0 2px 0 rgb(0 0 0 / 0.15);
    transform: translateY(-1px);
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    font-size: 0.9rem;
    color: var(--ink-soft);
}
.breadcrumbs li + li::before { content: "/"; margin-right: 0.5rem; }
.breadcrumbs a { color: inherit; }
.breadcrumbs a[aria-current="page"] { text-decoration: none; font-weight: 600; color: var(--ink); }

.results-heading {
    margin: 0 0 1rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
}

@media (forced-colors: active) {
    .tag, .letters a, .result-card, .flavour-card, .calculator { border: 1px solid CanvasText; }
    .ppm-result__verdict { border: 1px solid CanvasText; }
}

@media print {
    .site-header, .site-footer, .flavour-toolbar, .letters, .skip-link { display: none; }
    .letter-group__heading { position: static; }
    body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
}
