/* ===== Zmienne (kolory, zaokrąglenia) ===== */
:root {
    --bg: #faf7f2;
    --card: #ffffff;
    --text: #1f2933;
    --muted: #6b7280;
    --border: #e7e1d8;
    --accent: #2a9d8f;
    --accent-dark: #21867a;
    --danger: #c0392b;
    --danger-bg: #fdecea;
    --radius: 14px;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 14px rgb(0 0 0 / 0.06);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

h1:focus {
    outline: none;
}

a {
    color: var(--accent-dark);
}

/* ===== Układ strony ===== */
.page {
    max-width: 1040px;
    margin: 0 auto;
    padding: 1.25rem 1rem 4rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar h1 {
    font-size: clamp(1.4rem, 4vw, 2rem);
    margin: 0.5rem 0;
}

.hint {
    color: var(--muted);
    margin-top: 0;
}

/* ===== Przyciski ===== */
button {
    font: inherit;
    cursor: pointer;
    border-radius: 999px;
    padding: 0.55rem 1.1rem;
    border: 1px solid transparent;
    transition: background-color 0.2s, color 0.2s, opacity 0.2s, transform 0.1s;
}

button:active:not(:disabled) {
    transform: scale(0.97);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-dark);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: #f1ece4;
}

.btn-link {
    background: none;
    color: var(--muted);
    text-decoration: underline;
    padding: 0.25rem;
}

/* ===== Lista prezentów ===== */
.gift-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.gift-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    /* Wejście kart jedna po drugiej: --i to numer karty ustawiany w Home.razor. */
    animation: card-in 0.45s ease-out backwards;
    animation-delay: calc(var(--i, 0) * 70ms);
    transition: border-color 0.4s, background-color 0.4s, transform 0.2s;
}

.gift-card:hover {
    transform: translateY(-2px);
}

.gift-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    transition: filter 0.5s;
}

.gift-body {
    padding: 0.85rem 1rem 0.5rem;
    flex: 1;
}

.gift-name {
    font-size: 1.1rem;
    margin: 0 0 0.3rem;
}

/* Skreślenie: linia rysowana jako tło napisu, animowana od 0 do 100% szerokości. */
.gift-name span {
    background-image: linear-gradient(currentColor, currentColor);
    background-repeat: no-repeat;
    background-position: 0 58%;
    background-size: 0 2px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    transition: background-size 0.6s ease-in-out, color 0.4s;
}

.gift-price {
    font-weight: 700;
    margin: 0 0 0.4rem;
}

.gift-description {
    margin: 0 0 0.5rem;
    color: var(--muted);
}

.gift-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 1rem 1rem;
}

.tag {
    display: inline-block;
    margin-top: 0.6rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 0.85rem;
    animation: pop-in 0.35s ease-out;
}

/* ===== "Checkbox" w rogu karty ===== */
.check {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgb(255 255 255 / 0.9);
    border: 2px solid var(--border);
    transition: background-color 0.3s, border-color 0.3s;
    z-index: 1;
}

.check::after {
    content: "";
    position: absolute;
    left: 0.62rem;
    top: 0.3rem;
    width: 0.45rem;
    height: 0.9rem;
    border: solid #fff;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s;
}

/* ===== Stan: zarezerwowany ===== */
.gift-card.reserved {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.gift-card.reserved img {
    filter: grayscale(0.85);
}

.gift-card.reserved .gift-name span {
    background-size: 100% 2px;
    color: var(--danger);
}

.gift-card.reserved .check {
    background: var(--danger);
    border-color: var(--danger);
}

.gift-card.reserved .check::after {
    transform: rotate(45deg) scale(1);
}

/* ===== Popup z tagiem ===== */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(17 24 39 / 0.45);
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 100;
    animation: fade-in 0.2s ease-out;
}

.dialog {
    width: min(420px, 100%);
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 20px 50px rgb(0 0 0 / 0.25);
    animation: dialog-in 0.25s ease-out;
}

.dialog h2 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.dialog label {
    display: block;
    margin: 0.75rem 0 0.25rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.dialog input {
    width: 100%;
    font: inherit;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.dialog input:focus {
    outline: 2px solid var(--accent);
    border-color: transparent;
}

.counter {
    display: block;
    text-align: right;
    color: var(--muted);
    margin-top: 0.25rem;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ===== Komunikat (toast) ===== */
.toast {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    max-width: calc(100% - 2rem);
    padding: 0.75rem 1.1rem;
    border-radius: 12px;
    color: #fff;
    box-shadow: var(--shadow);
    z-index: 200;
    pointer-events: none;
    /* Pojawia się, wisi ~3,5 s i znika – bez żadnego JavaScriptu. */
    animation: toast-in 0.3s ease-out both, toast-out 0.4s ease-in 3.5s forwards;
}

.toast.ok {
    background: var(--accent-dark);
}

.toast.warn {
    background: var(--danger);
}

/* ===== Logowanie ===== */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-card {
    width: min(380px, 100%);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    animation: dialog-in 0.35s ease-out;
}

.login-card h1 {
    margin-top: 0;
    font-size: 1.5rem;
}

.login-card label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--muted);
}

.login-card input {
    width: 100%;
    font: inherit;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.login-card button {
    width: 100%;
    margin-top: 0.5rem;
    background: var(--accent);
    color: #fff;
}

.login-error,
.validation-message {
    color: var(--danger);
    margin: 0.25rem 0;
}

/* ===== Animacje ===== */
@keyframes card-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@keyframes pop-in {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: none; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translate(-50%, 20px); }
}

/* Osoby z włączonym "ogranicz ruch" w systemie dostają wersję bez animacji. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }

    /* Komunikat ma jednak zniknąć po chwili, tylko bez przesuwania. */
    .toast {
        animation: toast-out 0.01ms linear 3.5s forwards !important;
    }
}

/* ===== Telefon ===== */
@media (max-width: 520px) {
    .gift-list {
        grid-template-columns: 1fr;
    }

    .gift-actions button {
        flex: 1;
    }
}

/* ===== Błąd Blazora (z szablonu) ===== */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "Wystąpił błąd."
    }
