/* ========================================================================
   DEVELOPER GUIDE: DYNAMIC THEMES

   1. IMAGE BACKGROUND:
      In <head>:
      <style> body.glass-mode { --custom-bg-image: url('user.jpg'); } </style>
      In <body>: <body class="glass-mode">

   2. VIDEO BACKGROUND:
      In <head>:
      <style> body.glass-mode { --custom-bg-image: url('poster.jpg'); } </style>
      In <body>: <body class="glass-mode">
      Inject HTML: <video class="bg-video" ...></video>
======================================================================== */
/* ========================================================================
   DEVELOPER GUIDE: DYNAMIC THEMES
   1. IMAGE BACKGROUND: <body class="glass-mode"> with --custom-bg-image
   2. VIDEO BACKGROUND: <body class="glass-mode"> with video tag
======================================================================== */

/* ===============================
   1. GLOBAL VARIABLES
================================ */
:root {
  /* --- Color Palette --- */
  --bg-page: #f2f2f0; 
  --bg-card: #ffffff;          
  
  /* Border & Shadow */
  --border-card: rgba(0, 0, 0, 0.15); 
  --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.12);
  
  --text-main: #111827;
  --text-muted: #6b7280;
  
  --accent: #5865f2;
  --text-on-accent: #ffffff;
  
  /* --- Background Tints --- */
  --bg-neutral: #f3f4f6;

  /* --- Token References --- */
  --border-light: rgba(0, 0, 0, 0.15); 
  --radius-lg: 24px;
  --radius-sm: 16px;
  --footer-bg: rgba(255, 255, 255, 0.8);
}

/* --- DARK MODE --- */
body[data-theme="dark"] {
  --bg-page: #0b0f14;
  --bg-card: #1f2937;
  --border-card: #374151;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --footer-bg: #1f2937;
  --border-light: rgba(255, 255, 255, 0.15);
  
  /* Dark Mode Button Color */
  --bg-neutral: #374151; 
}

/* =========================================================
   PREMIUM GLASS LOGIC
   ========================================================= */
body.glass-mode {
  --bg-card: rgba(15, 23, 42, 0.35); 
  --border-card: rgba(255, 255, 255, 0.3);
  --glass-blur: blur(24px) saturate(180%);
  --glass-shine: linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 100%);
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.9);
  --text-shadow: 0 2px 4px rgba(0,0,0,0.6); 
  --shadow-card: 0 20px 40px rgba(0, 0, 0, 0.4); 
  --footer-bg: rgba(15, 23, 42, 0.6);
}

