﻿/* =========================================================================
   Gift Registry - theme (friendly / warm / celebratory redesign)

   Design intent (Req 12.1): one confident warm accent (terracotta/coral)
   grounded by a calm sage, laid on warm cream "paper". Soft, rounded,
   friendly display type for headings; comfortable spacing; tactile cards
   with a colored top accent. Avoids the generic pastel-rainbow look.

   Motion lives in a dedicated section further down and is fully disabled
   under prefers-reduced-motion (Req 12.2, 12.3). Responsive at the bottom
   (Req 12.4).
   ========================================================================= */

:root {
    /* --- Core palette --------------------------------------------------- */
    --cream: #fdf6ec;          /* warm paper background        */
    --cream-deep: #f6ead7;     /* slightly deeper paper tint   */
    --ink: #40352e;            /* warm espresso text           */
    --ink-soft: #8a7a6d;       /* muted brown for secondary    */
    --card: #fffaf3;           /* card surface (warmer white)  */
    --line: #ecdcc6;           /* hairline / border            */

    --coral: #e8734a;          /* primary accent (terracotta)  */
    --coral-deep: #cf5c35;
    --coral-wash: #fce9df;     /* soft coral background wash   */
    /* Semantic alias for the primary accent so palette consumers (and the theme
       smoke test) have a stable, intent-named token independent of the hue name. */
    --color-primary: var(--coral);

    --sage: #7fa98c;           /* secondary accent (calm)      */
    --sage-deep: #5f8a6c;
    --sage-wash: #e6f0e8;

    --sky: #bcd3d8;            /* soft header band             */
    --sky-deep: #a9c6cc;
    --butter: #f6c66b;         /* warm highlight (prices)      */

    --success: #4f9d69;
    --success-wash: #e3f1e7;
    --warning: #c88a2e;
    --warning-wash: #faf0dc;
    --claimed: #8b76b4;
    --claimed-wash: #efeaf7;
    --danger: #d1584f;
    --danger-wash: #fae7e5;

    /* --- Shape & depth -------------------------------------------------- */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 999px;

    --shadow-sm: 0 2px 10px rgba(64, 53, 46, 0.06);
    --shadow-md: 0 10px 24px rgba(64, 53, 46, 0.10);
    --shadow-lg: 0 20px 48px rgba(64, 53, 46, 0.14);

    /* --- Spacing -------------------------------------------------------- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    --font-body: "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Baloo 2", "Fredoka", "Segoe UI", system-ui, sans-serif;
    --content-max: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    font-size: 1.02rem;
    line-height: 1.6;
    color: var(--ink);
    background-color: var(--cream);
    /* subtle warm "confetti dots" paper texture, very low contrast */
    background-image:
        radial-gradient(circle at 20% 30%, rgba(232, 115, 74, 0.05) 0 6px, transparent 7px),
        radial-gradient(circle at 70% 65%, rgba(127, 169, 140, 0.05) 0 5px, transparent 6px),
        radial-gradient(circle at 85% 20%, rgba(246, 198, 107, 0.06) 0 5px, transparent 6px);
    background-size: 340px 340px, 420px 420px, 300px 300px;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--ink);
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 var(--space-3);
}
h1 { font-size: clamp(1.8rem, 1.3rem + 2.2vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 1.05rem + 1vw, 1.7rem); }

p { margin: 0 0 var(--space-3); }

a { color: var(--coral-deep); text-decoration: none; font-weight: 700; }
a:hover, a:focus-visible { text-decoration: underline; }

:focus-visible {
    outline: 3px solid var(--sage-deep);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

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

.skip-link {
    position: absolute;
    left: var(--space-3);
    top: -3rem;
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    background: var(--card);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-md);
    transition: top 0.15s ease;
}
.skip-link:focus { top: var(--space-3); }

/* -------------------------------------------------------------------------
   Layout shell
   ------------------------------------------------------------------------- */
