/* ========================================
   Reveal & Layout Page
   ======================================== */

:root {
  --bg-dark: #0d0d0f;
  --bg-panel: #16161a;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text-primary: #f3f3f5;
  --text-secondary: #b5b5bd;
  --text-muted: #7c7c86;
  --text-faint: #55555f;
  --wash: rgba(255, 255, 255, 0.03);
  --accent: #7c5cff;
  --accent-glow: rgba(124, 92, 255, 0.35);
  --cat: #7fc095;
  --font-display: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-variable: 'Roboto Flex', system-ui, sans-serif;
  --radius: 12px;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-display);
  overflow-x: hidden;
  cursor: default; /* Standard cursor for layout page */
}

/* Cursor Glow (reused) */
.cursor-glow {
  position: fixed; width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none; transform: translate(-50%, -50%);
  z-index: 9999; opacity: 0; transition: opacity 0.15s ease;
}
body.show-cursor-glow .cursor-glow { opacity: 1; }

/* Nav (Consistent) */
.nav-bar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.15rem;
  z-index: 1000;
  padding: 0.28rem;
  background: rgba(13, 13, 15, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
}

.nav-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  text-decoration: none;
}

.nav-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.nav-btn.is-active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.nav-btn svg { width: 18px; height: 18px; }

/* Header */
.layout-header {
  padding: clamp(2rem, 5vw, 4rem) 1.5rem 2rem;
  text-align: center;
}
.layout-header h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 600; letter-spacing: -0.03em; margin: 0 0 0.25rem;
}
.layout-header .highlight {
  color: var(--text-secondary);
  font-weight: 500;
}
.tagline { color: var(--text-muted); font-size: 0.95rem; margin: 0; }

/* Main Grid */
.layout-main {
  max-width: 1200px; margin: 0 auto; padding: 0 1.5rem 4rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
}

.layout-block {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 240px;
}

/* Block Content Areas (Top part) */
.demo-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  position: relative;
  width: 100%;
  min-width: 0;
}

.block-info {
  padding: 1rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.2);
}
.block-info h2 { font-size: 1rem; margin: 0 0 0.25rem; color: var(--text-primary); }
.block-info p { font-size: 0.8rem; margin: 0; color: var(--text-muted); }

