/* Giftlist — public pages. Plain CSS served by AssetMapper. */

:root {
    color-scheme: light dark;

    --bg: #faf6f1;
    --surface: #ffffff;
    --surface-glass: rgb(250 246 241 / 0.82);
    --text: #26222b;
    --muted: #6f6874;
    --border: #ebe3da;
    --accent: #d64560;
    --accent-text: #ffffff;
    --accent-soft: #fbe4e8;
    --shadow: 0 1px 2px rgb(38 34 43 / 0.06), 0 6px 20px rgb(38 34 43 / 0.06);
    --shadow-hover: 0 2px 4px rgb(38 34 43 / 0.08), 0 14px 32px rgb(38 34 43 / 0.12);

    --radius: 18px;
    --gutter: 16px;
    --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1a1f;
        --surface: #27242b;
        --surface-glass: rgb(28 26 31 / 0.82);
        --text: #f3eff5;
        --muted: #a9a2ad;
        --border: #37323b;
        --accent: #ef6b83;
        --accent-text: #1c1a1f;
        --accent-soft: #3a2630;
        --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
        --shadow-hover: 0 2px 4px rgb(0 0 0 / 0.35), 0 14px 32px rgb(0 0 0 / 0.4);
    }
}

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

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- Top bar and list switch ---------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: center;
    padding: calc(env(safe-area-inset-top) + 14px) var(--gutter) 14px;
    background: var(--surface-glass);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
}

.list-switch {
    position: relative;
    display: flex;
    gap: 2px;
    max-width: 100%;
    padding: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
}

.list-switch::-webkit-scrollbar {
    display: none;
}

.list-switch__indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    width: 0;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 2px 8px rgb(214 69 96 / 0.35);
    opacity: 0;
    transition: transform 0.45s var(--spring), width 0.45s var(--spring), opacity 0.2s;
}

.list-switch__indicator.is-ready {
    opacity: 1;
}

.list-switch__indicator.is-instant {
    transition: none;
}

.list-switch__item {
    position: relative; /* above the indicator */
    flex: none;
    padding: 9px 18px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.3s var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.list-switch__item:hover {
    color: var(--text);
}

.list-switch__item[aria-current="page"] {
    color: var(--accent-text);
}

.list-switch__item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.single-title {
    margin: 4px 0;
    font-size: 1.25rem;
}

/* --- Content -------------------------------------------------------------- */

.content {
    max-width: 1120px;
    margin: 0 auto;
    padding: 8px var(--gutter) calc(env(safe-area-inset-bottom) + 40px);
}

turbo-frame {
    display: block;
    transition: opacity 0.2s;
}

turbo-frame[aria-busy="true"] {
    opacity: 0.45;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 16px;
    margin: 10px 0 16px;
}

.count {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Sort chips: scroll sideways on narrow phones instead of wrapping */
.sort {
    display: flex;
    gap: 6px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.sort::-webkit-scrollbar {
    display: none;
}

.sort__item {
    flex: none;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sort__item:hover {
    color: var(--text);
}

.sort__item[aria-current="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.sort__item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.empty {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 72px 0;
    color: var(--muted);
    text-align: center;
}

.empty img {
    opacity: 0.85;
}

/* --- Gift cards ----------------------------------------------------------- */

.gift-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (min-width: 640px) {
    :root {
        --gutter: 24px;
    }

    /* Capped columns, centered under the switch even with only a few gifts */
    .gift-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 250px));
        justify-content: center;
        gap: 20px;
    }
}

.gift-grid > li {
    animation: rise 0.5s var(--ease) both;
    animation-delay: calc(min(var(--i), 12) * 45ms);
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}

.gift-card {
    height: 100%;
}

.gift-card__button {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.gift-card__button:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.gift-card__button:active {
    transform: scale(0.98);
}

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

.gift-card__media {
    position: relative;
    display: block;
    aspect-ratio: 1;
    background: var(--accent-soft);
}

.gift-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: var(--accent);
}

.badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgb(0 0 0 / 0.15);
}