.site-header {
    background: var(--sky);
    background-image: linear-gradient(180deg, var(--sky) 0%, var(--sky-deep) 100%);
    border-bottom: 3px solid rgba(64, 53, 46, 0.06);
    position: relative;
}
/* soft scalloped bottom edge, like bunting */
.site-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -11px;
    height: 12px;
    background-image: radial-gradient(circle at 12px -2px, var(--sky-deep) 10px, transparent 11px);
    background-size: 24px 12px;
    background-repeat: repeat-x;
}

.site-header__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-4) var(--space-5);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4);
}

.site-header__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--ink);
    text-decoration: none;
}
.site-header__brand:hover { text-decoration: none; }

/* The brand mark is the SVG logo, sized to sit in the header. No CSS rounding/shadow: the SVG
   already carries its own shape. */
.site-header__brand-mark {
    display: block;
    width: 2.4rem;
    height: 2.4rem;
    line-height: 1;
}

.site-nav { flex: 1 1 auto; }
.site-nav__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}
.site-nav__link {
    display: inline-block;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-pill);
    font-weight: 700;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.5);
}
.site-nav__link:hover, .site-nav__link:focus-visible {
    background: #fff;
    text-decoration: none;
}

.site-header__account {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
}
.site-header__user { font-weight: 700; color: var(--ink); }
.site-header__user--anon { font-weight: 600; opacity: 0.75; }
.site-header__logout { margin: 0; }

.site-main { flex: 1 1 auto; width: 100%; }
.site-main__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-7) var(--space-5) var(--space-6);
}

.site-footer {
    margin-top: var(--space-6);
    background: var(--cream-deep);
    border-top: 1px solid var(--line);
}
.site-footer__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-5);
    text-align: center;
    color: var(--ink-soft);
    font-size: 0.95rem;
}
.site-footer__note::before { content: "\2740  "; color: var(--coral); }

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.button, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font: inherit;
    font-weight: 800;
    line-height: 1.1;
    color: var(--ink);
    background: var(--card);
    border: 2px solid var(--line);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease, border-color 0.14s ease;
}
.button:hover, button:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.button:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.button--primary, button[type="submit"] {
    color: #fff;
    background: var(--coral);
    border-color: var(--coral);
    box-shadow: 0 4px 0 var(--coral-deep), var(--shadow-sm);
}
.button--primary:hover, button[type="submit"]:hover {
    background: var(--coral-deep);
    border-color: var(--coral-deep);
    box-shadow: 0 4px 0 var(--coral-deep), var(--shadow-md);
}
.button--primary:active, button[type="submit"]:active {
    box-shadow: 0 1px 0 var(--coral-deep), var(--shadow-sm);
}

.button--ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--ink);
}
.button--ghost:hover { background: rgba(255, 255, 255, 0.6); }

.button.danger, button.danger, .danger {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
    box-shadow: 0 4px 0 #b4463e, var(--shadow-sm);
}
.button.danger:hover, button.danger:hover { filter: brightness(0.96); }

/* Compact button for dense surfaces like the donations table action cell. */
.button--sm {
    padding: var(--space-2) var(--space-4);
    font-size: 0.9rem;
}

/* -------------------------------------------------------------------------
   Page intro (optional heading block some views can use via .page-intro)
   ------------------------------------------------------------------------- */
.page-intro { margin-bottom: var(--space-6); }
.page-intro__lead { color: var(--ink-soft); max-width: 46ch; font-size: 1.08rem; }

/* -------------------------------------------------------------------------
   Registry browse grid
   ------------------------------------------------------------------------- */
.registry-empty {
    padding: var(--space-7) var(--space-6);
    text-align: center;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    font-size: 1.1rem;
}
.registry-empty::before {
    content: "\1F9F8";       /* teddy bear */
    display: block;
    font-size: 2.6rem;
    margin-bottom: var(--space-3);
}

.registry-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}

