@tailwind base;
@tailwind components;
@tailwind utilities;

/*

@layer components {
  .btn-primary {
    @apply py-2 px-4 bg-blue-200;
  }
}

*/

@layer base {
  html {
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    -webkit-tap-highlight-color: transparent;
  }
}

@import 'actiontext.css';

@layer components {
  .embed-container {
    @apply my-4;
  }

  .embed-wrapper {
    @apply relative overflow-hidden rounded-lg;
  }

  .embed-wrapper iframe {
    @apply absolute top-0 left-0 w-full h-full;
  }

  .embed-caption {
    @apply mt-2 text-sm text-slate-500  text-center;
  }

  /* YouTube video embeds in prose content (product updates) */
  .prose iframe[src*="youtube.com/embed"] {
    @apply w-full rounded-lg my-6;
    aspect-ratio: 16 / 9;
    height: auto;
  }

  .link-tool {
    @apply my-4 border border-slate-200  rounded-lg overflow-hidden;
  }

  .link-tool-content {
    @apply block hover:bg-slate-50  transition-colors duration-200;
  }

  .link-tool-image {
    @apply w-full h-48 overflow-hidden;
  }

  .link-tool-image img {
    @apply w-full h-full object-cover;
  }

  .link-tool-info {
    @apply p-4;
  }

  .link-tool-title {
    @apply text-base font-medium text-slate-900 ;
  }

  .link-tool-description {
    @apply mt-1 text-sm text-slate-500 ;
  }

  .link-tool-url {
    @apply mt-2 text-xs text-slate-400  truncate;
  }

  .table-wrapper {
    @apply my-4 overflow-x-auto md:overflow-visible md:flex md:justify-center;
  }

  .editor-table {
    @apply w-full border-collapse min-w-[800px] md:min-w-[1200px];
  }

  .editor-table th,
  .editor-table td {
    @apply border border-slate-200  px-4 py-2 whitespace-normal;
  }

  .editor-table th {
    @apply bg-slate-50  font-medium text-slate-900 ;
  }

  .editor-table td {
    @apply text-slate-600 ;
  }

  .editor-table tr:nth-child(even) {
    @apply bg-slate-50;
  }

  .animate-fade-in {
    animation: fade-in 0.5s ease-out forwards;
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  .shake-animation {
    animation: shake 0.6s ease-in-out;
  }

  @keyframes shake {
    0%, 100% {
      transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
      transform: translateX(-4px);
    }
    20%, 40%, 60%, 80% {
      transform: translateX(4px);
    }
  }

  /* Hide edit controls while editing block content */
  .bento-block.editing > .absolute.-top-3.left-1\/2 {
    @apply !opacity-0 !pointer-events-none;
  }

  /* Hide ALL edit controls while dragging blocks (including the one being dragged) */
  .is-dragging .bento-block > .absolute.-top-3.left-1\/2 {
    @apply !opacity-0 !pointer-events-none;
  }

  /* When a toolbar submenu is open, hide all other toolbars */
  .toolbar-submenu-open .bento-block > .absolute.-top-3.left-1\/2:not(.toolbar-locked) {
    @apply !opacity-0 !pointer-events-none;
  }

  /* Keep the locked toolbar visible */
  .toolbar-submenu-open .toolbar-locked {
    @apply !opacity-100 !pointer-events-auto;
  }

  /* Hide Edit page button when color picker is open */
  .color-picker-open .edit-page-button {
    @apply !opacity-0 !pointer-events-none;
  }

  /* Page content styling for dark themes */
  .page-content-dark a {
    color: rgba(255, 255, 255, 0.9) !important;
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.5);
  }

  .page-content-dark a:hover {
    color: white !important;
  }

  .page-content-dark strong,
  .page-content-dark b {
    color: white !important;
    font-weight: 600;
  }

  .page-content-dark h2 {
    color: white !important;
    font-weight: 600;
    font-size: 20px;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
  }

  /* Page content styling for light themes */
  .page-content-light a {
    color: #334155 !important;
    text-decoration: underline;
  }

  .page-content-light a:hover {
    color: #0f172a !important;
  }

  .page-content-light strong,
  .page-content-light b {
    color: #334155 !important;
    font-weight: 600;
  }

  .page-content-light h2 {
    color: #334155 !important;
    font-weight: 600;
    font-size: 20px;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
  }

  /* Long-press visual feedback for touch drag */
  .bento-block.press-hold {
    @apply ring-2 ring-blue-400/50;
    animation: pulse-ring 1s ease-out infinite;
  }

  @keyframes pulse-ring {
    0% {
      box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.4);
    }
    70% {
      box-shadow: 0 0 0 10px rgba(96, 165, 250, 0);
    }
    100% {
      box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
    }
  }

  /* Prevent double-tap zoom on touch devices (preserves pinch zoom for accessibility) */
  @media (pointer: coarse) {
    html, body {
      touch-action: manipulation;
    }

    /* Ensure inputs are 16px+ to prevent iOS auto-zoom on focus */
    input, textarea, select {
      font-size: 16px;
    }

    /* Ensure contenteditable elements are at least 16px to prevent iOS auto-zoom */
    /* The bio field is 15px which triggers zoom - this bumps small fonts to 16px */
    [data-controller="contenteditable"].text-\[15px\],
    [data-controller="contenteditable"].text-\[14px\],
    [data-controller="contenteditable"].text-\[13px\],
    [data-controller="contenteditable"].text-\[12px\] {
      font-size: 16px !important;
    }

    .bento-block {
      touch-action: manipulation;
    }

    .bento-block.sortable-chosen {
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
      transform: scale(1.02);
    }

    /* Touch device toolbar rules are now in .touch-device section below */

    /* Larger touch targets for toolbar buttons on mobile */
    .bento-block [data-controller="block-options"] button {
      min-width: 32px;
      min-height: 32px;
    }
  }

}

