/* ═══════════════════════════════════════════════════════════════
   SALVIATORE ARTACO — Mobile-first, app-like
   Tokens: #F2F2F2 bg · #E8E8E8 border · #262626 text · #8E8E8E muted
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg:         #F2F2F2;
  --bg-card:    #FFFFFF;
  --text:       #262626;
  --text-muted: #8E8E8E;
  --border:     #E8E8E8;
  --accent:     #0095F6;
  --accent-dk:  #0074CC;
  --danger:     #ED4956;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --ig-grad:    linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow-sm:  0 1px 4px rgba(0,0,0,.08);
  --shadow:     0 2px 12px rgba(0,0,0,.1);
  /* Safe areas */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* Globale: no tap highlight, touch friendly */
* { -webkit-tap-highlight-color: transparent; }
button, a, [role="button"] {
  touch-action: manipulation;
  font-family: var(--font);
  cursor: pointer;
}

/* ── HEADER ─────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  /* Safe area top per notch */
  padding-top: var(--safe-top);
}
.header-inner {
  padding: 0 16px;
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
  display: flex; align-items: center; justify-content: space-between;
  height: 44px;
}
.site-logo {
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -.5px;
}
.site-logo:active { opacity: .6; }
.header-nav { display: flex; gap: 6px; align-items: center; }
.nav-link {
  color: var(--text); font-size: .8rem; font-weight: 600;
  padding: 7px 12px;
  min-height: 36px;
  display: inline-flex; align-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.nav-link:active { background: var(--bg); }
.nav-link--logout {
  color: var(--text-muted); border-color: transparent; font-weight: 400;
}
.nav-link--logout:active { color: var(--text); background: transparent; }
.nav-member-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  padding: 0 4px;
}

@media (min-width: 614px) {
  .site-header { padding-top: 0; }
  .header-inner { max-width: 975px; margin: 0 auto; padding: 0 20px; height: 54px; }
  .site-logo { font-size: 1.35rem; }
  .nav-link { font-size: .875rem; padding: 7px 16px; min-height: 38px; }
  .nav-link:hover { background: var(--bg); }
  .nav-link--logout:hover { color: var(--text); background: transparent; }
}

/* ── LAYOUT ─────────────────────────────────────────────────── */
.wall-layout {
  padding: 0 0 calc(56px + var(--safe-bottom));
}
.wall-layout--single { padding-top: 12px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 16px 14px; color: var(--text-muted); font-size: .875rem;
  min-height: 44px;
}
.back-link:active { color: var(--text); }