.registry-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-5);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}
/* playful colored top accent bar on every card */
.registry-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 6px;
    background: linear-gradient(90deg, var(--coral) 0%, var(--butter) 55%, var(--sage) 100%);
}
.registry-card:hover { box-shadow: var(--shadow-md); }

.registry-card__link { color: inherit; text-decoration: none; font-weight: inherit; }
.registry-card__link:hover { text-decoration: none; }

.registry-card__media { margin: var(--space-2) 0 var(--space-3); }
.registry-card__image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--cream-deep);
}
/* friendly illustrated placeholder instead of a dev stripe pattern */
.registry-card__image--placeholder,
.item-detail__image--placeholder {
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 50% 42%, var(--coral-wash) 0 42%, transparent 43%),
        var(--sage-wash);
}
.registry-card__image--placeholder::after,
.item-detail__image--placeholder::after {
    content: "\1F381";       /* wrapped gift */
    font-size: 2.6rem;
    opacity: 0.85;
}

/* --- Gallery card image carousel ------------------------------------------ */
.registry-card__media--carousel { position: relative; }
.registry-card__slides { position: relative; }
/* Only the active slide shows. Non-active slides carry the [hidden] attribute, enforced globally
   by the [hidden]{display:none!important} rule; this is a defensive fallback. */
.registry-card__media--carousel .registry-card__image:not(.is-active) { display: none; }

/* Prev/next controls, overlaid on the image edges. */
.registry-card__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--ink);
    background: rgba(255, 250, 243, 0.86);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.14s ease, background-color 0.14s ease, transform 0.14s ease;
}
.registry-card__nav--prev { left: var(--space-2); }
.registry-card__nav--next { right: var(--space-2); }
/* Reveal controls on hover/focus; always visible on touch (no hover) via focus-within fallback. */
.registry-card__media--carousel:hover .registry-card__nav,
.registry-card__media--carousel:focus-within .registry-card__nav { opacity: 1; }
.registry-card__nav:hover { background: #fff; }
.registry-card__nav:focus-visible { opacity: 1; outline: 3px solid var(--sky-deep); outline-offset: 2px; }
/* Keep the controls vertically centred; override the global button hover/active translate so the
   nav buttons don't jump off-centre, and the dots don't drift. */
.registry-card__nav:hover, .registry-card__nav:focus-visible, .registry-card__nav:active { transform: translateY(-50%); }
.registry-card__dot:hover, .registry-card__dot:focus-visible, .registry-card__dot:active { transform: none; }
.registry-card__dot.is-active:hover { transform: scale(1.15); }

/* Dot indicators centred along the bottom edge. */
.registry-card__dots {
    position: absolute;
    left: 0; right: 0; bottom: var(--space-2);
    z-index: 2;
    display: flex;
    justify-content: center;
    gap: var(--space-2);
}
.registry-card__dot {
    width: 0.55rem;
    height: 0.55rem;
    padding: 0;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(64, 53, 46, 0.35);
    background: rgba(255, 250, 243, 0.75);
    box-shadow: 0 1px 2px rgba(64, 53, 46, 0.25);
    cursor: pointer;
    transition: background-color 0.14s ease, transform 0.14s ease;
}
.registry-card__dot.is-active { background: var(--coral); border-color: var(--coral); transform: scale(1.15); }
.registry-card__dot:focus-visible { outline: 2px solid var(--sky-deep); outline-offset: 2px; }

.registry-card__title { font-size: 1.25rem; margin: 0; }

.registry-card__price {
    display: inline-block;
    align-self: flex-start;
    font-family: var(--font-display);
    font-weight: 800;
    color: var(--ink);
    background: var(--butter);
    padding: 2px var(--space-3);
    border-radius: var(--radius-pill);
    margin: 0;
}

.registry-card__remaining,
.registry-card__remaining-amount {
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.registry-card__funding {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
}
.registry-card__donated { font-weight: 800; color: var(--sage-deep); }

/* Funding progress bar: a rounded track with a sage fill whose width = percent funded.
   The label is overlaid and centred; a --complete modifier celebrates a fully-funded item. */
.registry-card__progress {
    position: relative;
    width: 100%;
    height: 1.15rem;
    margin-top: var(--space-1);
    background: var(--cream-deep);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    overflow: hidden;
    isolation: isolate;
}
.registry-card__progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 0;
    height: 100%;
    min-width: 0;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--sage) 0%, var(--sage-deep) 100%);
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.registry-card__progress-label {
    position: relative;
    z-index: 1;
    display: block;
    text-align: center;
    line-height: 1.15rem;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--ink);
    /* A soft halo keeps the label legible over both the empty track and the fill. */
    text-shadow: 0 0 3px var(--card), 0 0 3px var(--card);
}
/* Fully funded: a warm coral-to-sage fill to echo the celebratory "Fully funded" badge. */
.registry-card__progress--complete .registry-card__progress-fill {
    background: linear-gradient(90deg, var(--coral) 0%, var(--sage-deep) 100%);
}
.registry-card__progress--complete .registry-card__progress-label { color: #fff; text-shadow: none; }

/* Card footer pins the browse/edit links to the bottom of the card. */
.registry-card__footer {
    margin-top: auto;
    padding-top: var(--space-3);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4);
}
.registry-card__details {
    font-weight: 800;
    color: var(--coral-deep);
}
.registry-card__details::after {
    content: " \2192";
    transition: transform 0.14s ease;
    display: inline-block;
}
.registry-card:hover .registry-card__details::after { transform: translateX(3px); }