/* Common Buttons */
.trigger-btn {
  padding: 0.6rem 1.2rem;
  background: var(--accent); color: white;
  border: none; border-radius: 6px;
  font-weight: 600; cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.trigger-btn:hover { transform: scale(1.05); }
.trigger-btn:active { transform: scale(0.95); }

/* 1. Modal Global */
.modal-backdrop {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal-content {
  background: var(--bg-panel); border: 1px solid var(--border-subtle);
  padding: 2rem; border-radius: 16px;
  width: 90%; max-width: 400px;
  transform: scale(0.8);
  transition: transform 0.4s var(--ease-spring);
}
.modal-backdrop.open .modal-content { transform: scale(1); }
.close-modal { margin-top: 1rem; padding: 0.5rem 1rem; background: #333; color: #fff; border:none; border-radius: 6px; cursor: pointer; }

/* 2. Accordion */
.accordion { width: 100%; }
.acc-item { border-bottom: 1px solid var(--border-subtle); }
.acc-header { padding: 1rem 0; cursor: pointer; font-weight: 600; }
.acc-content {
  height: 0; overflow: hidden; color: var(--text-muted);
  transition: height 0.4s var(--ease-out);
}
.acc-item.active .acc-content { height: 60px; /* JS usually calculates this */ }

/* 3. Tabs */
.tabs-container { width: 100%; }
.tabs-nav { display: flex; position: relative; border-bottom: 1px solid var(--border-subtle); margin-bottom: 1rem; }
.tab-btn {
  flex: 1; padding: 0.8rem; background: none; border: none;
  color: var(--text-muted); cursor: pointer; position: relative; z-index: 1;
}
.tab-btn.active { color: var(--accent); }
.tab-indicator {
  position: absolute; bottom: 0; left: 0; height: 2px;
  background: var(--accent); width: 50%;
  transition: transform 0.3s var(--ease-out);
}
.tabs-content { position: relative; height: 40px; }
.tab-pane {
  position: absolute; top: 0; left: 0; width: 100%;
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
}
.tab-pane.active { opacity: 1; transform: translateY(0); }

/* 4. Flip Card */
.flip-card { width: 140px; height: 180px; perspective: 600px; cursor: pointer; }
.flip-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--ease-out);
}
.flip-card:hover .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute; width: 100%; height: 100%;
  backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border-subtle);
}
.flip-front { background: #222; }
.flip-back { background: var(--accent); transform: rotateY(180deg); color: #fff; }

/* 5. Off-canvas */
.side-panel {
  position: fixed; top: 0; right: 0; width: 280px; height: 100%;
  background: var(--bg-panel); border-left: 1px solid var(--border-subtle);
  z-index: 2001; padding: 2rem;
  transform: translateX(100%);
  transition: transform 0.4s var(--ease-out);
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}
.side-panel.open { transform: translateX(0); }
.side-panel ul { list-style: none; padding: 0; }
.side-panel li { margin: 1rem 0; border-bottom: 1px solid #333; padding-bottom: 0.5rem; }
.close-panel { position: absolute; top: 1rem; right: 1rem; background:none; border:none; color:#fff; font-size: 1.5rem; cursor: pointer; }

/* 6. Toast */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 3000; display: flex; flex-direction: column; gap: 1rem; }
.toast {
  background: var(--bg-panel); border: 1px solid var(--accent);
  padding: 1rem 1.5rem; border-radius: 8px;
  color: #fff; min-width: 200px;
  animation: slideIn 0.4s var(--ease-spring);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 7. Grid/List */
.layout-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  width: 100%; transition: opacity 0.3s;
}
.layout-grid.list-mode { grid-template-columns: 1fr; }
.l-item { height: 60px; background: #333; border-radius: 6px; }
.view-controls { margin-bottom: 1rem; display: flex; gap: 0.5rem; }
.view-btn { padding: 0.25rem 0.5rem; font-size: 0.8rem; background: transparent; border: 1px solid #555; color: #888; border-radius: 4px; cursor: pointer; }
.view-btn.active { border-color: var(--accent); color: var(--accent); }

/* 8. Expandable Card */
.expand-card {
  width: 100%; background: #222; border-radius: 8px; padding: 1rem;
  cursor: pointer; overflow: hidden;
  transition: all 0.4s var(--ease-out);
  max-height: 60px;
}
.expand-card.open { max-height: 200px; background: #2a2a30; }
.ec-header { display: flex; justify-content: space-between; align-items: center; }
.ec-header h3 { margin: 0; }
.ec-icon { transition: transform 0.4s; }
.expand-card.open .ec-icon { transform: rotate(45deg); }
.ec-content { margin-top: 1rem; opacity: 0; transition: opacity 0.3s 0.1s; }
.expand-card.open .ec-content { opacity: 1; }

/* 9. Stagger List */
.stagger-list-ui { list-style: none; padding: 0; width: 100%; }
.stagger-list-ui li {
  background: #333; padding: 0.5rem; margin-bottom: 0.5rem; border-radius: 4px;
  opacity: 0; transform: translateX(-20px);
}
.stagger-list-ui.show li {
  animation: staggerFade 0.5s var(--ease-out) forwards;
}
@keyframes staggerFade { to { opacity: 1; transform: translateX(0); } }

/* 10. Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: 100%; left: 0;
  background: var(--bg-panel); border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 0.5rem;
  display: flex; flex-direction: column; gap: 0.25rem;
  min-width: 120px;
  transform-origin: top left;
  transform: scale(0.8); opacity: 0; pointer-events: none;
  transition: all 0.2s var(--ease-out);
}
.dropdown.open .dropdown-menu { transform: scale(1); opacity: 1; pointer-events: auto; }
.dropdown-menu a { color: var(--text-muted); text-decoration: none; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.9rem; }
.dropdown-menu a:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* 11. Skeleton */
.skeleton-card { width: 100%; }
.sk-img { width: 100%; height: 100px; background: #222; border-radius: 6px; margin-bottom: 0.5rem; }
.sk-line { height: 12px; background: #222; border-radius: 4px; margin-bottom: 0.4rem; }
.w-80 { width: 80%; } .w-60 { width: 60%; }
.skeleton-card.loading .sk-img, .skeleton-card.loading .sk-line {
  background: linear-gradient(90deg, #222 25%, #333 50%, #222 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 12. FAB */
.fab-container { position: relative; width: 50px; height: 50px; }
.fab-main {
  width: 50px; height: 50px; border-radius: 50%; background: var(--accent);
  border: none; color: #fff; font-size: 1.5rem; cursor: pointer;
  position: relative; z-index: 2; transition: transform 0.3s;
}
/* Bottom-anchor the FAB so the expanded stack has room to grow upward.
   Centred, only (192-50)/2 = 71px sat above the button — not enough for the 96px stack. */
[data-fx="fab"] .demo-area { justify-content: flex-end; }

/* Actions stack directly above the button (bottom: 100%) instead of being pushed
   there by a fixed translateY(-100px). The old travel put the top mini button
   ~188px above the container, which overflowed the 240px demo-area and clipped it.
   Stack height now: 2*40 + 8 gap + 8 offset + 50 button = 146px, inside the ~192px box. */
.fab-actions {
  position: absolute; bottom: calc(100% + 0.5rem); left: 0; width: 100%;
  display: flex; flex-direction: column-reverse; align-items: center; gap: 0.5rem;
  z-index: 1;
}
.fab-mini {
  width: 40px; height: 40px; border-radius: 50%; background: #444; border: none; color: #fff;
  cursor: pointer;
  opacity: 0; transform: translateY(12px) scale(0.4);
  transition: opacity 0.25s var(--ease-out), transform 0.3s var(--ease-out);
}
.fab-container:hover .fab-main,
.fab-container:focus-within .fab-main { transform: rotate(45deg); }
.fab-container:hover .fab-mini,
.fab-container:focus-within .fab-mini { opacity: 1; transform: translateY(0) scale(1); }
/* Nearest button leads, so the stack unfurls upward */
.fab-container:hover .fab-mini:nth-child(2),
.fab-container:focus-within .fab-mini:nth-child(2) { transition-delay: 0.06s; }

/* 13. Carousel */
.carousel-snap {
  display: flex; gap: 1rem; overflow-x: auto; width: 100%; padding-bottom: 0.75rem;
  scroll-snap-type: x mandatory;
  cursor: grab;
  user-select: none;
  /* Windows/Chrome renders a white native scrollbar here otherwise */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) rgba(255, 255, 255, 0.08);
}
.carousel-snap::-webkit-scrollbar { height: 6px; }
.carousel-snap::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}
.carousel-snap::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}
.carousel-snap::-webkit-scrollbar-thumb:hover { background: #a78bfa; }
.carousel-snap::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.carousel-snap.dragging { cursor: grabbing; scroll-behavior: auto; }
.c-item {
  min-width: 80%; height: 120px; background: #333; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 2rem; color: #555;
  scroll-snap-align: center;
}

/* 14. Stepper */
.stepper { display: flex; align-items: center; width: 100%; justify-content: space-between; }
.step {
  width: 30px; height: 30px; border-radius: 50%; background: #222; border: 2px solid #444;
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
  transition: all 0.4s;
}
.step.active { border-color: var(--accent); color: var(--accent); background: rgba(124,92,255,0.1); }
.step-line { flex: 1; height: 2px; background: #333; margin: 0 0.5rem; position: relative; overflow: hidden; }
.step-line::after {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--accent); transform: translateX(-100%); transition: transform 0.5s ease-out;
}
.step.active + .step-line::after { transform: translateX(0); }

/* 15. Switch */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: #333; transition: .4s; border-radius: 34px;
}
.slider:before {
  position: absolute; content: ""; height: 20px; width: 20px;
  left: 4px; bottom: 4px; background-color: white; transition: .4s var(--ease-spring);
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(22px); }

/* 16. Input Float */
.input-group { position: relative; width: 100%; margin-top: 1rem; }
.input-group input {
  width: 100%; padding: 0.5rem 0; background: transparent; border: none; border-bottom: 1px solid #444;
  color: #fff; outline: none;
}
.input-group label {
  position: absolute; top: 0.5rem; left: 0; color: #666; pointer-events: none;
  transition: 0.3s ease; font-size: 1rem;
}
.input-group input:focus + label, .input-group input:not(:placeholder-shown) + label {
  top: -12px; font-size: 0.75rem; color: var(--accent);
}
.input-border {
  position: absolute; bottom: 0; left: 0; width: 0; height: 2px; background: var(--accent);
  transition: width 0.3s ease;
}
.input-group input:focus ~ .input-border { width: 100%; }

/* 17. Search Expand */
/* Collapsed width must equal padding + button, so the icon lands dead centre.
   Previously the input's unshrinkable 0.5rem margin was still taking part in the
   flex line, pushing the button off-centre inside the 40px pill. */
.search-box {
  display: flex; align-items: center; background: #222; border-radius: 20px;
  padding: 4px; width: 40px; transition: width 0.4s var(--ease-out); overflow: hidden;
}
.search-box:focus-within { width: 100%; }
.search-btn {
  flex: 0 0 32px;
  width: 32px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 50%;
  font-size: 1rem; line-height: 1; cursor: pointer;
}
.search-input {
  /* flex-basis 0 + min-width 0 lets it collapse fully; padding replaces the margin
     so nothing unshrinkable is left in the line when collapsed */
  flex: 1 1 0; min-width: 0;
  background: transparent; border: none; color: #fff; outline: none;
  padding: 0 0.5rem;
  opacity: 0; transition: opacity 0.2s;
}
.search-box:focus-within .search-input { opacity: 1; }

/* 18. Delete Wipe */
.delete-item {
  width: 100%; padding: 1rem; background: #333; border-radius: 6px;
  display: flex; justify-content: space-between; align-items: center;
  overflow: hidden; height: auto;
}
.delete-item.deleting {
  animation: deleteSwipe 0.5s forwards;
}
@keyframes deleteSwipe {
  0% { transform: translateX(0); opacity: 1; max-height: 60px; margin-bottom: 0; padding: 1rem; }
  50% { transform: translateX(100%); opacity: 0; max-height: 60px; margin-bottom: 0; padding: 1rem; }
  100% { transform: translateX(100%); opacity: 0; max-height: 0; margin-bottom: 0; padding: 0; }
}
.delete-btn { background: none; border: none; color: #aaa; font-size: 1.5rem; cursor: pointer; }
.reset-btn { margin-top: 1rem; background: #333; color: #fff; border:none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }

/* 19. Tooltip */
.tooltip-trigger { position: relative; }
.tooltip-trigger::after {
  content: attr(data-tooltip);
  position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%) scale(0.8);
  background: #222; padding: 0.5rem; border-radius: 4px; font-size: 0.75rem; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: all 0.2s var(--ease-spring);
  border: 1px solid #444;
}
.tooltip-trigger:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

/* 20. Badge */
.badge-container { position: relative; display: inline-block; font-size: 1.2rem; margin-right: 1rem; }
.badge {
  /* Sit clear of the label's cap height instead of overlapping the final glyph */
  position: absolute; top: -0.6em; right: -1.15em;
  background: var(--accent); color: #fff;
  font-size: 0.7rem; font-weight: 600; line-height: 1;
  min-width: 1.25rem; padding: 0.2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  /* Ring reads as a floating badge lifted off the label */
  box-shadow: 0 0 0 2px var(--bg-panel);
  transform-origin: center;
}
.badge.bump { animation: badgeBump 0.3s; }
@keyframes badgeBump {
  0% { transform: scale(1); } 50% { transform: scale(1.5); } 100% { transform: scale(1); }
}
.add-btn { padding: 0.25rem 0.75rem; background: #333; color: #fff; border: none; border-radius: 4px; cursor: pointer; }

/* 21. Confetti */
.confetti-piece {
  position: fixed;
  width: 8px; height: 12px;
  /* Centre on the launch point via margin, not transform — the WAAPI keyframes
     own `transform` and would replace any base value set here */
  margin: -6px 0 0 -4px;
  border-radius: 1px;
  pointer-events: none;
  z-index: 5000;
  will-change: transform, opacity;
}

/* 22. Odometer */
.odometer-demo { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.odometer { display: flex; gap: 4px; }
.odo-digit {
  width: 36px; height: 52px;
  background: #222;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.odo-strip {
  display: flex; flex-direction: column;
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.odo-strip span {
  height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* 23. Hamburger Morph */
.hamburger {
  width: 56px; height: 56px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.3s;
}
.hamburger:hover { border-color: var(--accent); }
.hb-line {
  position: absolute; left: 14px;
  width: 28px; height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: transform 0.4s var(--ease-spring), opacity 0.3s, top 0.4s var(--ease-spring);
}
.hb-top { top: 19px; }
.hb-mid { top: 27px; }
.hb-bot { top: 35px; }
.hamburger.open .hb-top { top: 27px; transform: rotate(45deg); background: var(--accent); }
.hamburger.open .hb-mid { opacity: 0; transform: translateX(-10px); }
.hamburger.open .hb-bot { top: 27px; transform: rotate(-45deg); background: var(--accent); }

/* Footer */
.layout-footer {
  grid-column: 1 / -1; text-align: center; padding: 2rem 0;
  color: var(--text-muted); font-size: 0.8rem;
}

/* Footer credit */
.site-credit {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.site-credit a {
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}
.site-credit a:hover { color: rgb(218, 65, 103); }
