/**
 * Vibe Controls Styles - Server-Side Rendered CSS
 *
 * Pure CSS extracted from React style functions for SSR vibe controls.
 * This CSS is injected inline via <style> tag for self-contained styling.
 *
 * Sources:
 * - colors.css → All CSS variables (single source of truth)
 * - VibesSwitch.styles.ts → Switch colors, SVG transitions
 * - VibesButton.styles.ts → Button variants, hover states, bounce animation
 * - VibesPanel.styles.ts → Panel layout, button containers
 * - BrutalistCard.styles.ts → Card borders, shadows, sizing
 * - LabelContainer.styles.ts → Vertical label, responsive behavior
 */

/* ============================================
   CSS VARIABLES - Full design system colors
   Source: colors.css (vibes.diy/pkg/app/styles/colors.css)
   ============================================ */

:root {
  /* Primary Palette */
  --vibes-blue: #3b82f6;
  --vibes-red: #ef4444;
  --vibes-yellow: #eab308;
  --vibes-gray: #6b7280;
  --vibes-green: #51cf66;

  /* Neon/Phosphorescent colors for dark mode */
  --vibes-purple-neon: #c084fc;
  --vibes-pink-neon: #f472b6;
  --vibes-orange-neon: #fb923c;
  --vibes-cyan-neon: #22d3ee;

  /* Neutrals */
  --vibes-black: #000000;
  --vibes-near-black: #1a1a1a;
  --vibes-gray-mid: #555555;
  --vibes-gray-pale: #e5e5e5;
  --vibes-white: #ffffff;
  --vibes-cream: #fffff0;

  /* Button colors */
  --vibes-button-bg: var(--vibes-cream);
  --vibes-button-text: var(--vibes-near-black);
  --vibes-button-border: var(--vibes-near-black);
  --vibes-button-icon-bg: #2a2a2a;
  --vibes-button-icon-fill: var(--vibes-white);

  /* Button variant colors - Light mode */
  --vibes-variant-blue: var(--vibes-blue);
  --vibes-variant-red: var(--vibes-red);
  --vibes-variant-yellow: var(--vibes-yellow);
  --vibes-variant-gray: var(--vibes-gray);

  /* Card colors */
  --vibes-card-bg: var(--vibes-gray-pale);
  --vibes-card-bg-transparent: #14141433;
  --vibes-card-text: var(--vibes-near-black);
  --vibes-card-border: var(--vibes-near-black);

  /* Shadow */
  --vibes-shadow-color: var(--vibes-near-black);

  /* Clearance reserved below app content so the app can always be scrolled
     clear of the fixed vibes switch in the bottom-right corner. The switch is
     80px tall with a 20px inset (~100px footprint); we reserve a little more so
     the last row of content can be pulled up above the switch. See #1771. */
  --vibes-switch-clearance: 124px;
}

/* Dark mode - neon variant colors */
@media (prefers-color-scheme: dark) {
  :root {
    /* Button base colors — dark-aware. Without these overrides the panel
       buttons stay cream (#fffff0) with a near-black border that vanishes
       against the dark card. Mirrors semantic.dark.button.*DarkAware in
       vibes.diy/base/theme/tokens.ts so the SSR panel matches the React
       VibesButton in dark mode. See #vibe-button-dark-mode. */
    --vibes-button-bg: #2a2a2a;
    --vibes-button-text: #e0e0e0;
    --vibes-button-border: var(--vibes-gray-mid);

    /* Button icon colors swap */
    --vibes-button-icon-bg: var(--vibes-white);
    --vibes-button-icon-fill: #2a2a2a;

    /* Card colors */
    --vibes-card-bg: var(--vibes-near-black);
    --vibes-card-text: var(--vibes-white);
    --vibes-card-border: var(--vibes-gray-mid);

    /* Button variant colors - Dark mode (neon/phosphorescent) */
    --vibes-variant-blue: var(--vibes-purple-neon);
    --vibes-variant-red: var(--vibes-pink-neon);
    --vibes-variant-yellow: var(--vibes-orange-neon);
    --vibes-variant-gray: var(--vibes-cyan-neon);
  }
}

