/*
    Favicon Converter – Utility Page
    ══════════════════════════════════════════════════
    Parte della sezione "Lab & Utility" di AttilioViscido.it

    DESIGN SYSTEM:
    Stesso design token block di img-converter e qrcode.
    Copia autonoma (non importa da sito principale).

    Palette:
      --primary:       #076FB7
      --primary-light: #2A8CD4
      --accent:        #D3B574
      --dark-bg:       #0D1117
      --card-bg:       #161B22
      --text-main:     #c9d1d9
*/

/* ── Design tokens ─────────────────────────────── */
:root {
    --primary: #076FB7;
    --primary-light: #2A8CD4;
    --accent: #D3B574;
    --accent-hover: #b89a57;
    --dark-bg: #0D1117;
    --card-bg: #161B22;
    --card-border: rgba(211, 181, 116, 0.15);
    --text-main: #c9d1d9;
    --text-white: #ffffff;
    --text-muted: #8b949e;
    --error: #f85149;
    --success: #3fb950;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ── Reset & base ───────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* ── Animated background ────────────────────────── */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(7, 111, 183, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(7, 111, 183, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

/*
    Sfere di luce sfocate (glow) con animazione fluttuante.
    glow-1 = sfera blu (in alto a destra)
    glow-2 = sfera oro/accent (in basso a sinistra, meno opaca)
*/
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
    animation: driftGlow 18s ease-in-out infinite alternate;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -80px;
    left: -80px;
    animation-delay: -9s;
    opacity: 0.1;
}

@keyframes driftGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-40px, 40px) scale(1.1);
    }

    100% {
        transform: translate(40px, -20px) scale(0.95);
    }
}

/* ── Compact Site Header ────────────────────────── */
/*
    Header ridotto (60px) che sostituisce il nav completo del sito.
    Mostra il link di ritorno alla home e un breadcrumb "Lab & Utility".
    DEVE essere presente in TUTTE le utility per coerenza di navigazione.
*/
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.site-header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

.back-link i {
    font-size: 0.9rem;
    opacity: 0.7;
    transition: var(--transition);
}

.back-link:hover i {
    transform: translateX(-3px);
    opacity: 1;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-white);
}

.logo-dot {
    color: var(--accent);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.breadcrumb i {
    color: var(--accent);
    font-size: 0.8rem;
}

/* ── Main Wrapper ───────────────────────────────── */
.app-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 580px;
    padding: 90px 20px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ── App Card ───────────────────────────────────── */
.app-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 36px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: slideUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── App Header ─────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-icon-wrap {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-size: 1.4rem;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(7, 111, 183, 0.4);
}

.app-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-white);
    line-height: 1.2;
}

.app-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.reset-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    cursor: pointer;
    padding: 9px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.reset-btn:hover {
    color: var(--accent);
    background: rgba(211, 181, 116, 0.1);
    border-color: var(--accent);
}

/* ── Drop Zone ──────────────────────────────────── */
/*
    Area di rilascio per il file sorgente.
    Cambia aspetto (bordo blu e glow) al mouseover e diventa
    oro (accent) durante il drag-over per feedback visivo immediato.
*/
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    text-align: center;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(7, 111, 183, 0.07);
    box-shadow: 0 0 0 4px rgba(7, 111, 183, 0.12);
}

.drop-zone.drag-over {
    border-style: solid;
    border-color: var(--accent);
    background: rgba(211, 181, 116, 0.05);
    box-shadow: 0 0 0 4px rgba(211, 181, 116, 0.1);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.drop-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(7, 111, 183, 0.2), rgba(42, 140, 212, 0.1));
    border: 1px solid rgba(7, 111, 183, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--primary-light);
    margin-bottom: 6px;
    transition: var(--transition);
}

.drop-zone.drag-over .drop-icon {
    background: rgba(211, 181, 116, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.1);
}

.drop-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-white);
}

.drop-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.browse-btn {
    pointer-events: all;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 22px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(7, 111, 183, 0.35);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.browse-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(7, 111, 183, 0.5);
}

.drop-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: 4px;
}

/* ── Controls Section ───────────────────────────── */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.controls-section.hidden {
    display: none;
}

/* ── Source Image Preview ───────────────────────── */
.preview-wrap {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.07);
    max-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#preview-img {
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    display: block;
}

.preview-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-badge i {
    color: var(--accent);
}

/* ── Format / Size Row ──────────────────────────── */
.format-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.format-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.format-label i {
    color: var(--primary-light);
}

/* ── Type Selector pills ────────────────────────── */
.type-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 5px;
    gap: 5px;
}

.type-selector input[type="radio"] {
    display: none;
}

