/* ==========================================================================
   create.ax — Base CSS
   Layout primitives, reveal animations, slide chrome, edit mode
   ========================================================================== */

/* --- Fonts (local woff2) --- */
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Cabinet Grotesk'; src: url('/fonts/cabinet-grotesk-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Cabinet Grotesk'; src: url('/fonts/cabinet-grotesk-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Cabinet Grotesk'; src: url('/fonts/cabinet-grotesk-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Cabinet Grotesk'; src: url('/fonts/cabinet-grotesk-900.woff2') format('woff2'); font-weight: 900; font-display: swap; }

/* --- Default radius scale (themes can override) --- */
:root {
  --sf-radius-sm: 6px;
  --sf-radius-md: 12px;
  --sf-radius-lg: 20px;
  --sf-radius-full: 9999px;
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  height: 100%;
  overflow-x: hidden;
  scrollbar-width: none;
}
html::-webkit-scrollbar { display: none; }

body {
  font-family: var(--sf-font-body);
  background: var(--sf-bg);
  color: var(--sf-text);
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom cursor only when enabled */
body[data-cursor="custom"] { cursor: none; }

/* --- Dot Grid Background --- */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: radial-gradient(var(--sf-dot-color, rgba(255,255,255,0.08)) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  pointer-events: none; z-index: 0;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 85% 15%, black 0%, transparent 65%);
  mask-image: radial-gradient(ellipse 80% 70% at 85% 15%, black 0%, transparent 65%);
}

/* ==========================================================================
   SLIDE CONTAINER
   ========================================================================== */
.sf-slide {
  width: 100vw;
  height: 100vh; height: 100dvh;
  padding: var(--sf-slide-padding);
  scroll-snap-align: start;
  display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}

.sf-slide-inner {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  max-height: 100%; overflow: hidden;
  position: relative; z-index: 2;
}

/* --- Dark slide auto-inversion --- */
.sf-slide--dark {
  --sf-text: #F4F4F5;
  --sf-text-secondary: #A1A1AA;
  --sf-text-muted: #63636B;
  --sf-bg-card: rgba(255,255,255, 0.05);
  --sf-bg-card-hover: rgba(255,255,255, 0.08);
  --sf-border: rgba(255,255,255, 0.1);
  --sf-border-hover: rgba(255,255,255, 0.15);
  --sf-overlay-subtle: rgba(255,255,255, 0.02);
  --sf-overlay-dim: rgba(255,255,255, 0.05);
  --sf-overlay-soft: rgba(255,255,255, 0.06);
  --sf-overlay-border: rgba(255,255,255, 0.08);
}

/* --- Slide background textures --- */
.sf-slide-texture {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
}
.sf-slide-texture--grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
.sf-slide-texture--dots {
  background-image: radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 20px 20px;
}
.sf-slide-texture--noise {
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* --- Slide footer --- */
.sf-footer {
  position: absolute;
  bottom: var(--sf-gap-md);
  left: var(--sf-slide-padding, var(--sf-pad));
  right: var(--sf-slide-padding, var(--sf-pad));
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sf-font-body);
  font-size: var(--sf-label-size);
  color: var(--sf-text-muted);
  pointer-events: none;
  z-index: 5;
}
.sf-footer__left, .sf-footer__center, .sf-footer__right {
  flex: 1;
}
.sf-footer__center { text-align: center; }
.sf-footer__right { text-align: right; }

/* --- Gradient Glow Backgrounds --- */
.sf-glow {
  position: absolute; border-radius: 50%;
  filter: blur(120px); pointer-events: none;
  z-index: 0; opacity: 0;
  transition: opacity 1.5s ease;
}
.sf-slide.visible .sf-glow { opacity: 1; }

/* --- Slide Background Overlays --- */
.sf-slide-overlay {
  position: absolute; inset: 0;
  z-index: 1; pointer-events: none;
}
.sf-slide-overlay--dark   { background: rgba(0,0,0, 0.5); }
.sf-slide-overlay--darker { background: rgba(0,0,0, 0.7); }
.sf-slide-overlay--light  { background: rgba(255,255,255, 0.3); }

/* --- Absolutely Positioned Nodes (place: "top-left", "bottom-right", etc.) --- */
.sf-placed {
  position: absolute;
  z-index: 3;
}

/* ==========================================================================
   LAYOUT PRIMITIVES
   ========================================================================== */
