/*
 * Brand tokens copied from ReFood.Mobile/src/theme/palette.ts — the app's own sage/amber
 * palette, so a page opened from an email looks like the app it belongs to.
 */
:root {
    --sage: #6F8A6A;
    --amber: #F2C15A;
    --ink: #2E2F2B;
    --muted: #7A756E;
    --bg: #FBFAF7;
    --card: #FFFFFF;
    --border: #ECE8E1;
    --input: #DAD5CC;
    --error: #E07A6E;
    --error-bg: #FBEAE7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 24px;
    display: flex;
    align-items: center;
    /* A shared post can be taller than the window; centring alone would push its top edge
       off the top of the page with no way to scroll back to it. Ignored where unsupported,
       which leaves the plain centring above. */
    align-items: safe center;
    justify-content: center;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.card {
    width: 100%;
    max-width: 420px;
    padding: 28px 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
}

h1 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.25;
}

p {
    margin: 0 0 16px;
    color: var(--muted);
}

label {
    display: block;
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--muted);
}

/* A revealed password is a type="text" input, and must look the same as a hidden one. */
input[type="password"],
.password-field input {
    width: 100%;
    margin: 0 0 16px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 16px;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--input);
    border-radius: 12px;
}

input[type="password"]:focus,
.password-field input:focus {
    outline: 2px solid var(--sage);
    outline-offset: 1px;
    border-color: var(--sage);
}

/* Edge draws its own eye inside password fields; ours is the one that works everywhere. */
input::-ms-reveal {
    display: none;
}

/* The field's margin moves to its wrapper, so the eye centres on the input alone. */
.password-field {
    position: relative;
    margin: 0 0 16px;
}

.password-field input {
    margin: 0;
    padding-right: 48px;
}

.reveal {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}

.reveal:focus-visible {
    outline: 2px solid var(--sage);
    outline-offset: -2px;
}

