/* =====================================================================
   Sardynia 2026 - galeria 50. urodzin Wioli
   Paleta srodziemnomorska: piasek, turkus, terakota, krem.
   ===================================================================== */

:root {
    /* piasek */
    --sand-50:   #fdf8ed;
    --sand-100:  #faf0d7;
    --sand-200:  #f3deb1;
    --sand-300:  #e8c887;
    --sand-500:  #d4a460;

    /* morze / turkus */
    --aqua-100:  #ccfbf1;
    --aqua-300:  #5eead4;
    --aqua-500:  #14b8a6;
    --aqua-700:  #0f766e;
    --sea-900:   #134e4a;

    /* terakota */
    --terra-500: #c2410c;
    --terra-600: #9a3412;

    /* tekst i tlo */
    --cream:     #fffaf0;
    --ink:       #2c1a0c;
    --ink-soft:  #5b4530;
    --line:      rgba(44, 26, 12, 0.12);

    --serif: "Cormorant Garamond", "Playfair Display", Georgia, serif;
    --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --radius: 14px;
    --shadow: 0 10px 40px -10px rgba(19, 78, 74, 0.25);
    --shadow-hover: 0 18px 60px -10px rgba(19, 78, 74, 0.45);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* HTML 'hidden' musi wygrac z naszymi 'display: grid/flex/...' */
[hidden] { display: none !important; }

html, body {
    background: var(--sand-50);
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

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

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* =====================================================================
   EKRAN LOGOWANIA
   ===================================================================== */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow: hidden;
    background: linear-gradient(160deg, #0f766e 0%, #134e4a 45%, #1e3a5f 100%);
}

.login-bg {
    position: absolute;
    inset: -10%;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 30%, rgba(94, 234, 212, 0.35) 0%, transparent 45%),
        radial-gradient(circle at 80% 70%, rgba(212, 164, 96, 0.30) 0%, transparent 45%),
        radial-gradient(circle at 50% 100%, rgba(194, 65, 12, 0.20) 0%, transparent 60%);
    animation: drift 24s ease-in-out infinite alternate;
    filter: blur(40px);
}

@keyframes drift {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(2%, -3%) scale(1.05); }
    100% { transform: translate(-2%, 2%) scale(1.02); }
}

.login-card {
    position: relative;
    background: rgba(255, 250, 240, 0.95);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    padding: 48px 44px;
    border-radius: 24px;
    width: min(100%, 420px);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.7);
    text-align: center;
    animation: rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-size: 11px;
    color: var(--aqua-700);
    font-weight: 500;
    margin-bottom: 14px;
}

.login-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(38px, 6vw, 52px);
    line-height: 1;
    color: var(--ink);
}
.login-title .sep {
    color: var(--terra-500);
    margin: 0 4px;
    font-weight: 400;
}

.login-sub {
    font-family: var(--serif);
    font-size: 20px;
    color: var(--ink-soft);
    margin: 6px 0 18px;
}

.login-notice {
    display: inline-block;
    margin: 0 auto 28px;
    padding: 8px 14px;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--terra-500);
    background: rgba(234, 88, 12, 0.08);
    border: 1px solid rgba(234, 88, 12, 0.25);
    border-radius: 999px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    font-family: inherit;
    color: var(--ink);
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.login-input:focus {
    outline: none;
    border-color: var(--aqua-500);
    background: white;
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.15);
}
.login-input::placeholder { color: rgba(91, 69, 48, 0.5); }

.login-btn {
    padding: 14px;
    background: linear-gradient(135deg, var(--aqua-500), var(--aqua-700));
    color: white;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    box-shadow: 0 6px 20px -4px rgba(15, 118, 110, 0.5);
}
.login-btn:hover  { transform: translateY(-1px); box-shadow: 0 10px 28px -4px rgba(15, 118, 110, 0.6); filter: brightness(1.05); }
.login-btn:active { transform: translateY(0); }

.login-error {
    color: var(--terra-500);
    font-size: 13px;
    margin-top: 6px;
    animation: shake 0.4s;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}

.login-screen.fading {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.7s ease;
}

/* =====================================================================
   HERO / NAGLOWEK
   ===================================================================== */
.gallery-screen { opacity: 0; animation: fadeIn 1s ease 0.1s forwards; }
@keyframes fadeIn { to { opacity: 1; } }

.hero {
    position: relative;
    min-height: 92vh;
    min-height: 92svh;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--cream);
    padding: 80px 24px 60px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(19, 78, 74, 0.55) 0%, rgba(19, 78, 74, 0.7) 100%),
        radial-gradient(circle at 30% 20%, var(--aqua-500) 0%, var(--sea-900) 70%);
}