/* Owner-only quick edit link on a card. */
.registry-card__edit {
    font-weight: 800;
    color: var(--ink-soft);
}
.registry-card__edit:hover { color: var(--ink); }

/* status badges (shared) */
.registry-card__status,
.item-detail__status {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 800;
}
.registry-card__status--claimed, .item-detail__status--claimed {
    color: var(--claimed); background: var(--claimed-wash);
}
.registry-card__status--claimed::before,
.item-detail__status--claimed::before { content: "\2714 "; }
.registry-card__status--funded, .item-detail__status--funded {
    color: var(--success); background: var(--success-wash);
}
.registry-card__status--funded::before,
.item-detail__status--funded::before { content: "\1F389 "; }

/* -------------------------------------------------------------------------
   Item detail
   ------------------------------------------------------------------------- */
.item-detail {
    display: grid;
    gap: var(--space-5);
    max-width: 900px;
    margin: 0 auto;
}
.item-detail__title { margin-bottom: 0; }

.item-detail__gallery {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.item-detail__image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--cream-deep);
    box-shadow: var(--shadow-sm);
}

.item-detail__description { color: var(--ink-soft); font-size: 1.08rem; max-width: 60ch; }

.item-detail__price {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ink);
    background: var(--butter);
    padding: var(--space-1) var(--space-4);
    border-radius: var(--radius-pill);
}

.item-detail__quantity,
.item-detail__funding,
.item-detail__contributors {
    padding: var(--space-5);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.item-detail__quantity h2,
.item-detail__funding h2,
.item-detail__contributors h2 { margin-top: 0; }

.item-detail__quantity dl,
.item-detail__funding dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-2) var(--space-5);
    margin: 0;
}
.item-detail__quantity dt,
.item-detail__funding dt { font-weight: 700; color: var(--ink-soft); }
.item-detail__quantity dd,
.item-detail__funding dd { margin: 0; font-weight: 800; }

.item-detail__contributor-list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-wrap: wrap; gap: var(--space-2);
}
.item-detail__contributor-list li {
    padding: var(--space-1) var(--space-3);
    background: var(--sage);
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 700;
}
.item-detail__contributors-empty { color: var(--ink-soft); margin: 0; }