body.glass-mode[data-theme="dark"] {
  --bg-card: rgba(11, 15, 20, 0.85); 
  --border-card: rgba(255, 255, 255, 0.15);
  --glass-shine: linear-gradient(to bottom, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
  --footer-bg: rgba(11, 15, 20, 0.95);
}

/* ===============================
   2. BASE SETTINGS
================================ */
* { box-sizing: border-box; }

body {
  margin: 0; min-height: 100vh; padding: 20px 16px;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  text-shadow: var(--text-shadow, none);
  display: flex; justify-content: center; position: relative;
  background-color: var(--bg-page);
}

body::before {
  content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: -2; background-image: var(--custom-bg-image, none);
  background-size: cover; background-position: center;
  pointer-events: none; opacity: 0; transition: opacity 0.5s ease;
}
body.glass-mode::before { opacity: 1; }

.bg-video {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: -1; pointer-events: none;
  opacity: 0; transition: opacity 0.5s ease;
}
body.glass-mode .bg-video { opacity: 1; }
@media (max-width: 768px) { body.glass-mode .bg-video { display: none; } }

/* ── Layer 2b: Brand tint overlay ─────────────────────── */
.bg-tint-overlay {
  position: fixed; inset: 0;
  background: var(--bg-tint, transparent);
  mix-blend-mode: color;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: background 0.4s ease;
}
body.glass-mode .bg-tint-overlay { opacity: 1; }

/* =================================================================
   3. MOBILE LAYOUT (Unified Nameplate)
================================================================= */
.page {
  width: 100%; max-width: 440px; 
  display: flex; flex-direction: column; 
  background: transparent; border: none; box-shadow: none; padding: 0;
}

.col-profile { 
  display: flex; flex-direction: column; width: 100%; 
  margin-bottom: 24px;
}

/* --- THE NAME CARD --- */
.name-card {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  width: 100%; max-width: 400px;
  
  /* Positioning */
  margin: 60px auto 0 auto; 

  /* Visuals */
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  border-radius: 40px;
  
  /* COMPACT SPACING */
  padding: 32px 24px 24px 24px; 
  gap: 8px; 
  
  position: relative; z-index: 1;
  overflow: visible; 
}
body.glass-mode .name-card {
  background-image: var(--glass-shine);
  backdrop-filter: var(--glass-blur); 
  -webkit-backdrop-filter: var(--glass-blur);
}


/* --- Profile Image (Increased to 140px) --- */
.avatar-wrapper {
  position: relative; 
  
  /* 1. SIZE: Increased from 110px */
  width: 140px; 
  height: 140px; 
  
  border-radius: 50%; overflow: hidden; 
  border: 4px solid var(--bg-page); 
  background: var(--bg-card);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  flex-shrink: 0;
  
  /* 2. POP-OUT POSITION: Adjusted to pull the larger image up */
  margin-top: -100px; 
  margin-bottom: 0px; 
  z-index: 10;
}

.avatar-wrapper img { width: 100%; height: 100%; object-fit: cover; }
body.glass-mode .avatar-wrapper { border-color: rgba(255,255,255,0.1); }

/* --- Text Group --- */
.identity-group {
  display: flex; flex-direction: column; gap: 4px; width: 100%;
}
.name {
  font-size: 24px; font-weight: 800; 
  color: var(--text-main); line-height: 1.1; margin: 0;
}
.followers {
  font-size: 14px; color: var(--text-muted); margin: 0;
}

/* --- Social Row --- */
.social-row {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; 
  background: transparent; border: none; box-shadow: none;
  padding: 0; width: auto; margin: 10px 0 0 0; 
}

.social-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
}

/* DARK MODE: Inherits automatically via color: inherit */
body[data-theme="dark"] .social-btn {
  /* Ghost style inherits text color from parent */
}

/* HOVER STATE: Subtle gray highlight */
.social-btn:hover {
  transform: translateY(-3px);
  background: rgba(128, 128, 128, 0.15);
}

/* GLASS MODE: Frosted ghost with drop-shadow for visibility */
body.glass-mode .social-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* =================================================================
   4. CONTENT CARDS & POSTS
================================================================= */
.section { margin-bottom: 24px; }

.card {
  background: var(--bg-card); 
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card); 
  border-radius: var(--radius-lg);
  padding: 24px; 
  color: var(--text-main); line-height: 1.6;
}
body.glass-mode .card {
  background-image: var(--glass-shine);
  backdrop-filter: var(--glass-blur); 
  -webkit-backdrop-filter: var(--glass-blur);
}
.card p { margin-bottom: 0.75em; }
.card p:last-child { margin-bottom: 0; }

.primary-btn {
  display: flex; justify-content: center; align-items: center;
  width: 100%; padding: 16px; margin-bottom: 32px; 
  border-radius: 999px;
  background: var(--accent); color: var(--text-on-accent);
  font-weight: 700; font-size: 17px; text-decoration: none;
  transition: all 0.2s ease; text-shadow: none;
}
.primary-btn:hover {
  transform: translateY(-2px); opacity: 0.95;
  box-shadow: 0 8px 20px rgba(88, 101, 242, 0.25);
}

