/* ════════════════════════════════════════
   TONINO BARBUTO — Foglio di stile
   ════════════════════════════════════════ */

:root {
  --ink:        #1c1917;
  --ink-soft:   #57534e;
  --ink-muted:  #a8a29e;
  --paper:      #fafaf8;
  --paper-card: #ffffff;
  --line:       #e7e5e4;
  --accent:     #b45309;
  --accent-dk:  #92400e;
  --accent-lt:  #fef3c7;
  --private:    #1e3a5f;
  --radius:     12px;
  --max:        960px;
  --font-serif: 'Lora', Georgia, serif;
  --font-sans:  'Inter', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: inherit; text-decoration: none; }

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── HEADER ─── */
header {
  background: var(--paper-card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 200;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.site-logo {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 6px 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  background: var(--accent-lt);
  color: var(--accent-dk);
}

.btn-logout {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-muted);
  background: none;
  border: 1px solid var(--line);
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-logout:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* ─── HERO ─── */
.hero, .private-hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--line);
}

.hero-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 14px;
}

.hero-sub {
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 560px;
}

/* ─── POSTS GRID ─── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 20px;
  padding: 40px 0 64px;
}

.post-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.07);
  border-color: var(--accent);
}

.post-card--private .post-tag { background: #dbeafe; color: var(--private); }
.post-card--private:hover { border-color: var(--private); }

.post-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent-lt);
  color: var(--accent-dk);
  padding: 3px 10px;
  border-radius: 99px;
  width: fit-content;
}

.post-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

.post-excerpt {
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.6;
  flex: 1;
}

.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.post-date {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.post-cta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

/* ─── STATI: loading, empty, error ─── */
.loading-state, .empty-state, .error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--ink-soft);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-hint {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-top: 8px;
}

/* ─── MODAL ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.55);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  background: var(--paper-card);
  border-radius: 16px;
  padding: 40px 40px 36px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 1;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--line);
  border: none;
  font-size: 1rem;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover { background: #e5e5e5; }

.modal-date {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-bottom: 10px;
}

#modal-title {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--ink);
}

/* ─── LOGIN SCREEN ─── */
.login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  min-height: 60vh;
}

.login-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.06);
}

.login-icon {
  font-size: 2.8rem;
  margin-bottom: 20px;
}

.login-card h1 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  margin-bottom: 12px;
}

.login-card p {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

.btn-primary {
  display: inline-block;
  background: var(--private);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.18s, transform 0.12s;
  width: 100%;
}

.btn-primary:hover {
  background: #162d4a;
  transform: translateY(-1px);
}

.login-hint {
  margin-top: 18px !important;
  font-size: 0.82rem !important;
  margin-bottom: 0 !important;
}

.login-hint a {
  color: var(--private);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* ─── FOOTER ─── */
footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* ─── UTILITY ─── */
.hidden { display: none !important; }

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
  .header-inner { height: 56px; }
  .site-logo { font-size: 1rem; }
  .nav-link { padding: 5px 10px; font-size: 0.8rem; }
  .hero, .private-hero { padding: 40px 0 32px; }
  .hero-title { font-size: 1.7rem; }
  .posts-grid { grid-template-columns: 1fr; padding: 24px 0 48px; }
  .modal-box { padding: 28px 20px 24px; }
  #modal-title { font-size: 1.35rem; }
  .login-card { padding: 36px 24px; }
}
