/*
Theme Name: Insta Like
Theme URI: https://atsamag.com
Author: Atsamag
Author URI: https://atsamag.com
Description: Theme autonome type reseau social (fil d'actualite + profil), sans dependance a un theme ou plugin tiers. Expose des hooks pour que les plugins Atsamag y branchent leurs fonctionnalites.
Version: 0.3.2
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: atsa-insta-like
*/

/* ============================================================
   RESET / BASE
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #e9e9e9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #fff;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

svg.icon {
  width: 20px; height: 20px; stroke: currentColor; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block;
}

/* ============================================================
   THEME VARIABLES (clair / sombre)
   ============================================================ */
.atsa-app {
  --bg-frame: #000; --bg-surface: #0a0a0a; --bg-elevated: #1a1a1a;
  --bg-btn: #262626; --border-c: #262626; --border-soft: #1a1a1a;
  --text-1: #fff; --text-2: #ccc; --text-muted: #888;
  background: var(--bg-frame);
  color: var(--text-1);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.atsa-app.light {
  --bg-frame: #ffffff; --bg-surface: #f7f7f7; --bg-elevated: #ececec;
  --bg-btn: #eaeaea; --border-c: #e2e2e2; --border-soft: #ececec;
  --text-1: #111111; --text-2: #444444;
}
.atsa-app.light .ct-tab.active .ct-label,
.atsa-app.light .actions button { color: var(--text-1); }
.atsa-app.light .ct-icon-mono { filter: invert(1) !important; }

.theme-toggle {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--text-1);
  background: linear-gradient(90deg, #000 50%, #fff 50%);
  cursor: pointer; flex-shrink: 0;
}

/* ============================================================
   TOPBAR (mobile) — icons + label utilitaires
   ============================================================ */
.atsa-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; flex-shrink: 0;
}
.atsa-topbar .center { display: flex; align-items: center; gap: 4px; font-size: 17px; font-weight: 600; cursor: pointer; }
.atsa-topbar .icons { display: flex; align-items: flex-start; gap: 16px; }
.atsa-topbar .icons span { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.atsa-topbar .icon-label { font-size: 8.5px; color: var(--text-muted); }
.dot { position: absolute; top: -2px; right: -5px; width: 7px; height: 7px; background: #ff3040; border-radius: 50%; }

/* ============================================================
   NAV — un seul jeu de liens, repositionne par media query
   Mobile : ligne fixe en bas (icone + libelle)
   Desktop (>=900px) : colonne fixe a gauche (icone + libelle)
   ============================================================ */
.atsa-nav {
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 4px; border-top: 1px solid var(--border-c); background: var(--bg-frame);
  flex-shrink: 0; position: sticky; bottom: 0; z-index: 15;
}
.atsa-nav a, .atsa-nav span {
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-1);
}
.atsa-nav .nav-label { font-size: 9.5px; }
.atsa-nav .nav-plus {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--text-1);
  display: flex; align-items: center; justify-content: center;
}
.atsa-nav .nav-avatar {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.nav-avatar-icon { width: 28px; height: 28px; }
.atsa-nav [data-desktop-only] { display: none; }

/* ============================================================
   CONTENU PRINCIPAL / ECRANS
   ============================================================ */
.atsa-body { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 480px; margin: 0 auto; }

.atsa-screen { display: none; flex-direction: column; flex: 1; min-height: 0; }
.atsa-screen.active { display: flex; }
.atsa-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* --- Filtres de contenu --- */
.content-tabs { display: flex; flex-wrap: wrap; gap: 14px 18px; padding: 6px 16px 12px; flex-shrink: 0; }
.ct-tab { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--text-1); cursor: pointer; }
.ct-tab .ct-label { font-size: 10.5px; white-space: nowrap; }
.ct-tab.active { color: var(--text-1); }
.ct-tab.active .ct-label { font-weight: 600; }

