/**
 * Recipe tools — serving scaler, tickable lists, step progress, cook mode.
 *
 * Every selector here targets markup that recipe-tools.js injects or classes it
 * adds, so nothing in this file applies until the script has run. That keeps a
 * no-JavaScript reader from seeing checkbox affordances that do nothing.
 *
 * Direction C: square corners, 2px black rules, orange as the single accent.
 */

/* ------------------------------------------------------------------ scaler */

.fmr-scaler {
    display: flex;
    align-items: center;
    gap: var(--fmr-space-3);
    flex-wrap: wrap;
    margin-bottom: var(--fmr-space-4);
    padding-bottom: var(--fmr-space-4);
    border-bottom: 2px solid var(--fmr-border-strong);
}

.fmr-scaler__label {
    font-size: var(--fmr-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--fmr-track-label);
    color: var(--fmr-ink-500);
    margin-right: auto;
}

.fmr-scaler__ctrl {
    display: flex;
    align-items: stretch;
    border: 2px solid var(--fmr-border-strong);
}

.fmr-scaler__ctrl button {
    width: 44px;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--fmr-ink-900);
    font-size: var(--fmr-text-lg);
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.fmr-scaler__ctrl button:hover {
    background: var(--fmr-surface-dark);
    color: var(--fmr-on-dark);
}

.fmr-scaler__ctrl output {
    display: grid;
    place-items: center;
    min-width: 52px;
    padding-inline: var(--fmr-space-2);
    border-inline: 2px solid var(--fmr-border-strong);
    font-family: var(--font-serif, Georgia, serif);
    font-size: var(--fmr-text-lg);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.fmr-scaler__reset {
    min-height: 44px;
    padding-inline: var(--fmr-space-3);
    border: 0;
    background: none;
    font-size: var(--fmr-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--fmr-track-label);
    color: var(--fmr-ink-500);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.fmr-scaler__reset:hover {
    color: var(--fmr-ink-900);
}

/* A scaled amount is no longer what the author wrote, so it is marked. */
.fmr-qty {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.fmr-qty.is-scaled {
    background: var(--fmr-brand-50);
    box-shadow: 0 1px 0 0 var(--fmr-brand-500);
    padding-inline: 2px;
}

/* -------------------------------------------------------- tickable lists */

.fmr-tickable li {
    position: relative;
    cursor: pointer;
    transition: opacity .18s ease, color .18s ease;
    -webkit-tap-highlight-color: transparent;
}

.fmr-tickable li:focus-visible {
    outline: 2px solid var(--fmr-brand-500);
    outline-offset: 3px;
}

.fmr-tickable li.is-done {
    opacity: .42;
}

/* Ingredients get a box; the marker sits in the space the list already uses. */
.fmr-ing.fmr-tickable li::before {
    content: "";
    position: absolute;
    left: -30px;
    top: .42em;
    width: 16px;
    height: 16px;
    /* recipe.css draws the plain bullet as a circle. Reusing that element as a
       checkbox meant it kept the 50% radius, so the one round thing on the page
       was sitting in a design where every corner is square. */
    border-radius: 0;
    border: 2px solid var(--fmr-border-strong);
    background: var(--fmr-surface);
    transition: background .15s ease;
}

.fmr-ing.fmr-tickable li.is-done::before {
    background: var(--fmr-surface-dark);
}

.fmr-ing.fmr-tickable li.is-done {
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

@media (max-width: 640px) {
    .fmr-ing.fmr-tickable li::before {
        left: -26px;
    }
}

/* Steps are already numbered, so the tick reads as a strike on the number. */
.fmr-steps.fmr-tickable li.is-done::marker {
    color: var(--fmr-brand-500);
}

/* ---------------------------------------------------------- step progress */

.fmr-progress {
    margin-top: var(--fmr-space-4);
    padding-top: var(--fmr-space-3);
    border-top: 2px solid var(--fmr-border-strong);
}

.fmr-progress__track {
    height: 6px;
    background: var(--fmr-surface-muted);
    border: 1px solid var(--fmr-border);
    overflow: hidden;
}

.fmr-progress__track span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--fmr-brand-500);
    transition: width .25s ease;
}

.fmr-progress.is-complete .fmr-progress__track span {
    background: var(--fmr-surface-dark);
}

.fmr-progress__text {
    margin: var(--fmr-space-2) 0 0;
    font-size: var(--fmr-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--fmr-track-label);
    color: var(--fmr-ink-500);
}

/* --------------------------------------------------------------- cook mode */

/* Cook mode is read at arm's length with wet hands: everything that is not the
   method gets out of the way, and what is left gets bigger. */
body.fmr-cooking .fmr-header,
body.fmr-cooking .fmr-rhero__media,
body.fmr-cooking .fmr-section--tint,
body.fmr-cooking .fmr-block,
body.fmr-cooking .fmr-reviews,
body.fmr-cooking .fmr-footer,
body.fmr-cooking .fmr-ad,
body.fmr-cooking .fmr-tags {
    display: none !important;
}

body.fmr-cooking .fmr-rcols {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--fmr-space-8);
}

body.fmr-cooking .fmr-steps li,
body.fmr-cooking .fmr-ing li {
    font-size: clamp(18px, 2.4vw, 23px);
    line-height: 1.55;
    padding-block: var(--fmr-space-2);
}

body.fmr-cooking .fmr-ingredients {
    position: static;
    border: 2px solid var(--fmr-border-strong);
    padding: var(--fmr-space-4);
}

body.fmr-cooking .fmr-rhero h1 {
    font-size: var(--fmr-text-2xl);
}

.fmr-cookbtn[aria-pressed="true"] {
    background: var(--fmr-surface-dark);
    color: var(--fmr-on-dark);
    border-color: var(--fmr-surface-dark);
}

@media (prefers-reduced-motion: reduce) {

    .fmr-progress__track span,
    .fmr-scaler__ctrl button,
    .fmr-tickable li {
        transition: none;
    }
}


/* ------------------------------------------------------ jump to recipe */

/* The sticky header would otherwise cover the heading the link lands on. */
#recipe {
    scroll-margin-top: 90px;
}