.sf-layout { display: flex; position: relative; }

.sf-stack  { flex-direction: column; }
.sf-row    { flex-direction: row; align-items: center; }
.sf-center { flex-direction: column; align-items: center; justify-content: center; }
.sf-cover  { position: absolute; inset: 0; }

.sf-grid   { display: grid; }
.sf-split  { display: grid; grid-template-columns: 1fr 1fr; }

/* Gap sizes */
.sf-gap-sm  { gap: var(--sf-gap-sm); }
.sf-gap-md  { gap: var(--sf-gap-md); }
.sf-gap-lg  { gap: var(--sf-gap-lg); }
.sf-gap-xl  { gap: var(--sf-gap-xl); }

/* Alignment */
.sf-align-start   { align-items: flex-start; }
.sf-align-center  { align-items: center; }
.sf-align-end     { align-items: flex-end; }
.sf-align-stretch { align-items: stretch; }

.sf-justify-start   { justify-content: flex-start; }
.sf-justify-center  { justify-content: center; }
.sf-justify-end     { justify-content: flex-end; }
.sf-justify-between { justify-content: space-between; }

.sf-text-center { text-align: center; }

/* Padding */
.sf-pad-none  { padding: 0; }
.sf-pad-sm    { padding: var(--sf-gap-sm); }
.sf-pad-md    { padding: var(--sf-gap-md); }

/* ==========================================================================
   REVEAL ANIMATIONS
   ========================================================================== */
.sf-reveal {
  opacity: 0; transform: translateY(25px);
  transition: opacity 0.7s var(--sf-ease), transform 0.7s var(--sf-ease);
}
.sf-reveal-left {
  opacity: 0; transform: translateX(-25px);
  transition: opacity 0.7s var(--sf-ease), transform 0.7s var(--sf-ease);
}
.sf-reveal-scale {
  opacity: 0; transform: scale(0.96) translateY(10px);
  transition: opacity 0.6s var(--sf-ease), transform 0.6s var(--sf-ease-spring);
}
.sf-reveal-fade {
  opacity: 0;
  transition: opacity 0.8s var(--sf-ease);
}
.sf-reveal-zoom {
  opacity: 0; transform: scale(0.8); filter: blur(4px);
  transition: opacity 0.6s var(--sf-ease), transform 0.6s var(--sf-ease-spring), filter 0.6s var(--sf-ease);
}

.sf-slide.visible .sf-reveal,
.sf-slide.visible .sf-reveal-left,
.sf-slide.visible .sf-reveal-scale,
.sf-slide.visible .sf-reveal-fade,
.sf-slide.visible .sf-reveal-zoom {
  opacity: 1; transform: none; filter: none;
}

/* Stagger delays */
.sf-d1 { transition-delay: 0.08s !important; }
.sf-d2 { transition-delay: 0.16s !important; }
.sf-d3 { transition-delay: 0.24s !important; }
.sf-d4 { transition-delay: 0.32s !important; }
.sf-d5 { transition-delay: 0.40s !important; }
.sf-d6 { transition-delay: 0.48s !important; }
.sf-d7 { transition-delay: 0.56s !important; }
.sf-d8 { transition-delay: 0.64s !important; }

/* ==========================================================================
   CARD BASE
   ========================================================================== */
.sf-card {
  background: var(--sf-bg-card);
  border: 1px solid var(--sf-border);
  border-radius: var(--sf-card-radius);
  position: relative; overflow: hidden;
  transition: border-color 0.4s ease, background 0.4s ease,
              transform 0.4s var(--sf-ease), box-shadow 0.4s ease;
}
.sf-card:hover {
  border-color: var(--sf-border-hover);
  background: var(--sf-bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* Card top accent line */
.sf-card::after {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--sf-accent-glow) 50%, transparent 100%);
  opacity: 0; transition: opacity 0.4s ease;
}
.sf-card:hover::after { opacity: 1; }

/* Card shine */
.sf-card-shine {
  position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; opacity: 0;
  transition: opacity 0.4s ease;
  background: radial-gradient(
    300px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    var(--sf-overlay-soft), transparent 60%
  );
}
.sf-card:hover .sf-card-shine { opacity: 1; }

/* ==========================================================================
   CURSOR
   ========================================================================== */