/* ── PROFILO ────────────────────────────────────────────────── */
.profile-section {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.profile-bar {
  padding: 16px 16px 16px;
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
  display: flex; align-items: flex-start; gap: 20px;
}

.profile-avatar-wrapper { flex-shrink: 0; }
.ig-avatar-ring {
  width: 80px; height: 80px; border-radius: 50%;
  padding: 3px;
  background: var(--ig-grad);
  display: flex; align-items: center; justify-content: center;
}
.profile-avatar {
  width: 74px; height: 74px;
  border-radius: 50%; object-fit: cover;
  border: 3px solid var(--bg-card);
  background: #ddd; display: block;
}

.profile-info { flex: 1; padding-top: 2px; min-width: 0; }

.profile-username-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.profile-username {
  font-size: .95rem; font-weight: 300;
  color: var(--text); letter-spacing: -.2px; line-height: 1.2;
}

.profile-stats {
  display: flex; gap: 16px;
  list-style: none; padding: 0; margin-bottom: 10px;
}
.profile-stat { font-size: .78rem; color: var(--text); }
.profile-stat strong { font-weight: 700; }

.profile-display-name { font-size: .875rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.profile-bio-line { font-size: .875rem; color: var(--text); line-height: 1.4; margin-bottom: 1px; }
.profile-detail { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }

@media (min-width: 614px) {
  .profile-section { background: transparent; border-bottom: none; margin-bottom: 0; }
  .profile-bar {
    max-width: 614px; margin: 0 auto;
    padding: 28px 20px 20px; gap: 80px;
  }
  .ig-avatar-ring { width: 154px; height: 154px; padding: 4px; }
  .profile-avatar { width: 146px; height: 146px; border-width: 4px; }
  .profile-info { padding-top: 4px; }
  .profile-username { font-size: 1.25rem; }
  .profile-username-row { margin-bottom: 18px; gap: 20px; }
  .profile-stats { gap: 40px; margin-bottom: 14px; }
  .profile-stat { font-size: .875rem; }
  .profile-detail { font-size: .875rem; }
}

/* ── WALL CONTENT ────────────────────────────────────────────── */
.wall-content { display: block; }
.wall-sidebar { display: none; }

@media (min-width: 614px) {
  .wall-content { max-width: 614px; margin: 0 auto; padding: 16px 0 0; }
}

/* ── FEED ────────────────────────────────────────────────────── */
/* Mobile: gap tra card, bg grigio visibile tra i post */
.wall-feed {
  display: flex; flex-direction: column;
  gap: 20px;
  padding: 0 12px;
  padding-left: max(12px, var(--safe-left));
  padding-right: max(12px, var(--safe-right));
}
.empty-feed {
  margin: 0; padding: 40px 20px; text-align: center;
  color: var(--text-muted); background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 614px) {
  .wall-feed { gap: 24px; padding: 0; }
}

/* ── POST CARD ───────────────────────────────────────────────── */
/* Mobile: card con margini laterali, radius, shadow */
.post-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

@media (min-width: 614px) {
  .post-card {
    border-radius: var(--radius-sm);
    box-shadow: none;
    border: 1px solid var(--border);
  }
}

.post-header {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px;
}
.post-author-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border); background: #ddd;
}
.post-meta { flex: 1; min-width: 0; }
.post-author { font-weight: 600; font-size: .875rem; color: var(--text); }
.post-meta-bottom { display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.post-date { font-size: .72rem; color: var(--text-muted); }
.post-visibility { font-size: .68rem; color: var(--text-muted); }
.post-ai-badge { font-size: .65rem; color: var(--accent); font-weight: 600; padding: 0 4px; }

/* Caption stile Instagram: username bold + testo inline */
.post-caption-block {
  padding: 6px 14px 12px;
  font-size: .875rem; line-height: 1.5; color: var(--text);
}
.post-caption-author { font-weight: 700; margin-right: 5px; }
.post-caption-sub { font-size: .8rem; color: var(--text-muted); display: inline-block; margin-top: 2px; }

/* Media */
.post-media { margin: 0; }
/* Mobile: aspect ratio fisso 4:5 → taglia sempre */
.post-media img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  cursor: zoom-in;
}

/* Desktop: solo max-height, nessun ratio forzato */
@media (min-width: 614px) {
  .post-media img {
    aspect-ratio: unset;
    max-height: 560px;
  }
}