@media (prefers-reduced-motion: no-preference) {
    html:focus-within {
        scroll-behavior: smooth;
    }
}

/* ------------------------------------------------------------ share row */

.fmr-sharebar {
    margin-top: var(--fmr-space-8);
    padding-top: var(--fmr-space-4);
    border-top: 2px solid var(--fmr-border-strong);
}

.fmr-sharebar__title {
    margin: 0 0 var(--fmr-space-3);
    font-size: var(--fmr-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--fmr-track-label);
    color: var(--fmr-ink-500);
}

.fmr-sharebar__links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fmr-sharebar__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding-inline: 16px;
    border: 2px solid var(--fmr-border-strong);
    border-radius: 0;
    background: var(--fmr-surface);
    color: var(--fmr-ink-900);
    font: inherit;
    font-size: var(--fmr-text-sm);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.fmr-sharebar__link:hover,
.fmr-sharebar__link:focus-visible {
    background: var(--fmr-surface-dark);
    color: var(--fmr-on-dark);
}

/* ---------------------------------------------------------- email signup */

.fmr-signup {
    margin-top: var(--fmr-space-8);
    padding: clamp(20px, 4vw, 36px);
    background: var(--fmr-surface-dark);
    color: var(--fmr-on-dark);
}

.fmr-signup__title {
    margin: 0 0 var(--fmr-space-2);
    font-family: var(--font-serif, Georgia, serif);
    font-size: var(--fmr-text-xl);
    color: var(--fmr-on-dark);
}

.fmr-signup__text {
    margin: 0 0 var(--fmr-space-4);
    max-width: 52ch;
    color: var(--fmr-on-dark);
    opacity: .8;
}

.fmr-signup__form input[type="email"],
.fmr-signup__form input[type="text"] {
    min-height: 44px;
    padding: 10px 12px;
    border: 2px solid var(--fmr-on-dark);
    border-radius: 0;
    background: var(--fmr-surface);
    color: var(--fmr-ink-900);
    font: inherit;
}

.fmr-signup__form input[type="submit"],
.fmr-signup__form button {
    min-height: 44px;
    padding-inline: 20px;
    border: 2px solid var(--fmr-brand-500);
    border-radius: 0;
    background: var(--fmr-brand-500);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

@media print {
    .fmr-sharebar,
    .fmr-signup,
    .fmr-jump {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fmr-sharebar__link {
        transition: none;
    }
}

/* ------------------------------------------------------- units toggle */

.fmr-units {
    display: flex;
    flex-wrap: wrap;
    border: 2px solid var(--fmr-border-strong);
    flex-basis: 100%;
}

.fmr-units button {
    flex: 1 1 auto;
    min-height: 40px;
    padding-inline: 10px;
    border: 0;
    border-right: 2px solid var(--fmr-border-strong);
    background: var(--fmr-surface);
    color: var(--fmr-ink-700);
    font: inherit;
    font-size: var(--fmr-text-xs);
    font-weight: 700;
    letter-spacing: var(--fmr-track-label);
    text-transform: uppercase;
    cursor: pointer;
}

.fmr-units button:last-child {
    border-right: 0;
}

.fmr-units button.is-on {
    background: var(--fmr-surface-dark);
    color: var(--fmr-on-dark);
}

.fmr-unit {
    font-weight: 600;
}

/* --------------------------------------------------- UK ingredient names */

/* "UK: courgette" after an American ingredient name. Quiet enough not to
   compete with the ingredient, present enough to be found on a scan. */
.fmr-alias {
    display: inline-block;
    margin-left: 4px;
    padding: 0 6px;
    border: 1px solid var(--fmr-border);
    font-size: var(--fmr-text-xs);
    font-weight: 600;
    line-height: 1.6;
    color: var(--fmr-ink-500);
    white-space: nowrap;
    vertical-align: baseline;
}

/* "Made it? Leave a rating" once every step is ticked. */
.fmr-progress__rate {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: var(--fmr-space-2);
    padding-inline: 16px;
    background: var(--fmr-brand-500);
    color: #fff;
    font-size: var(--fmr-text-sm);
    font-weight: 700;
    text-decoration: none;
}

.fmr-progress__rate:hover,
.fmr-progress__rate:focus-visible {
    background: var(--fmr-surface-dark);
    color: var(--fmr-on-dark);
}

.fmr-progress__rate[hidden] {
    display: none;
}

/* ------------------------------------------------------------ tested box */

.fmr-tested {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin: 0 0 var(--fmr-space-6);
    padding: 14px 16px;
    border: 2px solid var(--fmr-border-strong);
    background: var(--fmr-surface);
}

.fmr-tested__mark {
    flex: none;
    padding: 2px 8px;
    background: var(--fmr-surface-dark);
    color: var(--fmr-on-dark);
    font-size: var(--fmr-text-xs);
    font-weight: 700;
    letter-spacing: var(--fmr-track-label);
    text-transform: uppercase;
}

.fmr-tested p {
    margin: 0;
    font-size: var(--fmr-text-sm);
    line-height: 1.55;
}

.fmr-tested__note {
    margin-top: 4px !important;
    color: var(--fmr-ink-700);
}

.fmr-convlink {
    margin: var(--fmr-space-3) 0 0;
    font-size: var(--fmr-text-sm);
    font-weight: 600;
}

@media print {
    .fmr-progress__rate,
    .fmr-convlink {
        display: none !important;
    }
}
