@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --bg: #0a0a0c;
    --bg-elevated: #111319;
    --border: #1f2430;
    --text: #cfd8e3;
    --text-dim: #6b7280;
    --accent: #00d9ff;
    --accent-dim: #0a4a56;
    --danger: #e74c3c;
    --danger-dim: #3a1a1a;
    --success: #2ecc71;
    --success-dim: #123a1e;
    --radius: 6px;
    --font-mono: 'JetBrains Mono', 'Share Tech Mono', ui-monospace, monospace;
    --font-display: 'Share Tech Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.5;
}

body {
    background-image:
        radial-gradient(circle at 20% 0%, rgba(0,217,255,0.06), transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(0,217,255,0.04), transparent 45%);
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-dim); color: var(--accent); }

/* Focus visibile per accessibilità */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============ LAYOUT ============ */
.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 4rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: .75rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .85rem;
    color: var(--text-dim);
}

.topbar-user strong { color: var(--text); }

.topbar-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: .85rem;
}

/* ============ LOGO GLITCH ============ */
.logo {
    position: relative;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--text);
    display: inline-block;
    user-select: none;
}

.logo .x { color: var(--accent); }

.logo-block {
    display: inline-flex;
    flex-direction: column;
    gap: .15rem;
}

.claim {
    font-size: .65rem;
    color: var(--text-dim);
    letter-spacing: .12em;
    text-transform: uppercase;
}

.glitch {
    position: relative;
    display: inline-block;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    overflow: hidden;
    background: var(--bg);
}

.glitch::before {
    color: #ff3b6b;
    animation: glitch-1 6s infinite linear;
    clip-path: inset(0 0 0 0);
}

.glitch::after {
    color: var(--accent);
    animation: glitch-2 6s infinite linear;
    clip-path: inset(0 0 0 0);
}

@keyframes glitch-1 {
    0%, 92%, 100% { clip-path: inset(0 0 0 0); transform: translate(0, 0); opacity: 0; }
    92.5% { clip-path: inset(10% 0 60% 0); transform: translate(-2px, 0); opacity: .8; }
    93.5% { clip-path: inset(60% 0 5% 0); transform: translate(2px, 0); opacity: .8; }
    94.5% { clip-path: inset(30% 0 40% 0); transform: translate(-1px, 0); opacity: .8; }
    95%   { opacity: 0; }
}

@keyframes glitch-2 {
    0%, 90%, 100% { clip-path: inset(0 0 0 0); transform: translate(0, 0); opacity: 0; }
    90.5% { clip-path: inset(70% 0 5% 0); transform: translate(2px, 0); opacity: .8; }
    91.5% { clip-path: inset(15% 0 55% 0); transform: translate(-2px, 0); opacity: .8; }
    92.5% { clip-path: inset(45% 0 20% 0); transform: translate(1px, 0); opacity: .8; }
    93%   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .glitch::before, .glitch::after { animation: none; display: none; }
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}

.project-card {
    display: block;
    color: var(--text);
    position: relative;
}

.project-card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: var(--radius);
}

.project-card-delete {
    position: absolute;
    top: .6rem;
    right: .6rem;
    z-index: 2;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    opacity: 0;
    transition: opacity .15s, color .15s, border-color .15s, background .15s;
}

.project-card:hover .project-card-delete,
.project-card-delete:focus-visible {
    opacity: 1;
}

.project-card-delete:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-dim);
    text-decoration: none;
}

/* su touch (niente hover) resta visibile, sobria, per essere comunque raggiungibile */
@media (hover: none) {
    .project-card-delete { opacity: .55; }
}

.project-card:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.project-card h3 {
    margin: 0 0 .35rem;
    font-size: 1rem;
    color: var(--accent);
}

.project-card .meta {
    font-size: .78rem;
    color: var(--text-dim);
}

/* ============ TYPOGRAPHY ============ */
h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--text);
}

h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; margin-top: 2rem; }

.eyebrow {
    font-size: .7rem;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: .3rem;
}

.text-dim { color: var(--text-dim); }
.small { font-size: .8rem; }

/* ============ FORMS ============ */
label {
    display: block;
    font-size: .75rem;
    color: var(--text-dim);
    letter-spacing: .05em;
    text-transform: uppercase;
    margin-bottom: .3rem;
}

input[type=text], input[type=email], input[type=password], input[type=number], select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .65rem .75rem;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .9rem;
}

input:focus, select:focus { border-color: var(--accent); }

.field { margin-bottom: 1rem; }

.form-row {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}
.form-row .field { flex: 1; min-width: 140px; }

input[type=file] {
    width: 100%;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: .85rem;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: var(--radius);
    padding: .6rem 1.1rem;
    font-family: var(--font-mono);
    font-size: .85rem;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: var(--accent-dim);
    text-decoration: none;
}

.btn-solid {
    background: var(--accent);
    color: #001217;
    font-weight: 700;
}
.btn-solid:hover { background: #33e1ff; }

.btn-danger {
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover { background: var(--danger-dim); }

.btn-ghost {
    border-color: var(--border);
    color: var(--text-dim);
}
.btn-ghost:hover { background: var(--bg-elevated); border-color: var(--text-dim); }

.btn-sm { padding: .35rem .7rem; font-size: .75rem; }

/* ============ TABLE / FILE LIST ============ */
.file-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}

.file-group-head {
    padding: .75rem 1rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .85rem;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: .75rem;
    flex-wrap: wrap;
}
.file-row:last-child { border-bottom: none; }

.file-row .name {
    flex: 1;
    min-width: 160px;
    word-break: break-word;
}

.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 99px;
    font-size: .68rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    font-weight: 700;
}
.badge-ultimo { background: var(--success-dim); color: var(--success); }
.badge-penultimo { background: #2a2a2a; color: var(--text-dim); }

/* ============ NUOVA VERSIONE (details/summary) ============ */
.new-version {
    padding: .5rem 1rem 1rem;
    border-top: 1px dashed var(--border);
}
.new-version summary {
    cursor: pointer;
    color: var(--accent);
    font-size: .8rem;
    padding: .6rem 0 .2rem;
    list-style: none;
}
.new-version summary::-webkit-details-marker { display: none; }
.new-version summary:hover { text-decoration: underline; }

.rename-inline summary {
    cursor: pointer;
    color: var(--text-dim);
    font-size: .8rem;
    list-style: none;
}
.rename-inline summary:hover { color: var(--accent); }
.rename-inline summary::-webkit-details-marker { display: none; }

/* ============ MESSAGES ============ */
.msg {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: .85rem;
    border: 1px solid;
}
.msg-ok { background: var(--success-dim); color: var(--success); border-color: var(--success); }
.msg-err { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }

/* ============ LOGIN ============ */
.center-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-box {
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.user-pick {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin-top: 1.5rem;
}

.user-pick .btn { justify-content: center; padding: .8rem; font-size: .95rem; }

.scanline {
    position: relative;
}
.scanline::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0,217,255,0.02),
        rgba(0,217,255,0.02) 1px,
        transparent 1px,
        transparent 3px
    );
}

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
    .wrap { padding: 1rem .9rem 3rem; }
    .topbar { padding: .85rem 1rem; }
    .grid { grid-template-columns: 1fr; }
    .file-row { flex-direction: column; align-items: flex-start; }
}
