/* Reusable components: buttons, cards, inputs, modal, toast, avatar */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--font-size-md);
  white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--color-accent);
  color: var(--color-brand-yellow-text);
  box-shadow: var(--shadow-accent);
}
.btn--primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.btn--secondary {
  background: var(--color-bg-elevated-2);
  color: var(--color-text);
  border: 1.5px solid var(--color-border-strong);
}
.btn--secondary:hover:not(:disabled) { border-color: var(--color-text-secondary); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: var(--space-2) var(--space-3);
}
.btn--ghost:hover:not(:disabled) { color: var(--color-text); }

.btn--block { width: 100%; }
.btn--sm { padding: var(--space-2) var(--space-4); font-size: var(--font-size-sm); }
.btn--lg { padding: var(--space-4) var(--space-6); font-size: var(--font-size-lg); }

/* ---- Cards ---- */
.card {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.card--hoverable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card--interactive {
  cursor: pointer;
  text-align: right;
  width: 100%;
  display: block;
}

/* ---- Inputs ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.input, .textarea, select.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-bg-elevated);
  font-size: var(--font-size-md);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.input:focus, .textarea:focus, select.input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px var(--color-accent-soft);
}

.textarea {
  resize: vertical;
  min-height: 90px;
  font-family: inherit;
}

.input--search {
  padding-inline-start: var(--space-5);
  font-size: var(--font-size-lg);
  border-radius: var(--radius-pill);
}

/* ---- Avatar ----
   Ring uses the brand gradient (double-background border trick): the inner
   layer paints the flat fill, the outer layer paints the gradient, clipped
   so only the border-width sliver of it shows — an Instagram-story-ring look. */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--color-accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-sm);
  overflow: hidden;
  border: 2px solid transparent;
  background-image: linear-gradient(var(--color-bg-elevated-2), var(--color-bg-elevated-2)), var(--gradient-brand);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Slightly bigger ring for the header's brand mark (real profile photo) */
.avatar--lg {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  z-index: 100;
}

.modal {
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: var(--container-max);
  max-height: 92vh;
  overflow-y: auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
  position: relative;
}

.modal__close {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-bg-elevated-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
}
.modal__close:hover { background: var(--color-border-strong); color: var(--color-text); }

.modal__title {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-2);
}

.modal__subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-5);
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: var(--space-4); }
  .modal { border-radius: var(--radius-lg); max-height: 88vh; }
}

/* ---- Toast ---- */
.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  right: 50%;
  transform: translateX(50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: calc(100% - var(--space-6));
  max-width: 420px;
  align-items: center;
}

.toast {
  background: var(--color-bg-elevated-2);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-align: center;
}

.toast--success { background: var(--color-success); }
.toast--error { background: var(--color-danger); }

/* ---- Ranking table ---- */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rank-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
}

.rank-row__pos {
  width: 32px;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.rank-row--top .rank-row__pos { color: var(--color-accent); }

/* The #1 spot wears the brand's real gradient ring as a "spotlight" —
   the same signature used on the logged-in avatar, so it reads as one
   consistent idea: this is the one currently winning. */
.rank-row--champion {
  border: 2px solid transparent;
  background-image: linear-gradient(var(--color-bg-elevated), var(--color-bg-elevated)), var(--gradient-brand);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.rank-row--champion .rank-row__pos { color: var(--color-accent); }

.rank-row__name {
  flex: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row__votes {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ---- Badge / pill ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 700;
  background: var(--color-accent-soft);
  color: var(--color-accent-text);
}

.badge--muted {
  background: var(--color-border);
  color: var(--color-text-secondary);
}

/* Punchy brand-yellow badge — for "featured" / "most popular" style tags,
   echoing the channel's bold yellow-banner thumbnails. Used sparingly. */
.badge--brand {
  background: var(--color-brand-yellow);
  color: var(--color-brand-yellow-text);
  font-weight: 800;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-text-secondary);
}

.empty-state__emoji {
  font-size: 40px;
  margin-bottom: var(--space-3);
}

/* ---- Auth modal ---- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  text-align: center;
}

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

.auth-tabs {
  display: flex;
  background: var(--color-bg);
  border-radius: var(--radius-pill);
  padding: var(--space-1);
  gap: var(--space-1);
}

.auth-tab {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.auth-tab.is-active {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ---- Header user (name + direct sign-out, no photo/dropdown) ---- */
.header-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-user__name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .header-user__name { display: none; }
}

/* ---- Spinner ---- */
.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner--dark {
  border-color: var(--color-border-strong);
  border-top-color: var(--color-accent);
}

/* ---- Accessibility widget ("עיגול נגישות") ---- */
.a11y-widget {
  position: fixed;
  bottom: var(--space-5);
  left: var(--space-5);
  z-index: 60;
}

.a11y-widget__toggle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-text);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}

.a11y-widget__panel {
  position: absolute;
  bottom: calc(100% + var(--space-3));
  left: 0;
  width: 240px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.a11y-widget__title {
  font-weight: 700;
  margin-bottom: var(--space-1);
}

.a11y-widget__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-sm);
}

.a11y-widget__row-actions {
  display: flex;
  gap: var(--space-2);
}

.a11y-widget__row-actions button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-elevated-2);
  font-weight: 700;
}

.a11y-widget__option {
  text-align: right;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  background: var(--color-bg-elevated-2);
}

.a11y-widget__option.is-active {
  background: var(--color-accent-soft);
  color: var(--color-accent-text);
  font-weight: 700;
}

.a11y-widget__statement {
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

/* Preference effects, toggled on <html> by accessibility-widget.js */
.a11y-high-contrast {
  filter: contrast(1.35) saturate(1.1);
}

.a11y-underline-links a {
  text-decoration: underline !important;
}

.a11y-stop-animations *,
.a11y-stop-animations *::before,
.a11y-stop-animations *::after {
  animation: none !important;
  transition: none !important;
}