.gift-card__body {
    display: grid;
    gap: 2px;
    padding: 12px 14px 14px;
}

.gift-card__name {
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gift-card__price {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 700;
}

.gift-card__host {
    color: var(--muted);
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Modal: bottom sheet on phones, centered dialog above ------------------ */

.gift-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    margin: auto auto 0;
    padding: 0;
    border: 0;
    border-radius: 24px 24px 0 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 -10px 40px rgb(0 0 0 / 0.25);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.25s var(--ease), transform 0.35s var(--spring), overlay 0.35s allow-discrete, display 0.35s allow-discrete;
}

.gift-modal[open] {
    opacity: 1;
    transform: none;
}

@starting-style {
    .gift-modal[open] {
        opacity: 0;
        transform: translateY(40px);
    }
}

.gift-modal::backdrop {
    background: rgb(20 16 24 / 0);
    backdrop-filter: blur(0);
    transition: background 0.3s, backdrop-filter 0.3s, overlay 0.35s allow-discrete, display 0.35s allow-discrete;
}

.gift-modal[open]::backdrop {
    background: rgb(20 16 24 / 0.55);
    backdrop-filter: blur(4px);
}

@starting-style {
    .gift-modal[open]::backdrop {
        background: rgb(20 16 24 / 0);
        backdrop-filter: blur(0);
    }
}

@media (min-width: 640px) {
    .gift-modal {
        width: calc(100% - 48px);
        max-width: 620px;
        margin: auto;
        border-radius: 24px;
        transform: scale(0.95);
    }

    @starting-style {
        .gift-modal[open] {
            transform: scale(0.95);
        }
    }
}

.gift-modal__panel {
    position: relative;
}

.gift-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--surface-glass);
    color: var(--text);
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 1px 4px rgb(0 0 0 / 0.15);
}

.gift-modal__close:focus-visible {
    outline: 2px solid var(--accent);
}

.gift-modal__media {
    aspect-ratio: 4 / 3;
    background: var(--accent-soft);
}

.gift-modal__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.gift-modal__media .placeholder svg {
    width: 96px;
    height: 96px;
}

.gift-modal__body {
    padding: 20px 22px calc(env(safe-area-inset-bottom) + 24px);
}

.gift-modal__body h2 {
    margin: 0 0 14px;
    font-size: 1.35rem;
    line-height: 1.25;
}

.gift-modal__comment {
    margin: -6px 0 16px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.gift-modal__facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 0 0 20px;
}

.gift-modal__facts div {
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--bg);
}

.gift-modal__facts dt {
    color: var(--muted);
    font-size: 0.8rem;
}

.gift-modal__facts dd {
    margin: 2px 0 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 22px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.2s var(--ease), filter 0.2s;
}

.button:hover {
    filter: brightness(1.06);
}

.button:active {
    transform: scale(0.98);
}

@media (min-width: 640px) {
    .button {
        width: auto;
    }
}

/* --- Admin first launch (templates/admin/setup.html.twig) ------------------ */

.setup {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: var(--gutter);
}

.setup__card {
    width: 100%;
    max-width: 400px;
    padding: 32px 28px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.setup__card img {
    margin: 0 auto 12px;
}

.setup__card h1 {
    margin: 0 0 8px;
    font-size: 1.4rem;
}

.setup__card p {
    color: var(--muted);
}

.setup__card pre {
    padding: 10px;
    border-radius: 10px;
    background: var(--bg);
    font-size: 0.9rem;
}

.setup__form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
    text-align: left;
}

.setup__field {
    display: grid;
    gap: 6px;
}

.setup__field label {
    font-weight: 600;
    font-size: 0.9rem;
}

.setup__field input {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.setup__field input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.setup__form ul {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--accent);
    font-size: 0.88rem;
}

.setup__form .button {
    width: 100%;
    border: 0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }
}