.promo-grid { margin-bottom: 28px; display: flex; flex-direction: column; gap: 10px; }
.course-link {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 20px; gap: 15px;
  background: var(--bg-card); border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-sm); 
  font-weight: 700; color: var(--text-main);
  text-decoration: none; transition: all 0.2s ease;
}
body.glass-mode .course-link {
  background-image: var(--glass-shine);
  backdrop-filter: var(--glass-blur); 
  -webkit-backdrop-filter: var(--glass-blur);
}
.course-link::after {
  content: "→"; font-size: 20px; font-weight: 300; color: var(--accent);
  transition: transform 0.2s ease; flex-shrink: 0;
}
[dir="rtl"] .course-link::after { content: "←"; }
@media (hover: hover) {
  .course-link:hover {
    transform: translateY(-2px); border-color: var(--accent); background-color: rgba(88, 101, 242, 0.03);
  }
  .course-link:hover::after { transform: translateX(4px); }
  [dir="rtl"] .course-link:hover::after { transform: translateX(-4px); }
}

/* ---------- Promo Link — Thumbnail variant ---------- */
.course-link--thumb {
  padding: 10px 20px 10px 10px;
  gap: 14px;
  overflow: hidden;
  min-height: 80px;
}
.course-link-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 10px;
}
.course-link--thumb .course-link-text {
  flex: 1;
}

/* ---------- Promo Collections ---------- */

.promo-collection-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 10px 4px 2px;
}
.promo-collection-header:first-child { padding-top: 0; }
.col-icon-tabler,
.col-icon-lucide,
.col-icon-emoji { display: flex; align-items: center; flex-shrink: 0; }
.col-icon-tabler svg,
.col-icon-lucide svg { width: 16px; height: 16px; stroke: var(--text-muted); }

.promo-collection-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  min-height: 44px;
  background: var(--bg-soft, rgba(255,255,255,0.06));
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm, 12px);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  margin-top: 6px;
}
.promo-collection-toggle:first-child { margin-top: 0; }
@media (hover: hover) {
  .promo-collection-toggle:hover { background: var(--bg-card, rgba(255,255,255,0.1)); }
}

.col-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-main);
}
.col-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}
.col-count {
  font-size: 11px;
  color: var(--text-muted);
}
.col-chevron {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.col-chevron::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-top: -4px;
}
.promo-collection-toggle.is-collapsed .col-chevron { transform: rotate(-90deg); }
[dir="rtl"] .promo-collection-toggle.is-collapsed .col-chevron { transform: rotate(90deg); }

.promo-collection-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 2px solid var(--border-light, rgba(255,255,255,0.12));
}
.promo-collection-items.is-hidden { display: none; }

/* Desktop: all collections open by default */
@media (min-width: 768px) {
  .promo-collection-items.is-hidden { display: flex; }
  .promo-collection-toggle.is-collapsed .col-chevron { transform: rotate(0deg); }
}

/* ===============================
   4. CONTENT CARDS & POSTS
================================ */
#posts { display: block; margin-bottom: 24px; position: relative; }

.section-title { 
  font-size: 20px; font-weight: 800; margin-bottom: 18px; color: var(--text-main); 
}

.latest-posts-row {
  --shadow-card: none;
  display: flex; gap: 14px; overflow-x: auto;
  padding-bottom: 12px; scrollbar-width: none; background: transparent;
}
.latest-posts-row::-webkit-scrollbar { display: none; }

/* --- Base Card Logic --- */
.post-card {
  min-width: 240px;
  display: grid;
  grid-template-rows: auto auto;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  border-radius: 18px;
  color: var(--text-main);
  position: relative;
}

body.glass-mode .post-card {
  background-image: var(--glass-shine); 
  backdrop-filter: var(--glass-blur); 
  -webkit-backdrop-filter: var(--glass-blur);
}

.post-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  grid-row: 1 / -1;
}

/* --- Media Containers (Videos & Images Locked to 3/4) --- */
.video-thumb, 
.post-card[data-template="image"] .post-media {
  width: 100%;
  aspect-ratio: 3 / 4; /* Keeps grid symmetric */
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2c3e50 0%, #0b0f14 100%); /* Placeholder for both */
}

/* Image containment for Photos (Invisible Letterbox) */
.post-card[data-template="image"] .post-media {
  background: var(--bg-card); /* Matches card for seamless landscape photos */
  object-fit: contain; 
}

/* Media Item Styling & Broken Link Protection */
.video-thumb img, 
.post-card[data-template="image"] .post-media img {
  width: 100%;
  height: 100%;
  opacity: 0; /* Hide broken icon/alt-text in corner */
  font-size: 0;
}

.video-thumb img[src], 
.post-card[data-template="image"] .post-media img[src] {
  opacity: 1; /* Show only if source is valid */
}

.video-thumb img {
  object-fit: cover;
  object-position: center 15%;
}

/* This hides the broken icon and alt-text completely */
.video-thumb img, 
.post-media img {
    opacity: 0;
    font-size: 0;
    color: transparent;
}

/* This only reveals the image if it actually loads successfully */
.video-thumb img[src], 
.post-media img[src] {
    opacity: 1;
}

.post-card[data-template="image"] .post-media img {
  object-fit: contain; /* Full context for photos */
}

/* --- Play Button (Sharp & Centered) --- */
.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.play-circle {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.play-icon {
  width: 0; height: 0; 
  border-top: 10px solid transparent; border-bottom: 10px solid transparent;
  border-left: 16px solid #111827;
  margin-left: 4px;
}

.post-card:hover .play-circle {
  transform: scale(1.1);
  background: #ffffff;
}

/* --- Post Content --- */
.post-body {
  padding: 16px 20px 20px 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
}

.post-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 2.8em;
}

/* Text-Only Template Adjustments */
.post-card[data-template="text"] .post-body {
  flex: 1;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.post-card[data-template="text"] .post-body .post-title {
  text-align: center;
  font-size: 16px;
  font-style: italic;
  -webkit-line-clamp: 5;
  max-height: 7em;
}

/* --- FOOTER --- */
.platform-footer {
  margin-top: 30px; padding: 16px 20px; text-align: center; border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-top: 1px solid rgba(128, 128, 128, 0.15);
  color: inherit;
  font-size: 13px;
}

body[data-theme="dark"] .platform-footer {
  background: rgba(0, 0, 0, 0.2);
}
.page-chrome-top button,
body .theme-toggle,
body [data-surface="shareButton"] {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* =================================================================
   5. DESKTOP SPLIT LAYOUT
================================================================= */
@media (min-width: 1024px) {
  body { 
    align-items: flex-start; padding-top: 80px; 
    flex-direction: row; justify-content: center; 
  }
  
  .page {
    max-width: 1100px; padding: 0; margin: 0 auto;
    display: grid; grid-template-columns: 360px 1fr; 
    gap: 0 60px; align-items: start; position: relative;
  }

  /* LEFT COLUMN */
  .col-profile { grid-column: 1; position: sticky; top: 40px; height: auto; margin-bottom: 0; }

  /* NAME CARD */
  .name-card { 
    padding: 32px; border-radius: 48px; gap: 12px; 
    margin-top: 100px; 
  }
  
  /* PROFILE IMAGE (194px) */
  .avatar-wrapper { 
    width: 194px; height: 194px; margin: 0; 
    margin-top: -130px; 
    margin-bottom: 0px; 
  }
  
  .name { font-size: 32px; margin: 0; }
  .followers { font-size: 15px; margin: 0; }
  
  /* RESET Social Row */
  .page .social-row, body.glass-mode .page .social-row {
    position: static; margin-top: 12px; z-index: auto;
    background: transparent; border: none; box-shadow: none;
  }

  /* RIGHT COLUMN */
  .col-content { 
    grid-column: 2; width: 100%; 
    padding-top: 100px; /* ALIGNMENT FIX */
    min-width: 0; 
  }
  
  body #posts .latest-posts-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    overflow: visible;
    align-items: start;
  }
  .post-card { min-width: auto; }
  
  .platform-footer { grid-column: 1 / -1; margin: 60px 0 40px; width: 100%; }
}