/* ===========================================
   Touch Device Toolbar Control
   JS adds .touch-device to body on touch devices
   =========================================== */

/* On touch devices, completely disable hover-based toolbar visibility */
/* Force all toolbars hidden - only JS can show them via toolbar-visible class */
body.touch-device .bento-block [data-controller="block-options"] {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Override Tailwind group-hover utilities on touch devices */
body.touch-device .group:hover .group-hover\:opacity-100,
body.touch-device .group-hover\:opacity-100 {
  opacity: 0 !important;
}

body.touch-device .group:hover .group-hover\:pointer-events-auto,
body.touch-device .group-hover\:pointer-events-auto {
  pointer-events: none !important;
}

/* Only show toolbar when JS adds toolbar-visible class to the block */
body.touch-device .bento-block.toolbar-visible [data-controller="block-options"] {
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
}

/* ===========================================
   Bento Grid Block Sizing
   Must be in main stylesheet to prevent FOUC
   =========================================== */

/* Base block styles */
.bento-block {
  min-height: 140px;
  transition: width 0.3s ease, height 0.3s ease, transform 0.3s ease;
}

@media (min-width: 768px) {
  .bento-block {
    min-height: 208px;
  }
}

/* Size variations - desktop */
@media (min-width: 768px) {
  .block-1x1 {
    grid-column: span 1;
    grid-row: span 1;
    width: 208px;
    height: 208px;
  }

  .block-2x1 {
    grid-column: span 2;
    grid-row: span 1;
    width: 432px;
    height: 208px;
  }

  .block-1x2 {
    grid-column: span 1;
    grid-row: span 2;
    width: 208px;
    height: 432px;
  }

  .block-2x2 {
    grid-column: span 2;
    grid-row: span 2;
    width: 432px;
    height: 432px;
  }

  .block-3x1 {
    grid-column: span 3;
    grid-row: span 1;
    width: 656px;
    height: 208px;
  }
}

/* Section title blocks have auto height */
.bento-block[data-block-type="section_title"] {
  height: auto !important;
  min-height: auto !important;
}

/* Size variations - mobile (2 column grid) */
@media (max-width: 767px) {
  .block-1x1 {
    grid-column: span 1;
    grid-row: span 1;
  }

  .block-2x1,
  .block-3x1 {
    grid-column: span 2;
    grid-row: span 1;
  }

  .block-1x2 {
    grid-column: span 1;
    grid-row: span 2;
  }

  .block-2x2 {
    grid-column: span 2;
    grid-row: span 2;
  }
}

/* Mobile Preview Mode */
.bento-grid-container.mobile-preview {
  max-width: 400px !important;
}

.bento-grid-container.mobile-preview [data-bento-grid-target="grid"] {
  grid-template-columns: repeat(2, 1fr) !important;
}

.bento-grid-container.mobile-preview .bento-block {
  min-height: 140px !important;
  width: auto !important;
  height: auto !important;
}

.bento-grid-container.mobile-preview .block-1x1,
.bento-grid-container.mobile-preview .block-2x1,
.bento-grid-container.mobile-preview .block-1x2,
.bento-grid-container.mobile-preview .block-2x2,
.bento-grid-container.mobile-preview .block-3x1 {
  width: auto !important;
  height: auto !important;
}

.bento-grid-container.mobile-preview .block-1x1 {
  grid-column: span 1 !important;
  grid-row: span 1 !important;
}

.bento-grid-container.mobile-preview .block-2x1,
.bento-grid-container.mobile-preview .block-3x1 {
  grid-column: span 2 !important;
  grid-row: span 1 !important;
}

.bento-grid-container.mobile-preview .block-1x2 {
  grid-column: span 1 !important;
  grid-row: span 2 !important;
}

.bento-grid-container.mobile-preview .block-2x2 {
  grid-column: span 2 !important;
  grid-row: span 2 !important;
}

/* Drag states */

/* Ghost element - the placeholder showing where the block will drop */
.bento-block.sortable-ghost {
  opacity: 1 !important;
  background: transparent !important;
  border: 2px dashed rgba(59, 130, 246, 0.5) !important;
  border-radius: 10px !important;
  box-shadow: none !important;
}

/* Hide all content inside the ghost, just show the dashed border */
.bento-block.sortable-ghost > * {
  opacity: 0 !important;
}

/* The dragged element (fallback clone that follows cursor) */
/* Note: SortableJS appends this to body with inline position:fixed styles */
/* Styles are also applied via JS onClone callback for reliability */
.sortable-fallback {
  opacity: 1 !important;
  visibility: visible !important;
  cursor: grabbing !important;
  /* Disable transitions to prevent animation conflicts */
  transition: none !important;
}

/* Make sure content inside dragged element is visible */
.sortable-fallback > *,
.sortable-fallback > * > * {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Chosen state - when block is selected but drag hasn't started */
.bento-block.sortable-chosen {
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.bento-block[data-block-type="section_title"].sortable-chosen {
  background-color: var(--section-drag-bg);
}

.bento-block.sortable-drag {
  cursor: grabbing;
}

/* Animate other blocks smoothly when making room */
.is-dragging .bento-block:not(.sortable-ghost):not(.sortable-fallback) {
  transition: transform 0.15s cubic-bezier(0.2, 0, 0.2, 1) !important;
}

/* SortableJS fallback element in mobile preview mode */
/* The fallback is appended to body, so we need body class to target it */
/* Constrain size while preserving the scale animation */
body.mobile-preview-active .sortable-fallback.bento-block {
  width: 140px !important;
  height: 140px !important;
}

body.mobile-preview-active .sortable-fallback.block-2x1,
body.mobile-preview-active .sortable-fallback.block-3x1 {
  width: 300px !important;
  height: 140px !important;
}

body.mobile-preview-active .sortable-fallback.block-1x2 {
  width: 140px !important;
  height: 300px !important;
}

body.mobile-preview-active .sortable-fallback.block-2x2 {
  width: 300px !important;
  height: 300px !important;
}

/* Empty block placeholder */
.bento-block-empty {
  background: transparent;
  border: 2px dashed var(--placeholder-border);
  border-radius: 10px;
}

.bento-block-empty:hover {
  border-color: var(--placeholder-hover-border);
  background: var(--placeholder-hover-bg);
}

/* Drop placeholder for drag-and-drop */
.drop-placeholder {
  pointer-events: none;
}

.drop-placeholder[data-placeholder-type="section_title"] {
  height: auto !important;
  min-height: auto !important;
  padding: 16px 0;
}

/* Paste upload placeholder */
.paste-upload-placeholder {
  background: var(--placeholder-bg);
  border: 2px dashed var(--placeholder-border);
  border-radius: 10px;
  animation: pulse-border 1.5s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% {
    border-color: var(--placeholder-border);
  }
  50% {
    border-color: var(--placeholder-hover-border);
  }
}

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */


input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0px 1000px white inset !important;
}

.dark input:-webkit-autofill,
.dark input:-webkit-autofill:hover,
.dark input:-webkit-autofill:focus,
.dark input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0px 1000px #56534F inset !important;
    -webkit-text-fill-color: #E5E4E3 !important;
}

/* Ensure contenteditable caret matches text color */
[contenteditable="true"] {
    caret-color: currentColor;
}




#about p {
    margin-bottom: 20px;
}