/* ============================================
   VIBE APP SURFACE
   The vibe document's own backdrop: the platform gray grid (jchris,
   2026-07-04, post-#3211). This is what shows in the beat before the app
   paints — and behind any app that never paints its own background. It used
   to be a solid near-white/near-black ("the grid means platform fallback,
   never behind a live app"), but the solid surface is exactly what read as a
   BROKEN BLACK SCREEN in dark mode: theme CSS vars aren't defined until the
   client boots, so a `bg-[var(--background)]` app renders transparent over
   the near-black body. The grid is the platform's loading texture — it says
   "vibes is bringing your app" in both color schemes, and the app's own
   painted background fully covers it the moment the vars land. Values match
   the panel-open rule below so the open/close transition stays seamless.

   `.grid-background` is the legacy body class this replaced. It is kept in the
   selector ONLY for the rollout window: versioned vibe HTML is cached up to a
   day (`rootHtmlCacheControl: public, max-age=86400`), so a pre-deploy document
   still carrying `<body class="grid-background">` would otherwise fetch this
   newer stylesheet and render unstyled until its HTML cache expires. No
   live element uses the plain class anymore, so styling it is a harmless alias.
   ============================================ */
.vibe-app-surface,
.grid-background {
  background-color: #d4d4d4;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
  background-size: 40px 40px;
}

@media (prefers-color-scheme: dark) {
  .vibe-app-surface,
  .grid-background {
    background-color: #2a2a2a;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
  }
}

body:has([data-vibe-controls-container] [data-vibe-switch].active) {
  background-color: #d4d4d4;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: scroll;
  transition:
    background-color 0.3s ease,
    background-image 0.3s ease;
}

@media (min-width: 768px) {
  body:has([data-vibe-controls-container] [data-vibe-switch].active) {
    background-attachment: fixed;
  }
}

@media (prefers-color-scheme: dark) {
  body:has([data-vibe-controls-container] [data-vibe-switch].active) {
    background-color: #2a2a2a;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
  }
}

/* App mount blur and shift when panel is open */
body:has([data-vibe-controls-container] [data-vibe-switch].active) .vibe-app-container {
  filter: blur(4px);
  transform: translateY(-400px);
  transition:
    filter 0.3s ease,
    transform 0.3s ease;
  pointer-events: none;
}

.vibe-app-container {
  transition:
    filter 0.3s ease,
    transform 0.3s ease;
}

/* Switch clearance: keep a scrollable strip below the app so its bottom
   content can always be pulled up above the fixed switch overlay (#1771).
   Apps that intentionally pin content to the bottom will sit above this strip;
   that trade-off is accepted for now. */
.vibe-app-container {
  padding-bottom: var(--vibes-switch-clearance);
}

/* Container - Fixed position lower right */
[data-vibe-controls-container] {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
}

/* ============================================
   VIBES SWITCH (SVG Toggle Button)
   ============================================ */

[data-vibe-switch] {
  width: 160px;
  height: 80px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  transform: scale(1);
  transition: transform 0.15s ease;
}

[data-vibe-switch]:hover {
  transform: scale(1.05);
}

[data-vibe-switch]:active {
  transform: scale(0.95);
}

/* SVG paths with transitions */
[data-vibe-switch] svg path {
  transition:
    d 0.3s ease,
    transform 0.8s ease,
    fill 2s ease;
}

/* Morphing path - changes shape when active */
/* Default (closed): stretched oval on left (under "VIBES") with translate */
[data-vibe-switch] svg path.morphing {
  /* stretchedD path in JSX by default */
  transform: translateX(3px);
}

/* Active (open): circular shape on right (under "DIY"), no translate */
/* When panel opens, the path needs to be swapped via JavaScript to originalD */
[data-vibe-switch].active svg path.morphing {
  transform: none;
}

/* Logo letter colors - transition on toggle */
/* VIBES letters (logo-vibes) - start black, turn white when active */
[data-vibe-switch] svg path.logo-vibes {
  fill: var(--vibes-black);
  transition: fill 1s ease;
}

[data-vibe-switch].active svg path.logo-vibes {
  fill: var(--vibes-white);
}

/* DIY letters (logo-diy) - start white, turn black when active */
[data-vibe-switch] svg path.logo-diy {
  fill: var(--vibes-white);
  transition: fill 1s ease;
}

[data-vibe-switch].active svg path.logo-diy {
  fill: var(--vibes-black);
}

/* ============================================
   VIBES PANEL (Settings Panel)
   ============================================ */