/* dekoracyjne kola - faktura wody / piasku */
.hero::before, .hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
}
.hero::before {
    width: 50vw; height: 50vw;
    background: radial-gradient(circle, rgba(94, 234, 212, 0.55), transparent 70%);
    top: -10vw; left: -10vw;
}
.hero::after {
    width: 45vw; height: 45vw;
    background: radial-gradient(circle, rgba(212, 164, 96, 0.55), transparent 70%);
    bottom: -10vw; right: -10vw;
}

.hero-inner {
    position: relative;
    z-index: 2;
    max-width: 900px;
    animation: heroRise 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both;
}

@keyframes heroRise {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.5em;
    font-size: 12px;
    font-weight: 500;
    color: var(--sand-200);
    margin-bottom: 24px;
}

.hero-title {
    font-family: var(--serif);
    font-weight: 500;
    line-height: 1;
}
.hero-title .line-1 {
    display: block;
    font-size: clamp(56px, 11vw, 140px);
    letter-spacing: -0.01em;
}
.hero-title .line-2 {
    display: block;
    font-size: clamp(24px, 4vw, 44px);
    color: var(--sand-200);
    margin-top: 18px;
}
.hero-title em {
    font-style: italic;
    color: var(--sand-100);
}

.hero-sub {
    margin-top: 28px;
    color: var(--sand-200);
    font-size: 14px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.hero-scroll {
    position: absolute;
    bottom: 30px; left: 50%;
    transform: translateX(-50%);
    width: 24px; height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 14px;
    z-index: 2;
}
.hero-scroll span {
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 4px; height: 8px;
    background: var(--cream);
    border-radius: 2px;
    animation: scrollDot 1.8s ease-in-out infinite;
}
@keyframes scrollDot {
    0%   { transform: translate(-50%, 0);   opacity: 1; }
    100% { transform: translate(-50%, 14px); opacity: 0; }
}

/* =====================================================================
   GALERIA - masonry (grid-row-span obliczane w JS)
   ===================================================================== */
.gallery {
    --gap: 14px;
    padding: 60px clamp(16px, 4vw, 60px);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    grid-auto-rows: 8px;
    gap: var(--gap);
    max-width: 1900px;
    margin: 0 auto;
}

@media (min-width: 900px) {
    .gallery { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
@media (min-width: 1400px) {
    .gallery { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

.gallery-item {
    position: relative;
    grid-row-end: span 30; /* nadpisywane przez JS po zaladowaniu obrazka */
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--sand-200);
    cursor: zoom-in;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    transition: opacity 0.6s ease, transform 0.6s ease,
                box-shadow 0.35s ease;
}
.gallery-item.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.gallery-item:hover {
    box-shadow: var(--shadow-hover);
}
.gallery-item:hover img,
.gallery-item:hover .video-thumb video {
    transform: scale(1.04);
}

.gallery-item img,
.gallery-item .video-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
    background: var(--sand-100);
}

/* Overlay z ikona play dla wideo */
.video-thumb {
    position: relative;
    width: 100%;
    height: 100%;
}
.video-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.35) 100%);
    pointer-events: none;
}
.play-icon {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 64px; height: 64px;
    border-radius: 50%;
    background: rgba(255, 250, 240, 0.92);
    color: var(--sea-900);
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    z-index: 2;
    transition: transform 0.25s ease, background 0.25s ease;
    pointer-events: none;
}
.gallery-item:hover .play-icon {
    transform: translate(-50%, -50%) scale(1.1);
    background: var(--cream);
}
.play-icon svg { width: 22px; height: 22px; margin-left: 4px; }