.sf-cursor-dot {
  width: 6px; height: 6px;
  background: var(--sf-overlay-strong);
  border-radius: 50%;
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width 0.2s ease, height 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
.sf-cursor-ring {
  width: 36px; height: 36px;
  border: 1px solid var(--sf-overlay-border);
  border-radius: 50%;
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 9998;
  transform: translate(-50%, -50%);
  transition: width 0.3s var(--sf-ease), height 0.3s var(--sf-ease),
              border-color 0.3s ease, background 0.2s ease;
}
.sf-cursor-glow {
  width: 180px; height: 180px;
  background: radial-gradient(circle, var(--sf-cursor-glow-color), transparent 70%);
  border-radius: 50%;
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 9997;
  transform: translate(-50%, -50%);
}
body.sf-cursor-hover .sf-cursor-ring {
  width: 50px; height: 50px;
  border-color: var(--sf-cursor-hover-ring);
  background: var(--sf-cursor-hover-bg);
}
body.sf-cursor-hover .sf-cursor-dot {
  width: 4px; height: 4px;
  background: var(--sf-cursor-hover-dot);
}
@media (hover: none) {
  .sf-cursor-dot, .sf-cursor-ring, .sf-cursor-glow { display: none; }
  body[data-cursor="custom"] { cursor: auto; }
}

/* ==========================================================================
   PROGRESS BAR
   ========================================================================== */
.sf-progress-bar {
  position: fixed; top: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--sf-accent), #FF8A65);
  z-index: 100; transition: width 0.3s ease;
  width: 0%;
}

/* ==========================================================================
   NAV DOTS
   ========================================================================== */
.sf-nav-dots {
  position: fixed;
  right: clamp(0.75rem, 2vw, 2rem);
  top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px;
  z-index: 50;
}
.sf-nav-dot {
  width: 5px; height: 5px; border-radius: 50%;
  border: none; background: var(--sf-text-muted);
  opacity: 0.3; cursor: pointer;
  transition: all 0.3s ease; padding: 0;
}
.sf-nav-dot:hover { opacity: 0.6; }
.sf-nav-dot.active {
  background: var(--sf-accent); opacity: 1;
  box-shadow: 0 0 8px var(--sf-accent-glow);
  transform: scale(1.4);
}

/* ==========================================================================
   BOTTOM NAV
   ========================================================================== */
.sf-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 90; pointer-events: none;
  opacity: 0; transform: translateY(100%);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.sf-bottom-nav.visible {
  opacity: 1; transform: none; pointer-events: auto;
}
.sf-bottom-nav-inner {
  display: flex; align-items: stretch;
  height: 32px;
  background: var(--sf-chrome-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--sf-border);
}
.sf-bottom-nav-section {
  flex: 1; position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; background: none;
  padding: 0 clamp(0.5rem, 1vw, 1rem);
  color: var(--sf-text-muted);
  font-family: var(--sf-font-body); font-weight: 600;
  font-size: clamp(0.6rem, 0.75vw, 0.72rem);
  letter-spacing: 0.04em; text-transform: uppercase;
  transition: color 0.3s ease, background 0.3s ease;
  white-space: nowrap; overflow: hidden;
}
.sf-bottom-nav-section:hover {
  color: var(--sf-text-secondary);
  background: var(--sf-overlay-light);
}
.sf-bottom-nav-section.active { color: var(--sf-accent); }
.sf-bottom-nav-section + .sf-bottom-nav-section {
  border-left: 1px solid var(--sf-border);
}
.sf-bottom-nav-fill {
  position: absolute; inset: 0;
  background: var(--sf-nav-fill);
  transform-origin: left;
  transition: transform 0.3s ease;
  pointer-events: none;
}
.sf-bottom-nav-section span { position: relative; z-index: 1; }

/* ==========================================================================
   EDIT MODE
   ========================================================================== */
.sf-edit-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 40px; z-index: 200;
  background: var(--sf-chrome-bg-solid);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sf-border);
  display: none; align-items: center;
  padding: 0 16px; gap: 12px;
  font-family: var(--sf-font-body);
  font-size: 12px; color: var(--sf-text-secondary);
}
body.sf-edit-mode .sf-edit-bar { display: flex; }
body.sf-edit-mode .sf-progress-bar { top: 40px; }
body.sf-edit-mode .sf-slide { padding-top: calc(var(--sf-slide-padding) + 40px); }