.item-detail__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* Owner management block, set apart from the buy/donate CTA with a soft divider. */
.item-detail__owner-actions {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px dashed var(--line);
}
.item-detail__owner-actions-title {
    margin: 0 0 var(--space-3);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.item-detail__owner-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}
.item-detail__owner-buttons form { margin: 0; }

/* Owner mark-quantity-bought control: label, input, "of N", and the button sit on one inline row. */
.item-detail__mark-bought {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-4);
}
.item-detail__mark-bought-label {
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
/* Compact fixed-width field. The extra class ancestor raises specificity above the global
   input[type="number"]{width:100%} rule so the field stays small and inline. */
.item-detail__mark-bought .item-detail__mark-bought-input {
    width: 4.5rem;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--card);
    font: inherit;
}
.item-detail__mark-bought-of { color: var(--ink-soft); font-weight: 700; }
.item-detail__mark-bought .button { flex: 0 0 auto; }

/* Owner action feedback banner (shared tone with the donation status). */
.item-detail__status-message {
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--success-wash);
    color: var(--success);
    border-radius: var(--radius-md);
    font-weight: 700;
}

/* -------------------------------------------------------------------------
   Register / donate flow
   ------------------------------------------------------------------------- */
.register, .donation-confirmation {
    max-width: 640px;
    margin: 0 auto;
    padding: var(--space-6);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.register__price {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 800;
    background: var(--butter);
    padding: var(--space-1) var(--space-4);
    border-radius: var(--radius-pill);
    margin: 0 0 var(--space-3);
}
.register__quantity { color: var(--ink-soft); margin: 0 0 var(--space-5); }

/* Segmented toggle: a pill-shaped track with a single coral "thumb" that slides between the
   two segments. The thumb is a ::before pseudo-element moved with transform:translateX so the
   state change animates smoothly (rather than cross-fading two separate backgrounds). Its
   position is driven by the data-active attribute set on the container by the toggle script;
   :checked is used as a no-JS fallback. The radio inputs stay for accessibility/no-JS posting
   but are visually hidden, so the labels become the toggle segments. */
.register__type-selector {
    position: relative;
    display: inline-flex;
    width: 100%;
    max-width: 22rem;
    gap: var(--space-1);
    padding: var(--space-1);
    margin-bottom: var(--space-5);
    background: var(--cream-deep);
    border: 1px solid rgba(64, 53, 46, 0.08);
    border-radius: var(--radius-pill);
    isolation: isolate;
}
/* The sliding thumb. Width spans one segment (half the track minus the centre gap); it starts
   over the first segment and slides right when the second is active. */
.register__type-selector::before {
    content: "";
    position: absolute;
    z-index: 0;
    top: var(--space-1);
    bottom: var(--space-1);
    left: var(--space-1);
    width: calc((100% - var(--space-1) * 2 - var(--space-1)) / 2);
    background: var(--coral);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    transform: translateX(0);
    transition: transform 0.26s cubic-bezier(0.34, 1.3, 0.64, 1);
}
/* Slide the thumb to the second segment. The travel distance is one segment width plus the gap.
   Driven by data-active (set by the toggle script); the :has() rule is a no-JS fallback that
   reacts to the second radio being checked on load/selection. */
.register__type-selector[data-active="donate"]::before,
.register__type-selector:not([data-active]):has(label:last-of-type input:checked)::before {
    transform: translateX(calc(100% + var(--space-1)));
}

.register__type-selector label {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-weight: 700;
    color: var(--ink-soft);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-pill);
    cursor: pointer;
    user-select: none;
    text-align: center;
    transition: color 0.2s ease;
}
/* Hide the actual radio dot but keep it operable and focusable. */
.register__type-selector input[type="radio"] {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
/* Selected segment text turns white to read against the coral thumb beneath it. */
.register__type-selector label:has(input:checked),
.register__type-selector label.is-selected {
    color: #fff;
}
.register__type-selector label:hover:not(:has(input:checked)):not(.is-selected) {
    color: var(--ink);
}
/* Keyboard focus ring on the segment, not the hidden radio. */
.register__type-selector label:has(input:focus-visible),
.register__type-selector label.is-focused {
    outline: 3px solid var(--sky-deep);
    outline-offset: 2px;
}
/* Disabled "Buy" segment when the item is fully claimed. */
.register__type-selector label:has(input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

/* The HTML [hidden] attribute must win over authored display rules. Grid/flex display
   declarations (e.g. .register__form below) otherwise override the UA [hidden] rule, which
   kept the inactive buy/donate form visible even after the toggle script set form.hidden. */
[hidden] { display: none !important; }

.register__form { display: grid; gap: var(--space-4); }
.register__visibility { display: grid; gap: var(--space-2); }
.register__claimed {
    padding: var(--space-3) var(--space-4);
    background: var(--claimed-wash);
    color: var(--claimed);
    border-radius: var(--radius-md);
    font-weight: 700;
}

/* -------------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------------- */
form { margin: 0 0 var(--space-4); }

.form-field {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    border: 0; padding: 0; min-width: 0;
}
.form-field > label,
.form-field > legend { font-weight: 800; color: var(--ink); }

.form-field input[type="text"],
.form-field input[type="url"],
.form-field input[type="number"],
.form-field input[type="email"],
.form-field input[type="file"],
.form-field textarea,
input[type="text"], input[type="url"], input[type="number"],
input[type="email"], textarea, select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font: inherit;
    color: var(--ink);
    background: var(--cream);
    border: 2px solid var(--line);
    border-radius: var(--radius-md);
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.form-field input:focus, .form-field textarea:focus,
input:focus, textarea:focus, select:focus {
    border-color: var(--sage);
    outline: none;
    box-shadow: 0 0 0 4px var(--sage-wash);
}
textarea { resize: vertical; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

/* Only show the red summary box when the server actually reported errors. ASP.NET adds
   .validation-summary-valid when the model is valid (rendering an empty <ul><li hidden></li></ul>,
   which is NOT :empty), and swaps to .validation-summary-errors when there are messages. Keying
   the styling off these state classes avoids an empty red box on a clean page load. */
.validation-summary-valid { display: none; }

.validation-summary-errors {
    margin: 0 0 var(--space-5);
    padding: var(--space-4) var(--space-5);
    color: var(--danger);
    background: var(--danger-wash);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    font-weight: 600;
}
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }

.field-validation-error { color: var(--danger); font-size: 0.9rem; font-weight: 700; }
input.input-validation-error, textarea.input-validation-error { border-color: var(--danger); }

/* -------------------------------------------------------------------------
   Donation confirmation + payment instructions
   ------------------------------------------------------------------------- */
.donation-confirmation__title { color: var(--coral-deep); }
.donation-confirmation__title::before {
    content: "\1F389 ";
}
.donation-confirmation__summary, .donation-confirmation__amount { font-size: 1.08rem; }
.donation-confirmation__clamp {
    padding: var(--space-4);
    background: var(--warning-wash);
    color: var(--warning);
    border-radius: var(--radius-md);
    font-weight: 700;
}
.donation-confirmation__actions {
    display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5);
}

.payment-instructions {
    margin-top: var(--space-5);
    padding: var(--space-5);
    background: var(--sage-wash);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.payment-instructions h2 { margin-top: 0; }
.payment-instructions__lead { color: var(--ink-soft); margin-top: 0; }
.payment-instructions__fields {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-3) var(--space-5);
    margin: 0;
    align-items: center;
}
.payment-instructions__fields dt { font-weight: 800; color: var(--ink-soft); }
.payment-instructions__fields dd {
    margin: 0;
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
}
.payment-instructions__value { font-weight: 800; font-variant-numeric: tabular-nums; }

.copy-button {
    padding: var(--space-1) var(--space-3);
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--sage-deep);
    background: #fff;
    border: 2px solid var(--sage);
    border-radius: var(--radius-pill);
    box-shadow: none;
}
.copy-button:hover { background: var(--sage); color: #fff; }

/* -------------------------------------------------------------------------
   Owner donations table
   ------------------------------------------------------------------------- */
.owner-donations__status {
    padding: var(--space-3) var(--space-4);
    background: var(--success-wash);
    color: var(--success);
    border-radius: var(--radius-md);
    font-weight: 700;
}
.owner-donations__empty {
    padding: var(--space-7) var(--space-6);
    text-align: center;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.owner-donations__empty::before {
    content: "\1F4EC";
    display: block; font-size: 2.4rem; margin-bottom: var(--space-2);
}

table.owner-donations {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
table.owner-donations th, table.owner-donations td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.owner-donations thead th {
    background: var(--cream-deep);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
}
table.owner-donations tbody tr:last-child th,
table.owner-donations tbody tr:last-child td { border-bottom: 0; }
table.owner-donations tbody tr:hover { background: var(--cream); }
table.owner-donations form { margin: 0; }

/* Action cell layout: a tidy vertical stack of (1) the status-change button row and
   (2) the compact edit form, instead of controls crammed together. */
.donation-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: flex-start;
    min-width: 15rem;
}
.donation-actions__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* Compact inline edit form: amount + visibility sit side by side and wrap gracefully;
   the Save/Delete buttons share their own row beneath. */
.donation-edit {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--cream-deep);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}
.donation-edit__fields {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}
.donation-edit__field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.donation-edit__field label {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.donation-edit__field--amount { flex: 0 0 7.5rem; }
.donation-edit__field--amount input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--card);
    font: inherit;
    white-space: normal;
}
.donation-edit__field--visibility { flex: 1 1 8rem; }
.donation-edit__field--visibility select {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--card);
    font: inherit;
}
.donation-edit__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.payment-status {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 800;
}
.payment-status--awaiting { color: var(--warning); background: var(--warning-wash); }
.payment-status--received { color: var(--success); background: var(--success-wash); }
.payment-status--received::before { content: "\2714 "; }