/* ── LIGHTBOX ────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  cursor: zoom-out;
  animation: lbFadeIn .15s ease;
}
.lightbox[hidden] { display: none; }
.lightbox-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  cursor: default;
  animation: lbScaleIn .18s cubic-bezier(.34,1.56,.64,1);
}
@keyframes lbFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes lbScaleIn {
  from { transform: scale(.92); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.video-container {
  position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;
}
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

/* Click-to-play thumbnail */
.video-thumb-wrap {
  display: block; position: relative; overflow: hidden;
  background: #000; cursor: pointer; text-decoration: none;
}
.video-thumb-img {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
  display: block; opacity: .85;
  transition: opacity .2s;
}
.video-thumb-wrap:hover .video-thumb-img { opacity: .7; }
.video-play-btn {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
}
.video-fallback {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 28px 16px;
  background: #0f0f0f; border-radius: 4px;
}
.video-fallback-msg { color: #aaa; font-size: .85rem; margin: 0; text-align: center; }
.video-fallback-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: #fff; font-size: .9rem; font-weight: 600;
  text-decoration: none; padding: 8px 16px;
  background: #FF0000; border-radius: 4px;
  transition: background .15s;
}
.video-fallback-link:hover { background: #cc0000; }

.post-audio { margin: 8px 14px 4px; }
.audio-player-wrapper {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); padding: 12px 14px;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.audio-icon { font-size: 1.3rem; }
.audio-player-wrapper audio { flex: 1; min-width: 0; }

.post-link-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 0 12px;
  text-decoration: none;
}
.post-link-card:active { opacity: .85; }
.post-link-card img { width: 100%; aspect-ratio: 1.91/1; object-fit: cover; display: block; }
.link-card-text { padding: 10px 12px 12px; background: var(--bg); }
.link-card-domain { display: block; font-size: .65rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: .06em; margin-bottom: 2px; }
.link-card-text strong { display: block; font-size: .88rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.link-card-text p { font-size: .78rem; color: var(--text-muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Stats bar */
.post-stats {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px;
  min-height: 48px;
}

.comment-toggle-btn {
  background: none; border: none;
  color: var(--text-muted); font-size: .8rem;
  font-family: var(--font); padding: 8px 6px;
  min-height: 44px;
}
.comment-toggle-btn:active { color: var(--text); }

@media (min-width: 614px) {
  .comment-toggle-btn:hover { color: var(--text); }
  .post-link-card:hover { opacity: .85; }
}

/* ── REACTION TRIGGER ─────────────────────────────────────────── */
.reaction-trigger-wrapper { position: relative; }

.reaction-trigger {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none;
  padding: 8px 10px;
  min-height: 44px;
  border-radius: 22px;
  font-family: var(--font); font-size: .82rem;
  color: var(--text-muted);
  user-select: none; -webkit-user-select: none;
  transition: background .15s;
}
.reaction-trigger:active { background: var(--bg); }
.reaction-trigger--active { color: var(--accent); font-weight: 700; }

.trigger-emojis { letter-spacing: -2px; font-size: 1rem; line-height: 1; }
.trigger-count  { font-size: .82rem; }
.trigger-icon   { font-size: 1.1rem; line-height: 1; }
.trigger-label  { font-size: .82rem; }
.trigger-active-emoji { font-size: 1.1rem; line-height: 1; }
.trigger-active-label { font-size: .82rem; }

@media (min-width: 614px) {
  .reaction-trigger:hover { background: var(--bg); }
}

/* ── REACTION PICKER ─────────────────────────────────────────── */
.reaction-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: -4px;
  display: flex; align-items: center; gap: 2px;
  background: #fff;
  border-radius: 32px;
  padding: 8px 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.18), 0 1px 6px rgba(0,0,0,.1);
  z-index: 200;
  transform-origin: left bottom;
  animation: pickerIn .22s cubic-bezier(.34,1.56,.64,1) forwards;
  /* Freccia in basso */
  filter: drop-shadow(0 4px 16px rgba(0,0,0,.14));
}
.reaction-picker[hidden] { display: none; }

@keyframes pickerIn {
  from { opacity: 0; transform: scale(.5) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.reaction-picker-btn {
  background: none; border: none;
  padding: 4px;
  border-radius: 50%;
  position: relative;
  display: flex; flex-direction: column; align-items: center;
}
.reaction-picker-btn:active .picker-emoji {
  transform: scale(1.55) translateY(-5px);
}

.picker-emoji {
  font-size: 1.85rem;
  line-height: 1;
  display: block;
  transition: transform .18s cubic-bezier(.34,1.56,.64,1);
  will-change: transform;
}
@media (hover: hover) {
  .reaction-picker-btn:hover .picker-emoji {
    transform: scale(1.55) translateY(-5px);
  }
}

/* Tooltip nome sotto l'emoji (desktop hover) */
.picker-label { display: none; }

/* Comments */
.comments-section { padding: 0 14px 10px; }
.comments-list { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  flex-shrink: 0; border: 1px solid var(--border); background: #ddd;
}
.comment-bubble { flex: 1; min-width: 0; }
.comment-author { font-weight: 700; font-size: .82rem; display: inline; }
.comment-text { font-size: .82rem; color: var(--text); line-height: 1.4; }
.comment-time { font-size: .65rem; color: var(--text-muted); margin-top: 3px; display: block; }
.load-more-comments {
  background: none; border: none;
  color: var(--text-muted); font-family: var(--font);
  font-size: .8rem; font-weight: 600;
  padding: 8px 0; min-height: 40px;
  width: 100%; text-align: left;
}
.load-more-comments:active { color: var(--text); }

/* ── FORM COMMENTO ───────────────────────────────────────────── */
.comment-form {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}
.comment-form-row {
  display: flex; gap: 8px; align-items: center;
}
.comment-form-text {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 22px;
  font-family: var(--font);
  /* CRITICO: 16px previene lo zoom su iOS */
  font-size: 16px;
  background: var(--bg); color: var(--text);
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}
.comment-form-text:focus { border-color: var(--text-muted); }
.comment-form-text::placeholder { color: var(--text-muted); font-size: 15px; }

.comment-form-submit {
  background: none; border: none;
  color: var(--accent); font-family: var(--font);
  font-size: .875rem; font-weight: 700;
  padding: 8px 4px;
  min-height: 44px;
  min-width: 44px;
  text-align: center;
  white-space: nowrap;
}
.comment-form-submit:active { opacity: .6; }
.comment-form-submit:disabled { opacity: .4; }

.comment-form-error {
  font-size: .75rem; color: var(--danger); padding: 4px 4px 0;
}

/* Pagination */
.pagination { text-align: center; padding: 20px 0; }
.btn-load-more {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  padding: 12px 28px;
  min-height: 48px;
  font-family: var(--font); font-weight: 700; font-size: .9rem;
  transition: background .15s, transform .1s;
}
.btn-load-more:active { background: var(--accent-dk); transform: scale(.97); }

@media (min-width: 614px) {
  .btn-load-more:hover { background: var(--accent-dk); }
}

/* ── REGISTRAZIONE / LOGIN (landing) ─────────────────────────── */
.reg-wrapper {
  max-width: 420px;
  margin: 0 auto;
  padding: 8px 16px calc(56px + var(--safe-bottom));
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: .875rem;
  font-weight: 500;
}
.alert-success { background: #F0FDF4; color: #14532D; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

.reg-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 22px 24px;
  box-shadow: var(--shadow);
}

.reg-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  text-align: center;
}

.reg-row-2 {
  display: block;
}

.reg-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.reg-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
}
.reg-optional { font-weight: 400; color: var(--text-muted); }

.reg-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  /* CRITICO: 16px previene lo zoom su iOS */
  font-size: 16px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.reg-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,149,246,.12);
}
.reg-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.reg-btn {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  min-height: 50px;
  transition: background .15s, transform .1s;
  letter-spacing: .01em;
}
.reg-btn:active { transform: scale(.98); background: var(--accent-dk); }

@media (min-width: 614px) {
  .reg-btn:hover { background: var(--accent-dk); }
}

.reg-footer {
  text-align: center;
  margin-top: 18px;
  font-size: .85rem;
  color: var(--text-muted);
}
.reg-footer a { color: var(--accent); font-weight: 600; }
.reg-footer a:hover { text-decoration: underline; }

/* ── FOOTER ─────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 24px 20px;
  padding-bottom: max(24px, var(--safe-bottom));
  font-size: .65rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-top: 40px;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }
