/* =========================
   FILE: assets/css/profile.css
   Professional profile layout + tabs under player + gallery styling
   (Aligned to markup: .p-wrap / .p-stream / .p-miniRow / .p-hero__shade)
   + Offline overlay UI
   ========================= */

/* -------------------------
   Root helpers (safe fallbacks)
------------------------- */
:root{
  --bg: #0b1020;
  --card: rgba(255,255,255,.04);
  --line: rgba(148,163,184,.18);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.62);
  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --radius: 16px;
}

*{ box-sizing: border-box; }
img{ max-width: 100%; height: auto; }
a{ color: inherit; }

/* Generic “card” wrapper if you use it */
.p-card{
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Buttons (works with your existing .btn too) */
.btn{
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover{ background: rgba(255,255,255,.07); }
.btn:active{ transform: translateY(1px); }
.btn[disabled],
.btn.is-disabled{
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}
.btn--primary{
  background: rgba(59,130,246,.16);
  border-color: rgba(59,130,246,.34);
}
.btn--primary:hover{ background: rgba(59,130,246,.22); }
.btn--danger{
  background: rgba(239,68,68,.10);
  border-color: rgba(239,68,68,.24);
}
.btn--danger:hover{ background: rgba(239,68,68,.14); }

/* Pills / badges */
.p-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
}
.p-badge--muted{ color: var(--muted); }
.p-badge--ok{
  border-color: rgba(34,197,94,.26);
  background: rgba(34,197,94,.10);
}
.p-badge--warn{
  border-color: rgba(234,179,8,.28);
  background: rgba(234,179,8,.10);
}
.p-badge--off{
  border-color: rgba(148,163,184,.18);
  background: rgba(148,163,184,.06);
  color: var(--muted);
}

/* Code-ish */
.p-mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* -------------------------
   Container
------------------------- */
.p-wrap{
  max-width: 1240px;
  margin: 14px auto 0;
  padding: 0 10px;
  display: grid;
  gap: 14px;
}

/* -------------------------
   HERO
------------------------- */
.p-hero{ overflow: hidden; }

.p-hero__grid{
  display: grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
  gap: 16px;
  padding: 14px;
  align-items: stretch;
}
@media (max-width: 980px){
  .p-hero__grid{ grid-template-columns: 1fr; }
}

/* Media */
.p-hero__media{
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  min-height: 240px;
}
.p-hero__mediaBtn{
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: block;
  position: relative;
}
.p-hero__img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 16 / 10;
}
.p-hero__shade{
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 120% at 50% 10%, rgba(0,0,0,.0), rgba(0,0,0,.28));
  pointer-events: none;
}

.p-hero__flag{
  position: absolute;
  left: 12px;
  top: 12px;
  width: 30px;
  height: 22px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
  background: rgba(0,0,0,.35);
}
.p-hero__flag img{ width: 100%; height: 100%; object-fit: cover; display: block; }

/* Meta */
.p-hero__meta{
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 4px 2px;
}

.p-crumb{
  font-size: 12px;
  color: var(--muted);
}
.p-crumb__link{ color: inherit; text-decoration: none; }
.p-crumb__link:hover{ text-decoration: underline; }
.p-crumb__sep{ margin: 0 6px; opacity: .6; }
.p-crumb__here{ color: var(--text); opacity: .95; }