.sf-edit-bar-title {
  font-weight: 600; color: var(--sf-text);
  margin-right: auto;
}
.sf-edit-bar-status {
  color: var(--sf-green);
  font-size: 11px;
}
.sf-edit-bar-btn {
  border: 1px solid var(--sf-border);
  background: var(--sf-bg-card);
  color: var(--sf-text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sf-edit-bar-btn:hover {
  border-color: var(--sf-border-hover);
  color: var(--sf-text);
  background: var(--sf-bg-card-hover);
}

/* Inline editable elements */
[data-sf-editable] {
  outline: none;
  border-radius: 4px;
  transition: box-shadow 0.2s ease;
}
body.sf-edit-mode [data-sf-editable]:hover {
  box-shadow: 0 0 0 1px var(--sf-border-hover);
}
body.sf-edit-mode [data-sf-editable]:focus {
  box-shadow: 0 0 0 2px var(--sf-accent);
}

/* Slide action buttons */
.sf-slide-actions {
  position: absolute; top: 8px; right: 8px;
  z-index: 10; display: none;
  gap: 4px;
}
body.sf-edit-mode .sf-slide:hover .sf-slide-actions { display: flex; }
.sf-slide-action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--sf-border);
  background: var(--sf-chrome-btn-bg);
  color: var(--sf-text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sf-slide-action-btn:hover {
  border-color: var(--sf-accent);
  color: var(--sf-accent);
}

/* ==========================================================================
   V2 NODE-BASED LAYOUT
   ========================================================================== */

/* Default: centered vertical stack (no grid defined) */
.sf-slide-nodes {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  gap: var(--sf-gap-md);
  max-width: 900px;
  margin: 0 auto;
  height: 100%; width: 100%;
}
.sf-slide-nodes--start { align-items: flex-start; text-align: left; }

/* Grid-based slide layout */
.sf-slide-grid {
  display: grid;
  gap: var(--sf-gap-md);
  max-width: 1100px;
  margin: 0 auto;
  height: 100%; width: 100%;
  align-content: center;
}

/* Group containers */
.sf-group {
  display: flex; flex-direction: column;
  width: 100%;
}
.sf-group--row { flex-direction: row; flex-wrap: wrap; }
.sf-group--grid { display: grid; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-height: 700px) {
  :root {
    --sf-slide-padding: clamp(1rem, 3vw, 2.5rem);
    --sf-title-size: clamp(2rem, 5vw, 3.2rem);
    --sf-h2-size: clamp(1.5rem, 3.5vw, 2.5rem);
  }
}
@media (max-height: 600px) {
  :root {
    --sf-slide-padding: clamp(0.75rem, 2.5vw, 1.5rem);
    --sf-title-size: clamp(1.5rem, 4.5vw, 2.5rem);
    --sf-body-size: clamp(0.82rem, 1.1vw, 0.95rem);
  }
  .sf-nav-dots { display: none; }
}
@media (max-width: 900px) {
  .sf-grid[style*="--cols: 3"] { --cols: 2 !important; }
  .sf-grid[style*="--cols: 5"] { --cols: 2 !important; }
}
@media (max-width: 550px) {
  .sf-grid[style*="--cols: 2"] { --cols: 1 !important; }
  .sf-grid[style*="--cols: 3"] { --cols: 1 !important; }
  .sf-split { grid-template-columns: 1fr !important; }

  /* V2: collapse grid to single column stack */
  .sf-slide-grid {
    grid-template-columns: 1fr !important;
    grid-template-areas: none !important;
    grid-template-rows: auto !important;
  }
  .sf-slide-grid > * { grid-area: auto !important; }
  .sf-group--grid { grid-template-columns: 1fr !important; }
}
@media (max-height: 500px) { .sf-bottom-nav { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.2s !important;
  }
  html { scroll-behavior: auto; }
  .sf-reveal, .sf-reveal-left, .sf-reveal-scale, .sf-reveal-fade, .sf-reveal-zoom {
    opacity: 1 !important; transform: none !important; filter: none !important;
  }
  body { cursor: auto; }
  .sf-cursor-dot, .sf-cursor-ring, .sf-cursor-glow { display: none; }
}

/* ==========================================================================
   KEYFRAMES
   ========================================================================== */
@keyframes sf-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
@keyframes sf-shimmer {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}
@keyframes sf-fade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes sf-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes sf-ping {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}