/* loader podczas ladowania */
.gallery-item .ph {
    position: absolute; inset: 0;
    background: linear-gradient(110deg, var(--sand-100) 30%, var(--sand-200) 50%, var(--sand-100) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.gallery-item img.loaded + .ph,
.gallery-item video.loaded ~ .ph { display: none; }

/* =====================================================================
   STOPKA
   ===================================================================== */
.site-foot {
    text-align: center;
    padding: 60px 24px 40px;
    color: var(--ink-soft);
    font-family: var(--serif);
    font-style: italic;
    font-size: 18px;
}

/* =====================================================================
   LIGHTBOX
   ===================================================================== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(12, 22, 28, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    /* minmax(0, 1fr) - bez tego stage rozciaga sie pod naturalny rozmiar obrazu */
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    animation: fadeIn 0.25s ease;
}

.lb-stage {
    display: grid;
    place-items: center;
    padding: 70px 80px 20px;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    touch-action: pan-y;
}
.lb-stage img,
.lb-stage video {
    /* Viewport-unit fallback - zawsze miesci sie na ekranie. */
    max-width: calc(100vw - 160px);
    max-height: calc(100vh - 140px);
    width: auto; height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    animation: lbIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes lbIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.lb-close, .lb-prev, .lb-next {
    position: absolute;
    color: rgba(255, 250, 240, 0.85);
    width: 52px; height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.2s, color 0.2s, transform 0.2s;
    z-index: 3;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--cream);
}
.lb-close { top: 16px; right: 16px; font-size: 30px; }
.lb-prev  { top: 50%; left: 16px;  transform: translateY(-50%); }
.lb-next  { top: 50%; right: 16px; transform: translateY(-50%); }
.lb-prev:hover { transform: translateY(-50%) translateX(-3px); }
.lb-next:hover { transform: translateY(-50%) translateX(3px); }

.lb-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px 22px;
    color: rgba(255, 250, 240, 0.7);
    font-size: 13px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

@media (max-width: 640px) {
    .lb-stage { padding: 60px 16px 16px; }
    .lb-stage img, .lb-stage video {
        max-width: calc(100vw - 32px);
        max-height: calc(100vh - 130px);
    }
    .lb-prev, .lb-next { width: 44px; height: 44px; font-size: 18px; }
    .lb-prev { left: 8px; }
    .lb-next { right: 8px; }
    .lb-meta { padding: 10px 16px 18px; font-size: 11px; }
}

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


/* =====================================================================
   TRYB EDYCJI (tymczasowy - aktywowany przez ?edit=1)
   Mozna usunac caly blok gdy "remont" sie zakonczy.
   ===================================================================== */

/* Przycisk X na zdjeciu - domyslnie ukryty, widoczny tylko w trybie edit */
.item-del-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(194, 65, 12, 0.92);   /* terra-500 z alpha */
    color: #fff;
    font-size: 22px;
    line-height: 1;
    font-weight: 300;
    cursor: pointer;
    display: none;                         /* domyslnie schowany */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.15s ease, background 0.15s ease;
    z-index: 5;
    padding: 0 0 2px;                      /* mikro-korekta optycznego centra */
}
.item-del-btn:hover {
    background: var(--terra-600);
    transform: scale(1.1);
}
body.edit-mode .item-del-btn {
    display: inline-flex;
    animation: editBtnIn 0.25s ease;
}
@keyframes editBtnIn {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

/* Animacja znikania ukrywanego zdjecia */
.gallery-item.removing {
    transition: opacity 0.28s ease, transform 0.28s ease;
    opacity: 0;
    transform: scale(0.85);
    pointer-events: none;
}

/* Floating panel w prawym dolnym rogu */
.edit-panel {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 150;
    width: 280px;
    background: rgba(255, 250, 240, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 20px 50px -15px rgba(19, 78, 74, 0.4);
    overflow: hidden;
    font-family: var(--sans);
    transition: width 0.25s ease, height 0.25s ease;
}
.edit-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--aqua-700);
    color: #fff;
}
.edit-panel-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 600;
}
.edit-panel-min {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
}
.edit-panel-min:hover { background: rgba(255,255,255,0.15); }

.edit-panel-body {
    padding: 14px 14px 16px;
}
.edit-panel-count {
    font-size: 14px;
    color: var(--ink-soft);
    margin-bottom: 10px;
}
.edit-panel-count #edit-count {
    color: var(--terra-500);
    font-weight: 600;
    font-size: 18px;
}

.edit-btn {
    display: block;
    width: 100%;
    padding: 9px 12px;
    margin-top: 8px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.edit-btn:hover { background: var(--sand-50); }
.edit-btn:active { transform: translateY(1px); }
.edit-btn-export {
    background: var(--aqua-500);
    color: #fff;
    border-color: var(--aqua-500);
}
.edit-btn-export:hover { background: var(--aqua-700); }
.edit-btn-restore {
    background: transparent;
    color: var(--terra-500);
    border-color: rgba(194, 65, 12, 0.4);
}
.edit-btn-restore:hover {
    background: rgba(194, 65, 12, 0.08);
}

.edit-panel-hint {
    margin-top: 12px;
    font-size: 11px;
    color: var(--ink-soft);
    opacity: 0.75;
    line-height: 1.5;
}

.edit-panel.collapsed .edit-panel-body { display: none; }
.edit-panel.collapsed { width: auto; }

/* Lightbox - przycisk usuwania (obok zamknij) */
.lb-delete {
    position: absolute;
    top: 16px;
    right: 80px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(194, 65, 12, 0.88);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 220;
    transition: background 0.15s ease, transform 0.15s ease;
}
.lb-delete:hover { background: var(--terra-600); transform: scale(1.08); }
body.edit-mode .lb-delete { display: inline-flex; }

/* Maly badge informacyjny w naglowku galerii w trybie edycji */
body.edit-mode .hero::after {
    content: "TRYB EDYCJI - kliknij X na zdjeciu aby je oznaczyc do usuniecia";
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(194, 65, 12, 0.92);
    color: #fff;
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 14px;
    border-radius: 999px;
    z-index: 10;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
.hero { position: relative; }

@media (max-width: 640px) {
    .edit-panel { width: calc(100vw - 24px); bottom: 12px; right: 12px; }
    .lb-delete { right: 64px; width: 38px; height: 38px; font-size: 16px; }
}
