/* ═══════════════════════════════════════════════════════════════════
   Nikys Search — CSS v4  (Inter font · ocean logo · modern UI)
   ═══════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&display=swap');

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

:root {
    --ocean-a : #0a3d62;
    --ocean-b : #1e6fa8;
    --ocean-c : #38b2d4;
    --ocean-d : #74d7f0;
    --accent  : #1e6fa8;
    --bg      : #f0f4f8;
    --surface : #ffffff;
    --text    : #0d1b2a;
    --muted   : #607080;
    --radius  : 14px;
    --shadow  : 0 2px 12px rgba(14,50,80,.10);
    --shadow-h: 0 6px 24px rgba(14,50,80,.18);
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ══════════════════════════════════════════
   HERO — pagina iniziale
   ══════════════════════════════════════════ */
#hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(160deg, #071e34 0%, #0a3d62 40%, #1565a0 70%, #1e8bc3 100%);
}

/* ── Sfondo animato oceano ── */
.ocean-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.wave {
    position: absolute;
    bottom: -2px;
    width: 200%;
    height: 160px;
    border-radius: 50% 50% 0 0 / 80px 80px 0 0;
    opacity: .18;
    animation: waveMove linear infinite;
}
.wave1 { background: #38b2d4; animation-duration: 10s; left: -50%; }
.wave2 { background: #74d7f0; animation-duration: 14s; bottom: 20px; left: -30%; opacity:.12; }
.wave3 { background: #0a3d62; animation-duration: 18s; bottom: -10px; left: -10%; opacity:.22; }

@keyframes waveMove {
    0%   { transform: translateX(0) scaleY(1); }
    50%  { transform: translateX(15%) scaleY(1.08); }
    100% { transform: translateX(0) scaleY(1); }
}

/* bolle fluttuanti */
.bubbles { position:absolute; inset:0; }
.bubbles span {
    position: absolute;
    bottom: -40px;
    border-radius: 50%;
    background: rgba(255,255,255,.07);
    animation: rise linear infinite;
}
.bubbles span:nth-child(1){width:18px;height:18px;left:8%;animation-duration:9s;}
.bubbles span:nth-child(2){width:28px;height:28px;left:18%;animation-duration:13s;animation-delay:2s;}
.bubbles span:nth-child(3){width:12px;height:12px;left:30%;animation-duration:8s;animation-delay:4s;}
.bubbles span:nth-child(4){width:22px;height:22px;left:45%;animation-duration:11s;animation-delay:1s;}
.bubbles span:nth-child(5){width:14px;height:14px;left:60%;animation-duration:10s;animation-delay:3s;}
.bubbles span:nth-child(6){width:32px;height:32px;left:72%;animation-duration:15s;animation-delay:0.5s;}
.bubbles span:nth-child(7){width:10px;height:10px;left:82%;animation-duration:7s;animation-delay:5s;}
.bubbles span:nth-child(8){width:20px;height:20px;left:92%;animation-duration:12s;animation-delay:2.5s;}

@keyframes rise {
    0%   { transform: translateY(0) scale(1); opacity:.6; }
    100% { transform: translateY(-100vh) scale(1.4); opacity:0; }
}

/* ── Hero inner ── */
.hero-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
    padding: 40px 20px;
    width: 100%;
    max-width: 700px;
    animation: heroFadeIn .9s ease both;
}

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

/* ── Logo hero — oceano dentro le lettere ── */
.hero-logo-wrap {
    text-align: center;
    cursor: pointer;
}

.hero-logo {
    font-size: clamp(52px, 12vw, 96px);
    font-weight: 900;
    letter-spacing: -2px;
    line-height: 1;

    /* Oceano dentro il testo */
    background:
        radial-gradient(ellipse at 30% 60%, #74d7f0 0%, transparent 50%),
        radial-gradient(ellipse at 70% 40%, #38b2d4 0%, transparent 50%),
        linear-gradient(180deg,
            #e8f8ff 0%,
            #74d7f0 15%,
            #38b2d4 30%,
            #1e6fa8 55%,
            #0a3d62 80%,
            #071e34 100%
        );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;

    /* ombra leggera per profondità */
    filter: drop-shadow(0 4px 24px rgba(56,178,212,.45));
    transition: filter .3s, letter-spacing .3s;
    user-select: none;
}

.hero-logo-wrap:hover .hero-logo {
    filter: drop-shadow(0 6px 32px rgba(116,215,240,.7));
    letter-spacing: -1px;
}

.hero-sub {
    font-size: 14px;
    color: rgba(255,255,255,.65);
    margin-top: 10px;
    letter-spacing: .3px;
}

/* ── Search bar hero ── */
.hero-search-wrap {
    width: 100%;
    max-width: 580px;
}

.hero-search-bar {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1.5px solid rgba(255,255,255,.28);
    border-radius: 40px;
    padding: 14px 20px;
    gap: 12px;
    transition: background .25s, box-shadow .25s, border-color .25s;
}

.hero-search-bar:focus-within {
    background: rgba(255,255,255,.22);
    border-color: rgba(116,215,240,.8);
    box-shadow: 0 0 0 4px rgba(116,215,240,.18), 0 8px 32px rgba(0,0,0,.25);
}

.hero-search-bar .search-icon { color: rgba(255,255,255,.7); flex-shrink:0; }

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 17px;
    font-family: inherit;
    background: transparent;
    color: #fff;
    caret-color: #74d7f0;
}
#search-input::placeholder { color: rgba(255,255,255,.5); }

#clear-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,.6);
    font-size: 18px;
    display: none;
    padding: 0 4px;
    transition: color .15s;
    line-height: 1;
}
#clear-btn:hover { color: #fff; }
#clear-btn.visible { display: block; }

/* ══════════════════════════════════════════
   HEADER — visibile solo dopo la ricerca
   ══════════════════════════════════════════ */
#main-header {
    display: none;           /* nascosto di default; JS lo mostra */
    background: rgba(7,30,52,.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 20px 0;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 16px rgba(0,0,0,.3);
    animation: slideDown .3s ease both;
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity:0; }
    to   { transform: translateY(0);    opacity:1; }
}

#main-header.visible { display: block; }

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 10px;
}