.p-titleRow{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.p-title{
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: -0.02em;
}
@media (max-width: 520px){
  .p-title{ font-size: 24px; }
}

.p-badges{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.p-tagline{
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}
.p-tagline--muted{ color: var(--muted); }

.p-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 2px;
}
.p-actions .btn{ min-height: 34px; }

/* Mini chips row */
.p-miniRow{
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
  margin-top: 4px;
}
@media (max-width: 980px){
  .p-miniRow{ grid-template-columns: 1fr; }
}
.p-mini{
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
  border-radius: 14px;
  padding: 10px 12px;
  min-height: 56px;
}
.p-mini__k{ font-size: 12px; color: var(--muted); }
.p-mini__v{
  font-size: 13px;
  font-weight: 650;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

/* -------------------------
   STREAM CARD (player + tabs)
------------------------- */
.p-stream{ overflow: hidden; }

.p-stream__hd{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 0;
}
.p-stream__title{
  font-weight: 750;
  letter-spacing: -0.01em;
}
.p-stream__sub{
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.p-stream__status{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  padding-top: 2px;
}
.p-dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(148,163,184,.55);
  box-shadow: 0 0 0 4px rgba(148,163,184,.08);
}
.p-dot--on{
  background: rgba(34,197,94,.95);
  box-shadow: 0 0 0 4px rgba(34,197,94,.10);
}
.p-hint{ white-space: nowrap; }

.p-stream__bd{ padding: 12px 14px 14px; }

.p-videoBox{
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  position: relative;
}
.p-video{
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}
.p-video video{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Shortcuts */
.p-shortcuts{
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.p-shortcuts__k{
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}
.p-key{
  font-size: 12px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  color: var(--text);
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.p-key__kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 700;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.12);
  padding: 2px 6px;
  border-radius: 8px;
}

/* Tabs under player */
.p-tabs{
  margin-top: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
  border-radius: 16px;
  overflow: hidden;
}

/* IMPORTANT: your markup uses .p-tabs__bar not .p-tabs__nav */
.p-tabs__bar,
.p-tabs__nav{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.12);
}

.p-tab{
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.p-tab:hover{
  color: var(--text);
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.08);
}
.p-tab.is-active,
.p-tab[aria-selected="true"]{
  color: var(--text);
  background: rgba(59,130,246,.14);
  border-color: rgba(59,130,246,.26);
}
.p-tabs__panes{ padding: 12px; }
.p-pane{ display: none; }
.p-pane.is-active{ display: block; }

/* Pane typography */
.p-prose{
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}
.p-prose p{ margin: 0 0 10px; }
.p-prose p:last-child{ margin-bottom: 0; }
.p-prose a{ text-decoration: underline; text-underline-offset: 2px; }
.p-prose hr{
  border: 0;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}
.p-prose ul, .p-prose ol{ margin: 8px 0 8px 18px; }
.p-prose li{ margin: 4px 0; }
.p-prose .muted{ color: var(--muted); }

/* Details grid (optional; use for About/Appearance/Details panes) */
.p-kv{
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 12px;
  align-items: start;
}
@media (max-width: 560px){
  .p-kv{ grid-template-columns: 1fr; }
}
.p-kv__k{
  color: var(--muted);
  font-size: 12px;
}
.p-kv__v{
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.p-kv__row{
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.02);
}

/* -------------------------
   GALLERY (updated for .p-media markup)
------------------------- */
.p-gallery{
  display: grid;
  gap: 12px;
}

.p-gallery__section{
  display: grid;
  gap: 10px;
}

.p-gallery__hd{
  display: grid;
  gap: 4px;
  padding: 6px 2px 0;
}
.p-gallery__title{
  font-weight: 800;
  letter-spacing: -0.01em;
}
.p-gallery__sub{
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.p-gallery__hint{
  color: var(--muted);
  font-size: 12px;
}

/* Grid responsive */
.p-gallery__grid{
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 1100px){
  .p-gallery__grid{ grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 920px){
  .p-gallery__grid{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px){
  .p-gallery__grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .p-gallery__grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* New gallery tile (.p-media) */
.p-media{
  position: relative;
  display: grid;
  gap: 8px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
  text-decoration: none;
  min-height: 92px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}

.p-media__thumb{
  position: relative;
  background: rgba(0,0,0,.28);
  overflow: hidden;
}

/* Make thumbs consistent even if meta expands */
.p-media__thumb img{
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform .18s ease, filter .18s ease;
}
.p-media:hover .p-media__thumb img{
  transform: scale(1.03);
  filter: saturate(1.08) contrast(1.02);
}

/* Meta area */
.p-media__meta{
  padding: 8px 10px 10px;
  display: grid;
  gap: 2px;
}

.p-media__t{
  font-size: 12px;
  color: rgba(255,255,255,.86);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.p-media__d{
  font-size: 11px;
  color: var(--muted);
}

/* SEO description (your injected .p-media__seo) */
.p-media__seo{
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255,255,255,.74);
  opacity: 1;
  max-height: 3.95em;         /* clamp feel without needing -webkit-line-clamp */
  overflow: hidden;
}

/* Optional: only show SEO paragraph on hover for dense grids */
@media (max-width: 720px){
  .p-media__seo{ display:none; }
}

/* Small overlay chip (auto, if you add later) */
.p-media__chip{
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.40);
  color: rgba(255,255,255,.90);
  font-size: 11px;
  line-height: 1;
  backdrop-filter: blur(6px);
}

/* Backward-compatible old gallery tiles (.p-gItem) */
.p-gItem{
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.28);
  cursor: pointer;
  min-height: 86px;
}
.p-gItem__btn{
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  display: block;
  width: 100%;
  height: 100%;
}
.p-gItem__img{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 1 / 1;
  transform: scale(1.001);
  transition: transform .18s ease, filter .18s ease;
}
.p-gItem:hover .p-gItem__img{
  transform: scale(1.03);
  filter: saturate(1.08) contrast(1.02);
}

/* Skeleton (when lazy-loading) */
.p-skel{
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(255,255,255,.03), rgba(255,255,255,.07), rgba(255,255,255,.03));
  background-size: 180% 180%;
  animation: pShimmer 1.2s ease-in-out infinite;
  aspect-ratio: 1 / 1;
}
@keyframes pShimmer{
  0%{ background-position: 0% 50%; }
  100%{ background-position: 100% 50%; }
}

/* Empty state */
.p-empty{
  padding: 12px;
  border: 1px dashed rgba(148,163,184,.28);
  border-radius: 16px;
  background: rgba(255,255,255,.02);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* -------------------------
   OFFLINE OVERLAY (for player)
------------------------- */
.p-videoBox.is-offline::after{
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 120% at 50% 10%, rgba(0,0,0,.15), rgba(0,0,0,.78));
  pointer-events: none;
}
.p-offline{
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  text-align: center;
  z-index: 3;
}
.p-videoBox.is-offline .p-offline{ display: grid; }

.p-offline__card{
  max-width: 520px;
  width: 100%;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.38);
  border-radius: 18px;
  padding: 14px 14px 12px;
  box-shadow: 0 22px 70px rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
}
.p-offline__title{
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: rgba(255,255,255,.92);
  font-weight: 800;
}
.p-offline__sub{
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255,255,255,.68);
  line-height: 1.5;
}
.p-offline__actions{
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* -------------------------
   MODAL (image/video viewer)
   Your actual HTML uses:
   #imgModal.p-modal
     .p-modal__backdrop
     .p-modal__panel (dialog container)
       .p-modal__close
       .p-modal__head
         .p-modal__meta (.p-modal__title/.p-modal__sub)
         .p-modal__nav (buttons)
       .p-modal__img
       .p-modal__vid
------------------------- */
.p-modal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
}
.p-modal.is-open{ display: block; }

.p-modal__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.68);
  backdrop-filter: blur(6px);
}

