/* ═══════════════════════════════════════════════════════════════════
   MyTemple Admin — Decorative Animations
   These keyframes can't be expressed as Tailwind utilities.
   Everything else uses Tailwind classes in the ERB templates.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Floating lotus petals ─────────────────────────────────────── */
@keyframes petal-fall {
  0%   { transform: translateY(-40px) rotate(0deg); opacity: 0; }
  10%  { opacity: var(--po, 0.07); }
  85%  { opacity: var(--po, 0.07); }
  100% { transform: translateY(calc(100vh + 40px)) rotate(540deg); opacity: 0; }
}
@keyframes petal-sway {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(var(--drift, 20px)); }
}

/* ── Garland bells ─────────────────────────────────────────────── */
@keyframes bell-tinkle {
  0%, 85%, 100% { transform: rotate(0); }
  88%  { transform: rotate(5deg); }
  92%  { transform: rotate(-4deg); }
  96%  { transform: rotate(2deg); }
}
.bell-tinkle { transform-origin: top center; }
.bell-tinkle:nth-child(4n+1) { animation: bell-tinkle 6s ease-in-out infinite; }
.bell-tinkle:nth-child(4n+2) { animation: bell-tinkle 7s ease-in-out 0.5s infinite; }
.bell-tinkle:nth-child(4n+3) { animation: bell-tinkle 5s ease-in-out 1s infinite; }
.bell-tinkle:nth-child(4n)   { animation: bell-tinkle 8s ease-in-out 1.5s infinite; }

/* ── Dharma wheel spin ─────────────────────────────────────────── */
@keyframes dharma-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.dharma-spin { animation: dharma-spin 20s linear infinite; transform-origin: center; }

/* ── Prayer flags flutter ──────────────────────────────────────── */
@keyframes flag-flutter {
  0%, 100% { transform: skewX(0deg); }
  25%      { transform: skewX(2deg); }
  75%      { transform: skewX(-1.5deg); }
}
.flag-flutter { animation: flag-flutter 3s ease-in-out infinite; }
.flag-flutter:nth-child(4n+1) { animation-duration: 3s; }
.flag-flutter:nth-child(4n+2) { animation-duration: 3.5s; animation-delay: 0.4s; }
.flag-flutter:nth-child(4n+3) { animation-duration: 4s; animation-delay: 0.8s; }
.flag-flutter:nth-child(4n)   { animation-duration: 2.8s; animation-delay: 0.2s; }

/* ── Environment badge pulse (production) ─────────────────────── */
@keyframes env-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.env-pulse { animation: env-pulse 2s ease-in-out infinite; }

/* ── Sidebar active indicator ──────────────────────────────────── */
.sidebar-item { transition: all 0.15s ease; }
.sidebar-item:hover,
.sidebar-item:focus-visible { background: color-mix(in srgb, var(--side-accent) 5%, transparent); }
.sidebar-item.active { background: color-mix(in srgb, var(--side-accent) 9%, transparent); border-left-color: var(--side-accent); color: var(--side-accent); }

/* ── Collapsible sidebar (sidebar_controller.js) ───────────────
   --side-w is how much of the left edge the sidebar takes; the content and the
   decorations start there. Wide screens: shown unless the body carries
   data-nav-collapsed (from the `sidebar` cookie). Below 768px: hidden, and
   data-nav-open lays it over the page without moving the page. When hidden,
   the show button floats at the top of the content, so only the first block
   sits beside it and no empty column runs down the page. */
.admin-shell { --side-w: 184px; }
.admin-shell[data-nav-collapsed] { --side-w: 0px; }
.admin-main { transition: margin-left 0.2s ease; }
.admin-sidebar { transition: transform 0.2s ease, visibility 0.2s; }
.admin-shell[data-nav-collapsed] .admin-sidebar { transform: translateX(-100%); visibility: hidden; }
.admin-nav-show { display: none; float: left; margin: 0.5rem 0.5rem 0.25rem 0; }
.admin-shell[data-nav-collapsed] .admin-nav-show { display: inline-flex; }
.admin-nav-backdrop { display: none; }

@media (max-width: 767px) {
  .admin-shell, .admin-shell[data-nav-collapsed] { --side-w: 0px; }
  .admin-shell .admin-sidebar,
  .admin-shell[data-nav-collapsed] .admin-sidebar { transform: translateX(-100%); visibility: hidden; }
  .admin-shell .admin-nav-show { display: inline-flex; }
  /* Visible at once on opening (not after the transition), so focus can move into it. */
  .admin-shell[data-nav-open] .admin-sidebar { transition: transform 0.2s ease; transform: none; visibility: visible; box-shadow: 4px 0 16px color-mix(in srgb, var(--side) 40%, transparent); }
  .admin-shell[data-nav-open] .admin-nav-show { display: none; }
  .admin-shell[data-nav-open] .admin-nav-backdrop { display: block; }
}

/* ── Dashboard tab bar: the controller only toggles `active` ───── */
.dashboard-tab.active { color: var(--highlight-ink); border-left-color: var(--highlight); }

/* ── Table row striping ────────────────────────────────────────── */
.admin-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-alt) 40%, transparent); }
.admin-table tbody tr:hover { background: var(--surface-alt); }

/* ── Form layout classes ──────────────────────────────────────── */
.admin-form-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.admin-form-field {
  flex: 1;
  min-width: 0;
}
.admin-hint {
  font-size: 9px;
  color: var(--ink-faint);
  margin-top: 2px;
}
.admin-field-error {
  font-size: 9px;
  color: var(--warn);
  margin-top: 2px;
}

.admin-checkbox {
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  color: var(--accent);
  accent-color: var(--accent);
}
.admin-checkbox:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.admin-checkbox:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Form input classes ───────────────────────────────────────── */
.admin-input {
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--ink);
  font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif;
  width: 100%;
}
.admin-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent);
}
.admin-input:disabled { opacity: 0.6; cursor: not-allowed; }
.admin-input::placeholder {
  color: var(--ink-faint);
}
.admin-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  width: 7rem;
  min-width: 7rem;
  text-align: right;
  flex-shrink: 0;
}
/* An image drop zone with a file dragged over it (image_upload_controller.js). A class of its
   own, in this unlayered sheet, so it wins over the zone's resting border-line utility. */
.admin-dropzone-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.admin-input-error {
  border-color: var(--warn);
}
.admin-input-error:focus {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warn) 20%, transparent);
}