/* Logo piccolo a sinistra — stesso effetto oceano del hero */
.header-logo {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -0.5px;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
    cursor: pointer;
    background:
        linear-gradient(180deg,
            #e8f8ff 0%,
            #74d7f0 20%,
            #38b2d4 45%,
            #1e6fa8 70%,
            #0a3d62 100%
        );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 1px 6px rgba(56,178,212,.5));
    transition: filter .2s, font-size .2s;
}
.header-logo:hover {
    filter: drop-shadow(0 2px 10px rgba(116,215,240,.8));
}

/* Search bar header compatta */
.search-bar {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(255,255,255,.10);
    border: 1.5px solid rgba(255,255,255,.18);
    border-radius: 28px;
    padding: 9px 16px;
    gap: 9px;
    transition: .2s;
    max-width: 600px;
}
.search-bar svg { color: rgba(255,255,255,.55); flex-shrink:0; }
.search-bar:focus-within {
    background: rgba(255,255,255,.18);
    border-color: rgba(116,215,240,.7);
    box-shadow: 0 0 0 3px rgba(116,215,240,.14);
}

#search-input-header {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    background: transparent;
    color: #fff;
    caret-color: #74d7f0;
}
#search-input-header::placeholder { color: rgba(255,255,255,.45); }

#clear-btn-header {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,.5);
    font-size: 16px;
    display: none;
    padding: 0 4px;
    line-height: 1;
    transition: color .15s;
}
#clear-btn-header:hover { color: #fff; }
#clear-btn-header.visible { display: block; }