[data-vibe-panel] {
  display: flex;
  flex-direction: column;
  gap: 24px;
  color: var(--vibes-card-text);
}

[data-vibe-panel][data-panel-hidden] {
  display: none;
}

/* Panel animation on show */
@keyframes vibe-panel-slide-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

[data-vibe-panel]:not([data-panel-hidden]) {
  animation: vibe-panel-slide-in 0.3s ease;
}

/* Panel mode containers */
[data-panel-mode] {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

[data-panel-mode][data-mode-hidden] {
  display: none;
}

/* Button container within modes */
[data-panel-mode] > div {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

/* ============================================
   BUTTONS (Brutalist Style)
   ============================================ */

[data-vibe-panel] button {
  background: var(--vibes-button-bg);
  color: var(--vibes-button-text);
  border: 2px solid var(--vibes-button-border);
  border-radius: 12px;
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  transform: translate(0px, 0px);
  min-width: 120px;
}

/* Default button shadow */
[data-vibe-panel] button {
  box-shadow:
    8px 10px 0px 0px var(--vibes-variant-blue),
    8px 10px 0px 2px var(--vibes-button-border);
}

/* Button variants */
[data-vibe-panel] button[data-variant="blue"] {
  box-shadow:
    8px 10px 0px 0px var(--vibes-variant-blue),
    8px 10px 0px 2px var(--vibes-button-border);
}

[data-vibe-panel] button[data-variant="red"] {
  box-shadow:
    8px 10px 0px 0px var(--vibes-variant-red),
    8px 10px 0px 2px var(--vibes-button-border);
}

[data-vibe-panel] button[data-variant="yellow"] {
  box-shadow:
    8px 10px 0px 0px var(--vibes-variant-yellow),
    8px 10px 0px 2px var(--vibes-button-border);
}

[data-vibe-panel] button[data-variant="gray"] {
  box-shadow:
    8px 10px 0px 0px var(--vibes-variant-gray),
    8px 10px 0px 2px var(--vibes-button-border);
}

/* Button hover states */
[data-vibe-panel] button:hover {
  transform: translate(2px, 2px);
}

[data-vibe-panel] button[data-variant="blue"]:hover {
  box-shadow:
    2px 3px 0px 0px var(--vibes-variant-blue),
    2px 3px 0px 2px var(--vibes-button-border);
}

[data-vibe-panel] button[data-variant="red"]:hover {
  box-shadow:
    2px 3px 0px 0px var(--vibes-variant-red),
    2px 3px 0px 2px var(--vibes-button-border);
}

[data-vibe-panel] button[data-variant="yellow"]:hover {
  box-shadow:
    2px 3px 0px 0px var(--vibes-variant-yellow),
    2px 3px 0px 2px var(--vibes-button-border);
}

[data-vibe-panel] button[data-variant="gray"]:hover {
  box-shadow:
    2px 3px 0px 0px var(--vibes-variant-gray),
    2px 3px 0px 2px var(--vibes-button-border);
}

/* Button active (pressed) states */
[data-vibe-panel] button:active {
  transform: translate(4px, 5px);
  box-shadow: none;
}

/* Button disabled state */
[data-vibe-panel] button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: translate(0px, 0px);
}

/* ============================================
   ICON BUTTONS (Square with icon + text)
   ============================================ */

/* Icon buttons - 130x135px desktop squares */
[data-vibe-panel] button[data-has-icon] {
  width: 130px;
  height: 135px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-content-wrapper] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
}

[data-icon-container] {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  border: 2px solid var(--vibes-black);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-icon] {
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-icon] svg {
  width: 45px;
  height: 45px;
}

/* Variant colors for icon container background */
[data-variant="blue"] [data-icon-container] {
  background: var(--vibes-variant-blue);
}

[data-variant="red"] [data-icon-container] {
  background: var(--vibes-variant-red);
}

[data-variant="yellow"] [data-icon-container] {
  background: var(--vibes-variant-yellow);
}

[data-variant="gray"] [data-icon-container] {
  background: var(--vibes-variant-gray);
}