.selector-btn {
    flex: 1;
    text-align: center;
    padding: 9px 16px;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
}

.type-selector input[type="radio"]:checked+.selector-btn {
    color: var(--text-white);
    background: var(--primary);
    box-shadow: 0 4px 15px rgba(7, 111, 183, 0.35);
}

/* ── Generate Button ────────────────────────────── */
.convert-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 6px 20px rgba(7, 111, 183, 0.35);
    letter-spacing: 0.02em;
}

.convert-btn:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(7, 111, 183, 0.5);
}

.convert-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(7, 111, 183, 0.3);
}

.convert-btn.generating {
    opacity: 0.75;
    cursor: wait;
}

.btn-icon {
    color: var(--accent);
    transition: var(--transition);
    font-size: 0.9rem;
}

.convert-btn:hover .btn-icon {
    transform: scale(1.3) rotate(10deg);
}

/* ── Result Section ─────────────────────────────── */
/*
    Visibile solo dopo la generazione della favicon.
    Contiene le preview box per ciascuna dimensione generata
    e la riga con i due pulsanti di azione (download + toggle).
*/
.result-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-section.hidden {
    display: none;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Favicon Preview Boxes ──────────────────────── */
/*
    Flex row con una box per ogni dimensione generata (16, 32, 48px).
    Lo sfondo a scacchi (.preview-box-canvas-wrap) permette di vedere
    correttamente le favicon con canale alpha.
*/
.favicon-previews {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.preview-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 80px;
}

.preview-box-canvas-wrap {
    background:
        /* checkerboard pattern */
        repeating-conic-gradient(rgba(255, 255, 255, 0.06) 0% 25%, transparent 0% 50%) 0 0 / 12px 12px,
        rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    width: 100%;
    aspect-ratio: 1;
    transition: var(--transition);
}

.preview-box-canvas-wrap:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(211, 181, 116, 0.12);
}

.preview-box canvas {
    image-rendering: pixelated;
    border-radius: 4px;
    max-width: 100%;
    max-height: 100%;
}

.preview-box-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

/* ── Action Row ─────────────────────────────────── */
/*
    Riga con i due pulsanti principali del risultato:
    - action-btn--download  : scarica il file .ico (colore accent/oro)
    - action-btn--toggle    : alternanza anteprima favicon nel tab del browser
*/
.action-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    min-width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 13px 20px;
    border: none;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.02em;
}

/* Download — accent gold */
.action-btn--download {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #0D1117;
    box-shadow: 0 6px 20px rgba(211, 181, 116, 0.3);
}

.action-btn--download:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(211, 181, 116, 0.45);
}

.action-btn--download:active {
    transform: translateY(1px);
    box-shadow: 0 3px 10px rgba(211, 181, 116, 0.25);
}

/*
    Toggle: aspetto ghost (grigio trasparente) a riposo;
    diventa blu con glow quando il preview è attivo (.active).
    L'icona pulsa leggermente per segnalare lo stato ON.
*/
.action-btn--toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.action-btn--toggle:hover {
    background: rgba(7, 111, 183, 0.1);
    border-color: var(--primary-light);
    color: var(--text-white);
    transform: translateY(-1px);
}

.action-btn--toggle.active {
    background: linear-gradient(135deg, rgba(7, 111, 183, 0.25), rgba(42, 140, 212, 0.15));
    border: 1px solid var(--primary);
    color: var(--primary-light);
    box-shadow: 0 0 14px rgba(7, 111, 183, 0.25);
}

.action-btn--toggle.active i {
    animation: pulseIcon 1.8s ease-in-out infinite;
}

@keyframes pulseIcon {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.9);
    }
}

/* ── Success Toast ──────────────────────────────── */
.success-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(63, 185, 80, 0.12);
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--success);
    animation: fadeIn 0.4s ease;
}

.success-toast.hidden {
    display: none;
}

.success-toast i {
    font-size: 1.1rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Privacy note ───────────────────────────────── */
.privacy-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    opacity: 0.6;
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.privacy-note i {
    color: var(--accent);
    opacity: 0.8;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 520px) {
    .app-card {
        padding: 24px 18px;
        border-radius: 20px;
        gap: 22px;
    }

    .app-header h1 {
        font-size: 1.35rem;
    }

    .site-header-inner {
        padding: 0 16px;
    }

    .breadcrumb {
        display: none;
    }

    .format-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .type-selector {
        width: 100%;
    }

    .action-row {
        flex-direction: column;
    }

    .action-btn {
        min-width: unset;
        width: 100%;
    }

    .favicon-previews {
        justify-content: center;
    }

    .preview-box {
        min-width: 70px;
        max-width: 100px;
    }
}