/* Panel is the actual "box" */
.p-modal__panel{
  position: absolute;
  inset: 0;
  padding: 18px;
  display: grid;
  place-items: center;
}
@media (max-width: 520px){
  .p-modal__panel{ padding: 12px; }
}

.p-modal__panel{
  /* Make it the box */
  width: 100%;
  height: 100%;
}

/* Inner dialog surface: we style the panel's direct children layout */
.p-modal__panel{
  /* use pseudo container by styling children */
}

/* We'll style the dialog content by targeting the actual elements */
#imgModal .p-modal__panel{
  display: grid;
  grid-template-rows: auto 1fr;
  place-items: center;
  align-content: center;
}

#imgModal .p-modal__head{
  width: min(1100px, 100%);
  border-radius: 18px 18px 0 0;
  border: 1px solid rgba(255,255,255,.14);
  border-bottom: 0;
  background: rgba(10,14,25,.92);
  box-shadow: 0 30px 90px rgba(0,0,0,.60);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

#imgModal .p-modal__meta{
  display: grid;
  gap: 2px;
  min-width: 0;
}
#imgModal .p-modal__title{
  font-size: 12px;
  color: rgba(255,255,255,.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(760px, 68vw);
}
#imgModal .p-modal__sub{
  font-size: 12px;
  color: rgba(255,255,255,.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(760px, 68vw);
}

#imgModal .p-modal__nav{
  display: flex;
  gap: 8px;
  align-items: center;
}

#imgModal .p-modal__navBtn,
#imgModal .p-modal__close{
  appearance: none;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.90);
  width: 40px;
  height: 38px;
  border-radius: 12px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
#imgModal .p-modal__navBtn:hover,
#imgModal .p-modal__close:hover{ background: rgba(255,255,255,.10); }

#imgModal .p-modal__close{
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 2;
}
@media (max-width: 520px){
  #imgModal .p-modal__close{ right: 12px; top: 12px; }
}

#imgModal .p-modal__img,
#imgModal .p-modal__vid{
  width: min(1100px, 100%);
  max-height: min(78vh, 860px);
  border-radius: 0 0 18px 18px;
  border: 1px solid rgba(255,255,255,.14);
  border-top: 0;
  background: #000;
  box-shadow: 0 30px 90px rgba(0,0,0,.60);
  object-fit: contain;
  display: block;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .p-gItem__img{ transition: none; }
  .p-media__thumb img{ transition: none; }
  .p-skel{ animation: none; }
  .btn:active{ transform: none; }
}

/* Focus rings */
:where(.btn, .p-tab, .p-modal__close, .p-modal__navBtn, .p-hero__mediaBtn, .p-gItem__btn, .p-media):focus{
  outline: none;
}
:where(.btn, .p-tab, .p-modal__close, .p-modal__navBtn, .p-hero__mediaBtn, .p-gItem__btn, .p-media):focus-visible{
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}

/* Utilities */
.p-hide{ display: none !important; }
.p-center{ display: grid; place-items: center; }
.p-muted{ color: var(--muted) !important; }

.p-divider{
  height: 1px;
  background: var(--line);
  margin: 12px 0;
  border: 0;
}