/* -------------------------------------------------------------------------
   Responsive (Req 12.4)
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Stack the header into tidy rows instead of letting flex-wrap scatter
       the brand, nav and account block into overlapping fragments. */
    .site-header__inner {
        padding: var(--space-3) var(--space-4);
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    /* Top row: brand on the left, account (greeting + sign out) on the right. */
    .site-header__brand { order: 1; align-self: flex-start; }
    .site-header__account {
        order: 2;
        margin-left: 0;
        align-self: flex-start;
        flex-wrap: wrap;
    }
    /* Nav becomes a full-width row of evenly sized, tappable pills. */
    .site-nav { order: 3; flex: 1 1 100%; width: 100%; }
    .site-nav__list { width: 100%; gap: var(--space-2); flex-wrap: wrap; }
    /* The <li> items are the flex children of the list, so they must grow to
       share the row evenly; the link then fills its item. */
    .site-nav__item {
        flex: 1 1 auto;
        min-width: max-content;
    }
    .site-nav__link {
        display: block;
        text-align: center;
        padding: var(--space-3) var(--space-3);
        white-space: nowrap;
    }
    .site-main__inner { padding: var(--space-6) var(--space-4); }
    .register, .donation-confirmation { padding: var(--space-5) var(--space-4); }

    .item-detail__quantity dl,
    .item-detail__funding dl,
    .payment-instructions__fields {
        grid-template-columns: 1fr;
        gap: var(--space-1) 0;
    }
    .payment-instructions__fields dt { margin-top: var(--space-3); }

    table.owner-donations { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 480px) {
    .registry-grid { grid-template-columns: 1fr; }
    /* On very narrow phones give the account greeting + sign-out their own
       full-width row so they never crowd the brand. */
    .site-header__account { width: 100%; justify-content: space-between; }
    .form-actions, .item-detail__actions, .donation-confirmation__actions {
        flex-direction: column; align-items: stretch;
    }
    .form-actions .button, .form-actions button,
    .item-detail__actions .button, .donation-confirmation__actions .button { width: 100%; }
}

/* =========================================================================
   Celebratory motion (Req 12.2) - transform/opacity only, cheap to composite.
   All non-essential motion is neutralised under prefers-reduced-motion below
   (Req 12.3).
   ========================================================================= */
html { scroll-behavior: smooth; }

@keyframes gr-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.05); }
    70% { transform: scale(0.98); }
    100% { transform: scale(1); }
}
@keyframes gr-wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    50% { transform: rotate(8deg); }
    75% { transform: rotate(-5deg); }
}
@keyframes gr-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
@keyframes gr-rise-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.button:hover, .button:focus-visible,
button:hover, button:focus-visible { transform: translateY(-2px); }
.button:active, button:active { transform: translateY(0); }
.button:disabled, button:disabled,
.button:disabled:hover, button:disabled:hover { transform: none; }

