/* =========================================================================
   Panya — page tokens + gallery-specific layout
   ========================================================================= */

:root {
  color-scheme: dark;
  --brand: #ff5c4d;
  --brand-2: #ff7a6b;
  --brand-soft: rgba(255, 92, 77, 0.1);
  --brand-border: rgba(255, 92, 77, 0.28);
  --primary: var(--brand);
  --primary-h: #ff7a6b;
  --primary-light: var(--brand-soft);
  --primary-border: var(--brand-border);

  --bg: #0a0a0b;
  --sidebar-bg: #0d0d0f;
  --panel: #121214;
  --panel-2: #17171a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --muted-2: #71717a;
  --topbar-bg: rgba(10, 10, 11, 0.86);
  --success: #22c55e;
  --danger: #ef4444;
  --page-glow: rgba(255, 92, 77, 0.12);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Inter", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  --topbar-h: 64px;
  --sidebar-w: 248px;
}

/* ---------- Hero ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
  color: var(--brand);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.small {
  font-size: 0.64rem;
}

.hero {
  padding: 8px 0 0;
  max-width: 820px;
}

.hero h1 {
  font-size: clamp(2rem, 4.6vw, 3.6rem);
  letter-spacing: -0.045em;
  line-height: 1.06;
}

.hero-text {
  max-width: 620px;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: clamp(0.96rem, 1.4vw, 1.08rem);
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 22px;
}

/* ---------- Gallery ---------- */
.gallery-section {
  margin-top: 40px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.count {
  color: var(--muted-2);
  font-size: 0.78rem;
  white-space: nowrap;
}

.masonry {
  columns: 4 240px;
  column-gap: 14px;
  column-fill: balance;
}

.card {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 14px;
  overflow: hidden;
  break-inside: avoid;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.2);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--brand-border);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.card-media {
  position: relative;
  overflow: hidden;
  background: #09090b;
}

.card-media img,
.card-media video {
  display: block;
  width: 100%;
  height: auto;
  background: #09090b;
}

.card-media video {
  max-height: 560px;
  object-fit: contain;
}

.badge {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(10, 10, 11, 0.7);
  color: var(--text);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  backdrop-filter: blur(10px);
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

.badge.video::before {
  background: var(--brand-2);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
}

.card-caption {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-caption.muted {
  color: var(--muted-2);
  font-weight: 400;
}

.card-meta {
  margin: 0;
  color: var(--muted-2);
  font-size: 0.72rem;
  line-height: 1.4;
}

/* ---------- States ---------- */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 3rem 1.25rem;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(127, 127, 127, 0.035);
  text-align: center;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.06);
  color: var(--brand);
  font-size: 1.3rem;
  font-weight: 700;
}

.state-icon .icon {
  width: 20px;
  height: 20px;
}

.state h3 {
  margin: 0 0 0.4rem;
  font-size: 1.12rem;
}

.state p {
  max-width: 540px;
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.75;
}

.state.error .state-icon {
  color: var(--danger);
}

.state.error p {
  color: #ffb5bf;
  white-space: pre-wrap;
}

.state.no-results {
  border-style: solid;
}

/* ---------- Skeletons ---------- */
.skeleton-card {
  pointer-events: none;
}

.skeleton-media,
.skeleton-line {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.035) 25%,
    rgba(255, 255, 255, 0.08) 37%,
    rgba(255, 255, 255, 0.035) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.5s ease infinite;
}

.skeleton-media {
  width: 100%;
  min-height: 180px;
}

.skeleton-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem;
}

.skeleton-line {
  height: 0.75rem;
  border-radius: 999px;
}

.skeleton-line.short {
  width: 52%;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* ---------- Upload modal ---------- */
.modal,
.viewer {
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop,
.viewer::backdrop {
  background: rgba(3, 3, 5, 0.76);
  backdrop-filter: blur(9px);
}

.modal form {
  padding: 1.4rem;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 1.5rem 1rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(127, 127, 127, 0.035);
  text-align: center;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragging {
  border-color: var(--brand-border);
  background: var(--brand-soft);
}

.dropzone.dragging {
  transform: scale(1.01);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.06);
  color: var(--brand);
}

.drop-icon .icon {
  width: 20px;
  height: 20px;
}

.drop-title {
  margin: 0;
  font-weight: 600;
}

.drop-hint {
  margin: 0.35rem 0 0;
  color: var(--muted-2);
  font-size: 0.82rem;
}

.file-info {
  max-width: 100%;
  margin: 0.9rem 0 0;
  overflow: hidden;
  padding: 0.4rem 0.7rem;
  border: 1px solid rgba(34, 197, 94, 0.22);
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.07);
  color: var(--success);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 1.05rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.field textarea {
  width: 100%;
  resize: vertical;
  min-height: 86px;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  line-height: 1.6;
}

.field textarea::placeholder {
  color: var(--muted-2);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.progress {
  flex: 1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.14);
}

.progress > div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width 0.18s ease;
}

#progress-text {
  min-width: 2.6rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: end;
}

.form-error {
  margin: 0.9rem 0 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.08);
  color: #ffb5bf;
  font-size: 0.82rem;
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

/* ---------- Viewer ---------- */
.viewer {
  position: relative;
  width: min(1120px, calc(100vw - 1.5rem));
  overflow: hidden;
  background: #08080a;
}

.viewer-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34vh;
  max-height: calc(100dvh - 150px);
  background:
    radial-gradient(600px 300px at 50% 0%, rgba(255, 92, 77, 0.08), transparent 70%),
    #08080a;
}

.viewer-stage img,
.viewer-stage video {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 150px);
  object-fit: contain;
}

.viewer-close {
  position: absolute;
  top: 0.8rem;
  inset-inline-end: 0.8rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(10, 10, 11, 0.7);
  color: var(--text);
  backdrop-filter: blur(10px);
}

.viewer-close:hover {
  background: rgba(127, 127, 127, 0.16);
}

.viewer-close .icon {
  width: 18px;
  height: 18px;
}

.viewer-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.2rem 1.1rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.viewer-caption {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

.viewer-meta {
  flex: none;
  color: var(--muted-2);
  font-size: 0.72rem;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 80;
  inset-inline: 1rem;
  bottom: 1.25rem;
  width: fit-content;
  max-width: min(520px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 0.8rem 1.1rem;
  border: 1px solid rgba(34, 197, 94, 0.24);
  border-radius: 999px;
  background: rgba(10, 22, 14, 0.92);
  color: #d9ffe4;
  font-size: 0.84rem;
  line-height: 1.5;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
  transform: translateY(14px);
  opacity: 0;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ---------- Panya responsive ---------- */
@media (max-width: 1100px) {
  .masonry {
    columns: 3 220px;
  }
}

@media (max-width: 900px) {
  .hero {
    padding-top: 0;
  }

  .masonry {
    columns: 2 160px;
    column-gap: 10px;
  }

  .card {
    margin-bottom: 10px;
    border-radius: 10px;
  }

  .card-body {
    padding: 10px 11px 12px;
  }

  .card-caption {
    font-size: 0.84rem;
  }

  .section-head {
    margin-bottom: 14px;
  }

  .modal form {
    padding: 1.1rem;
  }

  .modal,
  .viewer {
    border-radius: 12px;
  }

  .viewer-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
}

@media (max-width: 560px) {
  .masonry {
    columns: 1;
  }

  .hero-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-tag {
    display: none;
  }
}