/* ── Tabs ── */
.tabs {
    display: flex;
    max-width: 1000px;
    margin: 0 auto;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display:none; }

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 9px 18px;
    font-size: 13px;
    font-family: inherit;
    color: rgba(255,255,255,.55);
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color .15s, border-color .15s;
    margin-bottom: -1px;
}
.tab-btn:hover { color: #74d7f0; }
.tab-btn.active { color: #74d7f0; border-bottom-color: #74d7f0; font-weight: 600; }

/* ── BANNER ── */
#site-banner {
    display: none;
    width: 100%;
    text-align: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
}

/* ══════════════════════════════════════════
   MAIN / RESULTS
   ══════════════════════════════════════════ */
main {
    max-width: 1000px;
    margin: 24px auto;
    padding: 0 16px;
}

/* ── Status ── */
#status {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 14px;
    min-height: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Spinner moderno (onda) ── */
.spinner {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    height: 18px;
}
.spinner span {
    display: block;
    width: 4px;
    border-radius: 2px;
    background: var(--accent);
    animation: barPulse .9s ease-in-out infinite;
}
.spinner span:nth-child(1){height:8px;  animation-delay:0s;}
.spinner span:nth-child(2){height:14px; animation-delay:.15s;}
.spinner span:nth-child(3){height:10px; animation-delay:.3s;}
.spinner span:nth-child(4){height:16px; animation-delay:.45s;}
.spinner span:nth-child(5){height:7px;  animation-delay:.6s;}

@keyframes barPulse {
    0%,100%{ transform:scaleY(.5); opacity:.5; }
    50%    { transform:scaleY(1);  opacity:1;  }
}

/* ── Web cards ── */
.result-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border-left: 3px solid transparent;
    transition: box-shadow .2s, transform .2s, border-color .2s;
    animation: cardIn .25s ease both;
}
.result-card:hover {
    box-shadow: var(--shadow-h);
    border-left-color: var(--accent);
    transform: translateX(3px);
}
@keyframes cardIn {
    from { opacity:0; transform:translateY(8px); }
    to   { opacity:1; transform:translateY(0);   }
}