/* Scrolling Frame Gallery Animation */
@keyframes scroll-gallery {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

.animate-scroll-gallery {
    animation: scroll-gallery 30s linear infinite;
    will-change: transform;
}

/* Pause animation on hover for better UX */
.animate-scroll-gallery:hover {
    animation-play-state: paused;
}

/* Gallery item hover effects */
.gallery-container .group:hover .animate-scroll-gallery {
    animation-play-state: paused;
}

/* Gallery container - transparent background */
.gallery-container {
    position: relative;
    background: transparent;
}

/* Smooth gallery scrolling */
.animate-scroll-gallery {
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

/* Prevent horizontal scrollbar */
html,
body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Ensure white background on iOS devices */
html {
    background-color: white;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: white;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* Fix iOS viewport issues */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

/* ============================================================================
   PAGE CONTENT EDITOR STYLES
   ============================================================================ */

/* Content editable area */
.page-content {
    outline: none;
    line-height: 1.75;
}

.page-content:focus {
    outline: none;
}

/* Placeholder text when empty */
.page-content:empty:before {
    content: 'Start writing...';
    color: #9ca3af;
    pointer-events: none;
}

.page-content.page-content-dark:empty:before {
    color: rgba(255, 255, 255, 0.4);
}

/* Content formatting styles */
.page-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: #334155;
    margin: 1.5rem 0 0.5rem 0;
    line-height: 1.4;
}

.page-content h2:first-child {
    margin-top: 0;
}

.page-content a {
    color: #475569;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.page-content a:hover {
    color: #334155;
}

.page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
    position: relative;
}

/* Image delete button overlay */
.page-image-wrapper {
    position: relative;
    display: block;
    max-width: 100%;
}

.page-image-wrapper img {
    display: block;
    margin: 0;
    border-radius: 0.5rem;
}

.page-image-delete {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: #1e293b;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.page-image-wrapper:hover .page-image-delete {
    opacity: 1;
}

.page-image-delete:hover {
    background: #334155;
}

.page-image-delete svg {
    width: 12px;
    height: 12px;
    color: #94a3b8;
}

.page-image-delete:hover svg {
    color: #f87171;
}

.page-content b,
.page-content strong {
    font-weight: 600;
}

/* ============================================================================
   FORMATTING TOOLBAR STYLES
   ============================================================================ */

.formatting-toolbar {
    position: fixed;
    z-index: 50;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    padding: 0.25rem;
    align-items: center;
    gap: 0.125rem;
}

.formatting-toolbar button {
    transition: background-color 0.15s ease;
    color: #374151;
}

.formatting-toolbar button:hover {
    background-color: #f3f4f6;
}

.formatting-toolbar button.bg-slate-200 {
    background-color: #e2e8f0;
}

/* Image upload placeholder */
.page-image-placeholder {
    background-color: #f8fafc;
    border: 2px dashed #cbd5e1;
}

/* Drop indicator for image drag and drop */
.page-drop-indicator {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: #3b82f6;
    border-radius: 2px;
    pointer-events: none;
    z-index: 10;
}

.page-drop-indicator::before,
.page-drop-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border-radius: 50%;
}

.page-drop-indicator::before {
    left: -4px;
}

.page-drop-indicator::after {
    right: -4px;
}

/* Insert button (image upload when cursor placed, no selection) */
.insert-button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.insert-button:hover {
    background: #f9fafb;
    color: #374151;
    border-color: #d1d5db;
}
