/**
 * Template Showcase — custom polish (animations, scroll reveals, shared utilities)
 * Theme-specific colors live in each HTML file via Tailwind config extend + utilities.
 */

/* Skip link — visible on keyboard focus (SEO + accessibility) */
.skip-to-main {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  background: #4f46e5;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15);
}
.skip-to-main:focus {
  left: 1rem;
  top: 1rem;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Smooth scroll for in-page anchor navigation */
html {
  scroll-behavior: smooth;
}

html.dark {
  color-scheme: dark;
}

/* Mobile nav open — reduce background scroll (optional; paired with showcase.js) */
body.nav-mobile-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Reusable hover lift for cards (use with Tailwind transition classes) */
.hover-lift {
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s ease;
}
.hover-lift:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.18);
}

/* Scroll-triggered fade (paired with showcase.js) */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Focus rings for keyboard users */
:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* Placeholder image blocks — consistent ratio */
.img-placeholder {
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

/* Gallery card: live template preview (iframe scaled to card — see index.html) */
.showcase-card-preview__scale {
  pointer-events: none;
}
.showcase-card-preview__scale iframe {
  display: block;
}

/* -------------------------------------------------------------------------- */
/* Accessibility panel (Studio Layouts gallery) + preference classes on html  */
/* -------------------------------------------------------------------------- */

html[data-a11y-font="110"] {
  font-size: 110%;
}
html[data-a11y-font="125"] {
  font-size: 125%;
}
html[data-a11y-font="140"] {
  font-size: 140%;
}

html.a11y-high-contrast body {
  filter: contrast(1.18) saturate(1.12);
}
html.dark.a11y-high-contrast body {
  filter: contrast(1.22) saturate(1.08);
}

html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

html.a11y-underline-links a {
  text-decoration: underline !important;
  text-underline-offset: 0.15em;
}

html.a11y-readable-font body {
  font-family:
    system-ui,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif !important;
}

html.a11y-readable-font .font-display {
  font-family: Georgia, "Times New Roman", serif !important;
}

html.a11y-strong-focus :focus-visible {
  outline: 3px solid currentColor !important;
  outline-offset: 4px !important;
}

/* Floating tab */
.showcase-a11y-tab {
  position: fixed;
  right: 0;
  top: 50%;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 0.5rem 0.65rem 0.75rem;
  border: none;
  border-radius: 0.5rem 0 0 0.5rem;
  background: #312e81;
  color: #e0e7ff;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: -4px 4px 24px rgba(15, 23, 42, 0.35);
  transform: translateY(-50%);
  transition: background 0.2s ease, color 0.2s ease, padding 0.2s ease;
}

.showcase-a11y-tab:hover {
  background: #4338ca;
  color: #fff;
}

.showcase-a11y-tab:focus-visible {
  outline: 3px solid #a5b4fc;
  outline-offset: 2px;
}

html.dark .showcase-a11y-tab {
  background: #4f46e5;
  color: #eef2ff;
}

html.dark .showcase-a11y-tab:hover {
  background: #6366f1;
}

.showcase-a11y-tab__icon {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
}

.showcase-a11y-tab__label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  max-height: 8.5rem;
  line-height: 1.2;
}

@media (max-width: 640px) {
  .showcase-a11y-tab__label {
    max-height: 6rem;
    font-size: 0.7rem;
  }
}

/* Backdrop + drawer */
.showcase-a11y-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.showcase-a11y-root.is-open .showcase-a11y-backdrop {
  opacity: 1;
  visibility: visible;
}

.showcase-a11y-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 120;
  height: 100%;
  width: 100%;
  max-width: 22rem;
  background: #f8fafc;
  color: #0f172a;
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.2);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}

html.dark .showcase-a11y-drawer {
  background: #0f172a;
  color: #f1f5f9;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
}

.showcase-a11y-root.is-open .showcase-a11y-drawer {
  transform: translateX(0);
}

.showcase-a11y-drawer__inner {
  padding: 1.25rem 1.25rem 2rem;
}

.showcase-a11y-drawer header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.showcase-a11y-drawer h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.showcase-a11y-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  background: #fff;
  color: #334155;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

html.dark .showcase-a11y-close {
  border-color: #475569;
  background: #1e293b;
  color: #e2e8f0;
}

.showcase-a11y-close:hover {
  background: #f1f5f9;
}

html.dark .showcase-a11y-close:hover {
  background: #334155;
}

.showcase-a11y-intro {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #475569;
}

html.dark .showcase-a11y-intro {
  color: #94a3b8;
}

.showcase-a11y-fieldset {
  margin: 0 0 1.25rem;
  padding: 0;
  border: none;
}

.showcase-a11y-fieldset legend {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 0.5rem;
}

html.dark .showcase-a11y-fieldset legend {
  color: #94a3b8;
}

.showcase-a11y-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.showcase-a11y-seg button {
  flex: 1 1 calc(50% - 0.25rem);
  min-width: 5rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  background: #fff;
  color: #0f172a;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

html.dark .showcase-a11y-seg button {
  border-color: #475569;
  background: #1e293b;
  color: #f1f5f9;
}

.showcase-a11y-seg button[aria-pressed="true"] {
  border-color: #4f46e5;
  background: #eef2ff;
  color: #312e81;
}

html.dark .showcase-a11y-seg button[aria-pressed="true"] {
  border-color: #818cf8;
  background: #312e81;
  color: #e0e7ff;
}

.showcase-a11y-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
  line-height: 1.4;
  cursor: pointer;
}

.showcase-a11y-check input {
  margin-top: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: #4f46e5;
  flex-shrink: 0;
}

.showcase-a11y-reset {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px dashed #94a3b8;
  border-radius: 0.375rem;
  background: transparent;
  color: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.showcase-a11y-reset:hover {
  border-style: solid;
  background: rgba(148, 163, 184, 0.15);
}

body.showcase-a11y-panel-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .showcase-a11y-backdrop,
  .showcase-a11y-drawer {
    transition-duration: 0.01ms !important;
  }
}