.result-title a {
    text-decoration: none;
    color: #1a3a6e;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}
.result-title a:hover { text-decoration: underline; color: var(--accent); }
.result-url {
    font-size: 12px;
    color: #2a7a3a;
    margin: 3px 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-desc {
    font-size: 14px;
    color: #4d5156;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Skeleton loader ── */
.skeleton {
    background: linear-gradient(90deg, #e8edf2 25%, #f5f7fa 50%, #e8edf2 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}
.sk-line { height:14px; margin-bottom:8px; }
.sk-url  { width:35%; height:10px; margin-bottom:10px; }
.sk-t1   { width:75%; }
.sk-t2   { width:90%; }
.sk-t3   { width:60%; }

/* ── Foto grid ── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.photo-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #dce4ea;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    animation: cardIn .3s ease both;
}
.photo-item:hover { transform: scale(1.05); box-shadow: var(--shadow-h); }
.photo-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}
.photo-caption {
    font-size: 11px;
    color: #555;
    padding: 6px 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--surface);
}

/* ── Source badge (crawler) ── */
.src-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 8px;
    margin-left: 8px;
    vertical-align: middle;
    letter-spacing: .3px;
    opacity: .9;
}
.badge-yahoo { background: #6001d2; color: #fff; }

/* Badge per fonte foto */
.photo-badge {
    position: absolute;
    top: 7px;
    right: 7px;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    pointer-events: none;
    letter-spacing: .3px;
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
    backdrop-filter: blur(4px);
}
.photo-badge[data-badge="Flickr"]      { background: #ff0084; }
.photo-badge[data-badge="Openverse"]   { background: #c00; }
.photo-badge[data-badge="NASA"]        { background: #0b3d91; }
.photo-badge[data-badge="iNaturalist"] { background: #4a9400; }
.photo-badge[data-badge="Commons"]     { background: #3366cc; }
.photo-badge[data-badge="Europeana"]   { background: #d4900a; color:#fff; }
.photo-badge:not([data-badge])         { background: rgba(0,0,0,.55); }

/* ── Video grid ── */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.video-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow .2s, transform .2s;
    animation: cardIn .3s ease both;
}
.video-card:hover { box-shadow: var(--shadow-h); transform: translateY(-3px); }
.video-thumb { width:100%; height:158px; object-fit:cover; background:#dce4ea; display:block; }
.video-info  { padding:13px; }
.video-title a {
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.video-title a:hover { color: var(--accent); }
.video-meta  { font-size:12px; color:var(--muted); margin-top:5px; }
.video-desc  {
    font-size:12px; color:#4d5156; margin-top:5px;
    display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}

/* ── News cards ── */
.news-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 14px;
    transition: box-shadow .2s;
    animation: cardIn .25s ease both;
}
.news-card:hover { box-shadow: var(--shadow-h); }
.news-img {
    width: 100px;
    height: 68px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #dce4ea;
}
.news-body    { flex:1; min-width:0; }
.news-title a {
    text-decoration: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.news-title a:hover { color: var(--accent); }
.news-meta { font-size:12px; color:var(--muted); margin-top:3px; }
.news-desc {
    font-size:13px; color:#4d5156; margin-top:5px;
    display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}

/* ── Info cards ── */
.info-card {
    background: linear-gradient(135deg, #e8f4fd, #f0f9ff);
    border: 1px solid #b8d9f5;
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 12px;
    animation: cardIn .25s ease both;
}
.info-card h3 { color: #1a4a8a; font-size: 16px; margin-bottom: 8px; }
.info-card p  { color: #374151; font-size: 14px; line-height: 1.7; }
.info-tags    { display:flex; gap:6px; flex-wrap:wrap; margin-top:10px; }
.info-tag     { background:#dbeafe; color:#1d4ed8; font-size:11px; padding:3px 9px; border-radius:12px; }
.info-link    { display:inline-block; margin-top:8px; font-size:13px; color:var(--accent); text-decoration:none; }
.info-link:hover { text-decoration:underline; }
.info-section-title {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    margin: 18px 0 10px;
}

/* ── Load more ── */
#load-more {
    display: none;
    width: 100%;
    padding: 13px;
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 12px;
    transition: background .2s, color .2s, transform .15s;
}
#load-more:hover  { background: var(--accent); color:#fff; transform:translateY(-1px); }
#load-more.visible{ display:block; }

/* ── Empty ── */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 15px;
}

/* ── Lightbox ── */
#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5,20,40,.92);
    z-index: 999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    backdrop-filter: blur(6px);
}
#lightbox.open    { display:flex; }
#lightbox img     { max-width:90vw; max-height:80vh; border-radius:10px; object-fit:contain; box-shadow:0 12px 48px rgba(0,0,0,.6); }
#lb-title         { color:#cde; font-size:13px; margin-top:14px; max-width:80vw; text-align:center; }
#lb-close         { position:absolute; top:18px; right:22px; background:none; border:none; color:#fff; font-size:32px; cursor:pointer; opacity:.75; line-height:1; }
#lb-close:hover   { opacity:1; }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .hero-logo       { letter-spacing: -1px; }
    .header-logo     { font-size: 18px; }
    .video-grid      { grid-template-columns: 1fr 1fr; }
    .news-img        { display: none; }
    main             { margin-top: 16px; }
}

/* ══════════════════════════════════════════
   STORAGE BAR — indicatore save_crawler
   ══════════════════════════════════════════ */
#storage-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
    background: rgba(30,111,168,.07);
    border: 1px solid rgba(30,111,168,.15);
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: 12px;
    min-height: 32px;
    transition: opacity .3s;
}
#storage-bar:empty { display: none; }
#storage-bar b     { color: var(--accent); }
.sb-icon           { font-size: 14px; }
.sb-extra          { background: #dcfce7; color: #166534; padding: 1px 8px; border-radius: 8px; font-weight: 600; }
.sb-pct            { margin-left: auto; color: #94a3b8; font-size: 11px; }

/* ══════════════════════════════════════════
   SOURCE BADGES — crawler engines + cache
   ══════════════════════════════════════════ */
.src-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    margin-left: 8px;
    vertical-align: middle;
    letter-spacing: .3px;
}
.badge-cache   { background: #0d9488; color: #fff; }   /* verde acqua  */
.badge-ddg     { background: #de5833; color: #fff; }   /* arancio DDG  */
.badge-yahoo   { background: #6001d2; color: #fff; }   /* viola Yahoo  */
.badge-bing    { background: #008272; color: #fff; }   /* verde Bing   */
.badge-crawler { background: #475569; color: #fff; }   /* grigio scuro */

/* leggero highlight sulle card con risultato crawler */
.result-card.has-crawler {
    border-left-color: rgba(30,111,168,.35);
}