.reveal svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.btn {
    display: block;
    width: 100%;
    padding: 14px 16px;
    margin: 0 0 12px;
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: var(--ink);
    background: var(--amber);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.btn.ghost {
    color: var(--sage);
    background: transparent;
    border: 1px solid var(--sage);
}

.note {
    margin: 16px 0 0;
    font-size: 14px;
    text-align: center;
}

/*
 * A shared food post (Pages/SharedPost.cshtml): the same card, a little wider and with its
 * photos bled to the edges, so a plate opened from a message looks like the plate does in
 * the app's own feed.
 */
.card.post {
    max-width: 560px;
    padding: 0 0 24px;
    overflow: hidden;
}

.post-body {
    padding: 0 20px;
}

.post-body h1 {
    margin: 12px 0 8px;
}

/* Nothing above it — a "this post is gone" page, or a post whose photos have gone missing
   — so the body supplies the card's own top padding. */
.card.post > .post-body:first-child {
    padding-top: 24px;
}

.card.post > .btn,
.card.post > .note {
    margin-left: 20px;
    margin-right: 20px;
    width: auto;
}

/* The picture at the top of a shared post: a clip, or one or more photos. Positioned, so the
   badge, the counter and the carousel's buttons and dots sit on it without moving it. */
.media {
    position: relative;
    margin: 0 0 16px;
    background: var(--border);
}

/* A clip keeps its own shape, up to a height that leaves the plate's name on screen. */
.media video {
    display: block;
    width: 100%;
    max-height: 560px;
    background: #000;
}

/*
 * The photos' frame takes the first photo's shape, within the bounds the app's feed frames a
 * plate within (the page sets it, see SharedPostModel.FrameAspect), and keeps it as the photos
 * are swiped, so nothing below moves.
 */
.gallery {
    overflow: hidden;
}

/* A strip that snaps a photo at a time: what a phone swipes, and what the buttons and dots
   below scroll. No script runs here — the website serves this page too, and carries none. */
.photos {
    position: absolute;
    inset: 0;
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

.photo {
    position: relative;
    flex: 0 0 100%;
    margin: 0;
    overflow: hidden;
    scroll-snap-align: start;
    /* One photo per swipe, however hard it is flicked — as the app's carousel pages. */
    scroll-snap-stop: always;
}

.photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* A photo of another shape than the frame is shown whole, over a blurred, darkened copy of
   itself that fills the rest — as the app does, rather than cropping it to the first photo's
   shape. The copy is the same file, so nothing more is downloaded. */
.photo.whole img {
    position: relative;
    object-fit: contain;
}

.photo.whole img.backdrop {
    position: absolute;
    inset: 0;
    object-fit: cover;
    filter: blur(24px) brightness(0.75);
    /* Past the frame's edges, which a blur would otherwise fade. */
    transform: scale(1.15);
}

/* Which photo this is, on the photo itself, so it needs nothing to keep it current. Where the
   browser can draw the dots below, they say it instead. */
.count {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: rgb(0 0 0 / 0.55);
    border-radius: 999px;
}

/*
 * The carousel's controls, drawn by the browser from CSS alone: a dot per photo, and on a
 * screen with a pointer, a button either side. A browser without them still swipes, scrolls
 * and shows the counter above.
 */
@supports selector(::scroll-marker) {
    .photos {
        scrollbar-width: none;
    }

    .photos.many {
        scroll-marker-group: after;
    }

    .count {
        display: none;
    }

    .photos::scroll-marker-group {
        position: absolute;
        left: 50%;
        bottom: 12px;
        display: flex;
        gap: 6px;
        padding: 5px 8px;
        background: rgb(0 0 0 / 0.3);
        border-radius: 999px;
        translate: -50% 0;
    }

    .photo::scroll-marker {
        content: "" / attr(data-label);
        width: 7px;
        height: 7px;
        background: rgb(255 255 255 / 0.5);
        border-radius: 999px;
        cursor: pointer;
        transition: background-color 0.2s, scale 0.2s;
    }

    .photo::scroll-marker:target-current {
        background: #fff;
        scale: 1.25;
    }

    .photo::scroll-marker:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 2px;
    }

    @media (hover: hover) {
        .photos.many::scroll-button(left) {
            content: "" / attr(data-previous);
            left: 12px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14.5 6 8.5 12l6 6' fill='none' stroke='%232E2F2B' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        }

        .photos.many::scroll-button(right) {
            content: "" / attr(data-next);
            right: 12px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m9.5 6 6 6-6 6' fill='none' stroke='%232E2F2B' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        }

        .photos::scroll-button(*) {
            position: absolute;
            top: 50%;
            width: 36px;
            height: 36px;
            padding: 0;
            background-color: rgb(255 255 255 / 0.9);
            background-position: center;
            background-repeat: no-repeat;
            background-size: 22px;
            border: 0;
            border-radius: 999px;
            box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
            cursor: pointer;
            translate: 0 -50%;
            transition: opacity 0.2s, background-color 0.2s;
        }

        .photos::scroll-button(*):hover {
            background-color: #fff;
        }

        .photos::scroll-button(*):focus-visible {
            outline: 2px solid var(--sage);
            outline-offset: 2px;
        }

        /* Nothing further that way: the first photo has no previous, the last no next. */
        .photos::scroll-button(*):disabled {
            opacity: 0;
            cursor: default;
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .photos {
        scroll-behavior: auto;
    }
}

.badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--sage);
    background: var(--card);
    border-radius: 999px;
}

.byline {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    object-fit: cover;
}

.avatar.initial {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    background: var(--sage);
}

.muted {
    color: var(--muted);
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 14px;
    color: var(--muted);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    padding: 5px 10px;
    font-size: 13px;
    color: var(--sage);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
}

/* What the numbers below are per: "Nutrition per 100 g". */
.macros-label {
    margin: 0 0 6px;
    font-size: 13px;
}

.macros {
    display: flex;
    margin: 0 0 16px;
    padding: 12px 6px;
    background: var(--bg);
    border-radius: 12px;
}

.macros > div {
    flex: 1;
    text-align: center;
}

.macros dt {
    font-weight: 700;
}

.macros dd {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

.steps summary {
    font-weight: 600;
    color: var(--sage);
    cursor: pointer;
}

/* The method is typed as free text; keep the author's own line breaks. */
.pre {
    white-space: pre-wrap;
}

/* The validation summary renders unconditionally; only show it once it has something. */
.validation-summary-errors {
    margin: 0 0 16px;
    padding: 12px 14px;
    font-size: 14px;
    color: var(--ink);
    background: var(--error-bg);
    border: 1px solid var(--error);
    border-radius: 12px;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

.validation-summary-valid {
    display: none;
}