.button--primary:hover, .button--primary:focus-visible,
button[type="submit"]:hover, button[type="submit"]:focus-visible { animation: gr-pop 0.45s ease; }

.registry-card:hover, .registry-card:focus-within { transform: translateY(-5px); }
.registry-card__link:focus-visible { outline-offset: 4px; }

.site-nav__link { transition: transform 0.12s ease, background-color 0.12s ease; }
.site-nav__link:hover, .site-nav__link:focus-visible { transform: translateY(-1px); }

.item-detail__register:hover, .item-detail__register:focus-visible { animation: gr-pop 0.45s ease; }

.copy-button { transition: transform 0.12s ease, background-color 0.12s ease, color 0.12s ease; }
.copy-button:hover, .copy-button:focus-visible { animation: gr-pulse 0.4s ease; }

.payment-status--received { animation: gr-pop 0.5s ease; }

.site-header__brand { transition: transform 0.12s ease; }
.site-header__brand:hover .site-header__brand-mark,
.site-header__brand:focus-visible .site-header__brand-mark {
    animation: gr-wiggle 0.6s ease;
    transform-origin: 60% 60%;
}

.registry-grid > .registry-card { animation: gr-rise-in 0.5s ease both; }
.registry-grid > .registry-card:nth-child(2) { animation-delay: 0.06s; }
.registry-grid > .registry-card:nth-child(3) { animation-delay: 0.12s; }
.registry-grid > .registry-card:nth-child(4) { animation-delay: 0.18s; }
.registry-grid > .registry-card:nth-child(5) { animation-delay: 0.24s; }
.registry-grid > .registry-card:nth-child(6) { animation-delay: 0.30s; }
.registry-grid > .registry-card:nth-child(n+7) { animation-delay: 0.36s; }

/* -------------------------------------------------------------------------
   Reduced-motion guard (Req 12.3)
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .button:hover, .button:focus-visible, .button:active,
    button:hover, button:focus-visible, button:active,
    .button--primary:hover, .button--primary:focus-visible,
    button[type="submit"]:hover, button[type="submit"]:focus-visible,
    .registry-card:hover, .registry-card:focus-within,
    .site-nav__link:hover, .site-nav__link:focus-visible,
    .item-detail__register:hover, .item-detail__register:focus-visible,
    .copy-button:hover, .copy-button:focus-visible,
    .site-header__brand:hover .site-header__brand-mark,
    .site-header__brand:focus-visible .site-header__brand-mark,
    .registry-grid > .registry-card,
    .payment-status--received,
    .registry-card__details::after,
    .registry-card:hover .registry-card__details::after {
        animation: none !important;
        transform: none !important;
    }
    .registry-grid > .registry-card { opacity: 1 !important; }
}