/* Button text styling */
[data-vibe-panel] button[data-has-icon] span {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Icon bounce animation on hover */
@keyframes vibes-button-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

[data-vibe-panel] button:hover [data-icon] {
  animation: vibes-button-bounce 0.8s ease-in-out infinite;
}

/* ============================================
   LABEL CONTAINER (Vertical label on desktop)
   ============================================ */

[data-label-container] {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  flex-direction: row;
  width: auto;
}

/* Label outer wrapper - matches Amber's getResponsiveLabelStyle */
[data-label] {
  background: var(--vibes-card-bg-transparent, transparent);
  border: 2px solid var(--vibes-card-border);
  border-left: none;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding: 12px 8px 12px 0px;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  color: var(--vibes-card-text);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 32px 0px;
}

/* Inner colored label box - matches Amber's getLabelStyle */
[data-label] span {
  background: var(--vibes-variant-gray);
  height: 100%;
  padding: 15px 8px;
  border-radius: 0px 8px 8px 0px;
  display: block;
}

/* Yellow label variant for invite mode */
[data-label-yellow] [data-label] span {
  background: var(--vibes-variant-yellow);
}

/* Button wrapper - matches Amber's getResponsiveButtonWrapperStyle */
[data-button-wrapper] {
  background: var(--vibes-card-bg-transparent, var(--vibes-card-bg));
  border: 2px solid var(--vibes-card-border);
  border-radius: 8px;
  padding: 24px 24px 32px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  gap: 16px;
  flex-wrap: wrap;
}

/* ============================================
   INVITE FORM
   ============================================ */

[data-invite-form] {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

[data-invite-form] label {
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-invite-form] input[type="email"] {
  width: 100%;
  padding: 12px 16px;
  border: 3px solid var(--vibes-card-border);
  border-radius: 8px;
  background: var(--vibes-card-bg);
  color: var(--vibes-card-text);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  box-shadow: 2px 3px 0px 0px var(--vibes-shadow-color);
  transition: all 0.15s ease;
}

[data-invite-form] input[type="email"]:focus {
  outline: none;
  border-color: var(--vibes-variant-blue);
  box-shadow: 4px 5px 0px 0px var(--vibes-variant-blue);
}

[data-invite-form] input[type="email"]::placeholder {
  color: var(--vibes-card-text);
  opacity: 0.5;
}

/* Invite status display */
[data-invite-status] {
  padding: 16px;
  border: 3px solid var(--vibes-card-border);
  border-radius: 12px;
  text-align: center;
  background: var(--vibes-card-bg);
  box-shadow: 2px 3px 0px 0px var(--vibes-shadow-color);
  font-weight: 500;
  letter-spacing: 0.02em;
}

[data-invite-status].success {
  background: rgba(220, 255, 220, 0.8);
  border-color: var(--vibes-green);
  box-shadow: 2px 3px 0px 0px var(--vibes-green);
}

[data-invite-status].error {
  background: rgba(255, 220, 220, 0.8);
  border-color: var(--vibes-red-accent);
  box-shadow: 2px 3px 0px 0px var(--vibes-red-accent);
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 768px) {
  [data-vibe-controls-container] {
    bottom: 10px;
    right: 10px;
    left: 10px;
    align-items: stretch;
  }

  [data-vibe-switch] {
    align-self: flex-end;
  }

  /* LabelContainer mobile - label disappears */
  [data-label-container] {
    flex-direction: column;
    width: 100%;
  }

  [data-label][data-disappear] {
    display: none;
  }

  [data-button-wrapper] {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    padding-bottom: 24px;
    flex-direction: column;
    width: 100%;
  }

  /* Icon buttons - horizontal on mobile */
  [data-vibe-panel] button[data-has-icon] {
    width: 100%;
    height: auto;
    min-height: 70px;
    padding: 12px 16px;
  }

  [data-content-wrapper] {
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
  }

  [data-icon-container] {
    width: 48px;
    height: 48px;
  }

  [data-icon] svg {
    width: 28px;
    height: 28px;
  }

  [data-vibe-panel] button[data-has-icon] span {
    font-size: 0.875rem;
  }

  /* Non-icon buttons on mobile */
  [data-vibe-panel] button:not([data-has-icon]) {
    width: 100%;
    padding: 0.75rem 1.5rem;
    min-height: 60px;
  }
}

/* Dark mode support via CSS variables */
@media (prefers-color-scheme: dark) {
  /* CSS variables will handle dark mode automatically */
  /* No explicit overrides needed here */
}
