/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--border-strong);
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--accent-ink);
  border-color: transparent;
}

.btn--primary:hover {
  color: var(--accent-ink);
  border-color: transparent;
  filter: brightness(1.05);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn--danger {
  background: var(--danger-soft);
  border-color: rgb(239 100 97 / 0.4);
  color: var(--danger);
}

.btn--danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn--block {
  width: 100%;
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Forms */
.field {
  display: grid;
  gap: 8px;
}

.field > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input:not([type]),
textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming into the field */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

input::placeholder,
textarea::placeholder {
  color: #5f5e6c;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Segmented control (movie / series) */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
}

.segmented label:has(input:checked) span {
  background: var(--surface-3);
  color: var(--text);
}

.segmented label:has(input:focus-visible) span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tabs (sign in / create account) */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  background: var(--surface-3);
  color: var(--text);
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 0.1);
  background: rgb(255 255 255 / 0.06);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chip--accent {
  background: rgb(231 179 90 / 0.14);
  border-color: rgb(231 179 90 / 0.35);
  color: var(--accent);
}

/* Panels and stats */
.panel {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel h2 {
  margin-bottom: 14px;
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel__head h2 {
  margin: 0;
}

.prose {
  white-space: pre-wrap;
  color: #d8d6e0;
}

.danger-zone {
  border-color: rgb(239 100 97 / 0.3);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.stat {
  display: grid;
  gap: 2px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat__value {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stat__label {
  font-size: 0.85rem;
  color: var(--muted);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-of-type {
  border-bottom: 0;
}

/* Poster-style project cards */
.poster-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.poster-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  color: var(--text);
}

.poster-card__art {
  position: relative;
  aspect-ratio: 16 / 9;
}

.poster-card__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(8 8 12 / 0.92), transparent 65%);
}

.poster-card__meta {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 1;
  display: grid;
  gap: 8px;
}

.poster-card__meta h3 {
  margin: 0;
  font-size: 1.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poster-card__body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.poster-card__body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.poster--1 {
  background: var(--poster-1);
}

.poster--2 {
  background: var(--poster-2);
}

.poster--3 {
  background: var(--poster-3);
}

.poster--4 {
  background: var(--poster-4);
}

/* Project hero band */
.project-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 200px;
  padding: 24px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.project-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(8 8 12 / 0.9), transparent 70%);
}

.project-hero__meta {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.project-hero__meta h1 {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (min-width: 900px) {
  .project-hero {
    min-height: 260px;
    padding: 32px;
  }
}

/* Empty and loading states */
.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty h3 {
  color: var(--text);
  margin: 0;
}

.empty p {
  margin: 0 0 6px;
  max-width: 36ch;
}

.skeleton {
  min-height: 240px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.skeleton--short {
  min-height: 120px;
}

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

/* Dialog (bottom sheet on phones, centred on desktop) */
.dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(4px);
}

.dialog__body {
  padding: 24px;
}

.dialog__body h2 {
  margin-bottom: 4px;
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

@media (max-width: 599px) {
  .dialog {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    width: 100%;
    max-width: none;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .dialog__actions .btn {
    flex: 1;
  }
}

/* Sidebar navigation (desktop) */
.sidebar__brand {
  padding: 4px 10px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav a,
.tabbar a {
  color: var(--muted);
  font-weight: 600;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
}

.nav a:hover,
.tabbar a:hover {
  color: var(--text);
}

.nav a.is-active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav svg,
.tabbar svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar__footer {
  margin-top: auto;
  padding: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* Bottom tab bar (phones) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgb(12 12 18 / 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.75rem;
}

.tabbar a.is-active {
  color: var(--accent);
}

/* Declared after the base rules so the tab bar stays hidden on desktop */
@media (min-width: 900px) {
  .tabbar {
    display: none;
  }
}

/* Auth screen */
.auth {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.auth__hero {
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  gap: 14px;
  padding: 56px;
  position: relative;
  overflow: hidden;
  background: var(--poster-1);
}

.auth__hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(8 8 12 / 0.92), transparent 70%);
}

.auth__hero > * {
  position: relative;
  z-index: 1;
}

.auth__hero h1 {
  font-size: clamp(2.2rem, 3.6vw, 3.4rem);
  max-width: 14ch;
}

.auth__hero ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  color: #e9e6dc;
}

.auth__hero li::before {
  content: "— ";
  color: var(--accent);
}

.auth__panel {
  display: grid;
  place-items: center;
  padding: 40px var(--gutter);
}

.auth__card {
  width: 100%;
  max-width: 420px;
}

.auth__card h1 {
  font-size: 1.7rem;
  margin-bottom: 20px;
}

.auth__card .btn {
  width: 100%;
}

.auth__card form {
  margin-bottom: 18px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

@media (min-width: 900px) {
  .auth {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  }

  .auth__hero {
    display: flex;
  }

  .auth__panel {
    padding: 56px;
  }
}

/* Account page */
.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  min-width: 0;
}

.profile h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.profile p {
  margin: 0;
  overflow-wrap: anywhere;
}

.avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--accent-ink);
  font-size: 1.3rem;
  font-weight: 800;
}

/* Toasts */
.toasts {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tabbar-height) + 16px + env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}

@media (min-width: 900px) {
  .toasts {
    bottom: 24px;
  }
}

.toast {
  padding: 12px 14px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: toast-in 0.25s ease;
}

.toast--success {
  border-left-color: var(--success);
}

.toast--error {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