/* --- Stories --- */
.stories { display: flex; gap: 14px; padding: 4px 16px 14px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border-soft); }
.stories::-webkit-scrollbar { display: none; }
.story { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; cursor: pointer; }
.story .ring {
  width: 56px; height: 56px; border-radius: 50%; border: 2px solid #666;
  display: flex; align-items: center; justify-content: center; font-size: 20px; color: #888; position: relative;
}
.story.you .ring { border-style: dashed; }
.story .plus-badge {
  position: absolute; bottom: -2px; right: -2px; width: 16px; height: 16px;
  background: #0af; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; border: 2px solid var(--bg-frame);
}
.story .label { font-size: 11px; color: var(--text-2); max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Post --- */
.post { border-bottom: 1px solid var(--border-soft); }
.post-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.post-header .p-avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid #444;
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: #888; flex-shrink: 0;
}
.post-header .p-name { font-size: 13px; font-weight: 600; }
.post-header .p-sound { font-size: 11px; color: #999; }
.post-header .p-more { margin-left: auto; cursor: pointer; }
.post-visual {
  width: 100%; aspect-ratio: 4/5; background: var(--bg-elevated); position: relative;
  display: flex; align-items: center; justify-content: center; font-size: 44px; color: #3a3a3a; cursor: pointer;
}
.post-visual::after, .grid div::after {
  content: "atsamag"; position: absolute; bottom: 8px; left: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; color: rgba(255,255,255,.35);
  pointer-events: none; text-transform: lowercase;
}
.atsa-app.light .post-visual::after, .atsa-app.light .grid div::after { color: rgba(0,0,0,.3); }
.post-actions { display: flex; align-items: center; gap: 16px; padding: 10px 12px 4px; }
.post-actions .spacer { flex: 1; }
.post-actions span { cursor: pointer; display: flex; }
.post-likes { padding: 2px 12px; font-size: 13px; font-weight: 600; }
.post-caption { padding: 4px 12px 0; font-size: 13px; color: var(--text-2); }
.post-caption b { font-weight: 600; color: var(--text-1); }
.post-comments { padding: 4px 12px 14px; font-size: 12px; color: var(--text-muted); cursor: pointer; }

/* --- Profil --- */
.profile-head { display: flex; gap: 18px; padding: 8px 16px 0; align-items: flex-start; }
.avatar {
  width: 80px; height: 80px; border-radius: 50%; border: 2px solid #333;
  display: flex; align-items: center; justify-content: center; font-size: 30px; color: #888;
  flex-shrink: 0; background: var(--bg-elevated); cursor: pointer;
}
.stats { display: flex; flex: 1; justify-content: space-around; margin-top: 8px; }
.stat { text-align: center; cursor: pointer; }
.stat .num { font-size: 16px; font-weight: 600; }
.stat .label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.fullname { padding: 10px 16px 0; font-size: 14px; font-weight: 600; }
.bio { padding: 4px 16px 0; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.actions { display: flex; gap: 8px; padding: 14px 16px 0; }
.actions button {
  flex: 1; background: var(--bg-btn); color: var(--text-1); border: none; border-radius: 8px;
  padding: 8px 0; font-size: 13px; font-weight: 600; cursor: pointer;
}
.tabs { display: flex; border-top: 1px solid var(--border-c); margin-top: 16px; }
.tab { flex: 1; text-align: center; padding: 10px 0; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.tab.active { color: var(--text-1); border-bottom: 1.5px solid var(--text-1); }
.panel { display: none; }
.panel.active { display: block; }
.empty { text-align: center; padding: 60px 24px; color: var(--text-2); font-size: 15px; font-weight: 600; }
.empty .sub { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-top: 6px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.grid div {
  aspect-ratio: 1; background: var(--bg-elevated); cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center; font-size: 22px; color: #444;
}

/* --- Parametres --- */
.settings-section { padding: 16px 16px 4px; }
.settings-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 6px; }
.settings-row { padding: 12px 4px; border-bottom: 1px solid var(--border-soft); font-size: 14px; cursor: pointer; color: var(--text-1); }
.settings-row.danger { color: #ff4d4d; }

/* --- Overlay post --- */
.overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.85);
  display: none; align-items: center; justify-content: center; flex-direction: column; padding: 24px; z-index: 40;
}
.overlay.active { display: flex; }
.overlay .close { position: absolute; top: 16px; right: 16px; font-size: 22px; cursor: pointer; color: #fff; }
.overlay .post-visual2 {
  width: 100%; max-width: 320px; aspect-ratio: 1; background: #1a1a1a;
  display: flex; align-items: center; justify-content: center; font-size: 40px; color: #555; border-radius: 8px; margin-bottom: 16px;
}
.overlay .post-caption2 { font-size: 13px; color: #ddd; text-align: center; }

.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #262626; color: #fff; padding: 8px 16px; border-radius: 20px;
  font-size: 12px; opacity: 0; pointer-events: none; transition: opacity 0.2s; white-space: nowrap; z-index: 50;
}
.toast.show { opacity: 1; }

/* ============================================================
   DESKTOP (>= 900px) — bascule nav en colonne laterale
   ============================================================ */
@media (min-width: 900px) {
  .atsa-app { flex-direction: row; }
  .atsa-topbar .icons > span[data-desktop-hide] { display: none; }

  .atsa-nav {
    flex-direction: column; justify-content: flex-start; gap: 18px;
    width: 74px; height: 100vh; position: sticky; top: 0;
    border-top: none; border-right: 1px solid var(--border-c);
    padding: 18px 0;
  }
  .atsa-nav .nav-label { font-size: 9.5px; text-align: center; }
  .atsa-nav .nav-plus { flex-direction: row; }
  .atsa-nav .nav-avatar { width: 34px; height: 34px; }
  .nav-avatar-icon { width: 34px; height: 34px; }
  .atsa-nav [data-desktop-only] { display: flex; }
  .atsa-topbar .icons [data-desktop-hide] { display: none; }

  .atsa-body { max-width: none; flex: 1; }
  .atsa-topbar { padding: 16px 28px 10px; }
  .content-tabs { padding: 6px 28px 14px; }
  .stories { padding: 4px 28px 16px; }
  .post { max-width: 440px; margin: 20px auto; border: 1px solid var(--border-soft); border-radius: 8px; overflow: hidden; }
  .profile-head { padding: 24px 28px 0; gap: 32px; align-items: center; }
  .avatar { width: 110px; height: 110px; font-size: 38px; }
  .stats { justify-content: flex-start; gap: 32px; margin-top: 0; }
  .stat { text-align: left; }
  .fullname, .bio { padding-left: 0; }
  .actions { padding-left: 0; max-width: 280px; }
  .grid { gap: 16px; padding: 16px 28px 24px; }
  .grid div { border-radius: 4px; font-size: 28px; }
}
