/* TypeVault Styles - Matching Figma Design */
.typevault-frame {
  width: 100%;
  max-width: 885px;
  margin: 0 auto;
  font-family: 'NaN Rage Soft VF', sans-serif;
  padding: 20px;
}

/* Font Showcase Grid */
.font-showcase-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}



.font-row {
  width: 100%;
  max-width: 850px;
  min-height: 100px;
  background: #FFF;
  border: 1px solid #000;
  border-radius: 50px;
  position: relative;
  margin: 0 auto 16px auto;
  padding: 20px 0;
  transition: all 0.3s ease, transform 0.2s ease;
  will-change: transform;
}

.font-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Expanded state for editing */
.font-row.editing {
  min-height: 140px;
  padding: 40px 0;
  max-height: none;
}

.font-tag {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
}

/* Clickable font tags with project links */
.font-tag.has-project-link {
  cursor: pointer;
  transition: all 0.2s ease;
}

.font-tag.has-project-link:hover {
  transform: translateY(-50%) translateY(-2px);
}

.font-tag.has-project-link .tag-text {
  transition: all 0.2s ease;
}

.font-tag.has-project-link:hover .tag-text {
  background: #FFE5A0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: scale(1.05);
}

.tag-text {
  background: #FFFBCC;
  border: 1px solid #000;
  border-radius: 200px;
  padding: 8px 16px;
  font-size: 12.6px;
  font-weight: 400;
  color: #000;
  font-family: 'NaN Rage Soft VF', sans-serif;
  line-height: 16px;
  text-transform: uppercase;
}

.font-preview {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 400px;
  transition: all 0.3s ease;
}

/* Expanded preview area for editing */
.font-row.editing .font-preview {
  width: 600px;
  max-width: calc(100% - 280px);
}

/* Ensure text can expand vertically */
.font-row.editing .preview-text {
  min-height: 1.2em;
  max-height: none;
  line-height: 1.3;
  white-space: normal;
}

.preview-text {
  font-size: 40px;
  font-weight: 400;
  color: #000;
  line-height: 1.2;
  margin: 0;
  transition: all 0.2s ease;
  cursor: text;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Hover effect for preview text */
.preview-text:hover {
  transform: scale(1.02);
  color: #333;
}

/* Editable state styling */
.preview-text[contenteditable="true"] {
  cursor: text;
  user-select: text;
  outline: none !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.preview-text[contenteditable="true"]:focus {
  outline: none !important;
}

.font-actions {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column; /* Default: column (vertical) layout, mobile overrides to row (horizontal) */
  gap: 8px;
}

/* Base class for all font action buttons */
.font-button {
  border: 1px solid #000;
  border-radius: 200px;
  padding: 8px 16px;
  font-size: 12.6px;
  font-weight: 400;
  color: #000;
  font-family: 'NaN Rage Soft VF', sans-serif;
  line-height: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: auto;
  height: 33px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.try-button {
  background: #CDEBFF;
  min-width: 61px;
}

.try-button:hover {
  background: #B8E0FF;
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.try-button:hover::after {
  content: "Click to edit • Tab for random phrase";
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  z-index: 1000;
  opacity: 0.9;
}

.request-button {
  background: #FFFBCC;
  min-width: 99px;
  height: 32px;
}

.request-button:hover {
  background: #F5F1A8;
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.client-work-button {
  background: #FFD9F7;
  min-width: 99px;
}

.client-work-button:hover {
  background: #FFE5F9;
  transform: translateY(-1px);
}

.not-ready-button {
  background: #F0F0F0;
  cursor: not-allowed;
  min-width: 89px;
  opacity: 0.7;
}

/* Font-specific styling for preview text */
.font-row[data-font="cheltender"] .preview-text {
  font-family: 'Cheltender', serif;
  font-size: 40px;
}

.font-row[data-font="otique"] .preview-text {
  font-family: 'Otique', serif;
  font-size: 43px;
}

.font-row[data-font="sooper"] .preview-text {
  font-family: 'Sooper', sans-serif;
  font-size: 43px;
  font-weight: 400;
}

.font-row[data-font="taman-serif"] .preview-text {
  font-family: 'Taman Serif', serif;
  font-size: 43px;
  font-weight: 300;
}

.font-row[data-font="amper-gothic"] .preview-text {
  font-family: 'Amper Gothic', sans-serif;
  font-size: 43px;
}

.font-row[data-font="coco-water"] .preview-text {
  font-family: 'Coco Water', sans-serif;
  font-size: 33.52px;
  line-height: 1.2;
  font-variation-settings: 'ytuc' 200;
  transition: font-variation-settings 0.15s ease-out;
}

/* Variable font animation for Coco Water on hover */
.font-row[data-font="coco-water"]:hover .preview-text {
  cursor: crosshair;
}

/* Visual indicator for the interactive area */
.font-row[data-font="coco-water"]:hover .font-preview {
  background: rgba(255, 251, 204, 0.1);
  border-radius: 8px;
  transition: background 0.2s ease;
}

.font-row[data-font="coco-water"] .font-preview {
  transition: background 0.2s ease;
}

.font-row[data-font="olymbeach"] .preview-text {
  font-family: 'Olymbeach', sans-serif;
  font-size: 43px;
}

.font-row[data-font="ark-sans"] .preview-text {
  font-family: 'Ark Sans', sans-serif;
  font-size: 43px;
}

.font-row[data-font="doo-sans"] .preview-text {
  font-family: 'Doo Sans', sans-serif;
  font-size: 43px;
}

.font-row[data-font="cason-sans"] .preview-text {
  font-family: 'Cason Sans', sans-serif;
  font-size: 43px;
}

.font-row[data-font="figlet"] .preview-text {
  font-family: 'Figlet', serif;
  font-size: 59px;
}

.font-row[data-font="sleek"] .preview-text {
  font-family: 'Sleek', cursive;
  font-size: 40px;
}

.font-row[data-font="noira"] .preview-text {
  font-family: 'Noira', sans-serif;
  font-size: 43px;
}

.font-row[data-font="trangtri"] .preview-text {
  font-family: 'TrangTri', monospace;
  font-size: 43px;
  font-weight: 400;
  font-feature-settings: 'tnum' 1; /* Enable tabular numerals */
  letter-spacing: 0.05em;
  animation: trangtri-weight-pulse 3s ease-in-out infinite;
}

/* Automatic weight animation for TrangTri */
@keyframes trangtri-weight-pulse {
  0% {
    font-weight: 100;
  }
  50% {
    font-weight: 900;
  }
  100% {
    font-weight: 100;
  }
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  html {
    overflow-x: hidden;
    overflow-y: scroll; /* Changed from auto to scroll to ensure scrolling works */
    height: 100%;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch; /* Enable smooth scrolling on iOS */
  }

  body {
    overflow-x: hidden !important;
    overflow-y: auto !important; /* Force auto scrolling */
    height: auto !important;
    min-height: 100vh !important;
    max-height: none !important; /* Remove any height constraints */
    width: 100% !important;
    max-width: 100% !important;
    position: relative !important;
    -webkit-overflow-scrolling: touch !important; /* Enable smooth scrolling on iOS */
  }

  .typevault-frame {
    padding: 4px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important; /* Allow content to be visible */
    position: relative !important;
    min-height: auto !important; /* Allow natural height */
    height: auto !important; /* Don't constrain height */
  }

  .font-showcase-grid {
    gap: 8px;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    min-height: auto !important; /* Allow natural height */
    height: auto !important; /* Don't constrain height */
  }

  .font-row {
    min-height: 70px; /* Slightly taller for better proportion */
    padding: 3px 3px 12px 3px; /* Increased bottom padding from 3px to 12px for more space */
    margin: 0 auto 6px auto;
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: 35px;
    width: 95%; /* Slightly less than full width for better appearance */
    max-width: 400px; /* Maximum width for readability */
    align-items: center;
    box-sizing: border-box;
  }

  .font-tag {
    display: none; /* Hide font name tag on mobile since text shows font name */
  }

  .font-preview {
    width: calc(100% - 6px); /* Extend width bigger, account for row padding */
    max-width: none;
    padding: 4px 12px; /* More padding for better appearance */
    position: static;
    transform: none;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFF;
    border-radius: 32px; /* Slightly larger radius for bigger pill */
    box-sizing: border-box;
    min-height: 48px; /* Increased height to prevent text clipping */
  }

  .preview-text {
    font-size: 28px !important; /* Larger font for bigger pill */
    line-height: 1.3; /* Slightly increased to prevent clipping */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 0; /* Add small vertical padding to prevent clipping */
  }

  /* Specific mobile font size adjustments for fonts that need smaller sizes */
  .font-row[data-font="coco-water"] .preview-text {
    font-size: 16px !important; /* Slightly larger but still fits */
    letter-spacing: -1.2px !important; /* Tighter letter spacing to save space */
    padding: 6px 4px !important; /* More vertical padding to prevent bottom cutoff */
    line-height: 1.5 !important; /* Increase line height to prevent clipping */
    overflow: visible !important; /* Allow text to be fully visible */
    transform: none !important; /* Remove horizontal scaling that might cause issues */
  }

  /* Ensure Coco Water container has enough space */
  .font-row[data-font="coco-water"] .font-preview {
    padding: 4px 2px !important; /* Add vertical padding to container */
    min-height: 55px !important; /* Increase minimum height significantly */
    overflow: visible !important; /* Allow text to be fully visible */
  }

  .font-row[data-font="figlet"] .preview-text {
    font-size: 24px !important; /* Much smaller size for this large display font */
  }

  /* Fonts with longer names that might need slightly smaller sizes */
  .font-row[data-font="amper-gothic"] .preview-text {
    font-size: 24px !important; /* Slightly smaller for "AMPER GOTHIC" text */
  }

  .font-row[data-font="taman-serif"] .preview-text {
    font-size: 24px !important; /* Slightly smaller for "Taman Serif" text */
  }

  .font-row[data-font="sleek"] .preview-text {
    font-size: 24px !important; /* Smaller size for script font on mobile */
  }

  .font-row[data-font="noira"] .preview-text {
    font-size: 24px !important;
  }

  .font-row[data-font="trangtri"] .preview-text {
    font-size: 24px !important;
    animation: trangtri-weight-pulse 3s ease-in-out infinite;
  }

  /* Mobile base class for all font action buttons */
  .font-button {
    font-size: 10px !important;
    font-weight: 400 !important;
    font-family: 'NaN Rage Soft VF', sans-serif !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    padding: 4px 8px !important;
    min-width: auto !important;
    height: auto !important;
    border-radius: 12px !important;
    margin: 0 !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    line-height: 1.2 !important;
    border: 1px solid #000 !important;
    cursor: pointer !important;
  }

  /* Only background colors differ */
  .try-button {
    background: #CDEBFF !important;
  }

  .not-ready-button {
    background: #F0F0F0 !important;
  }

  /* Remove hover effects on mobile */
  .try-button:hover::after {
    display: none;
  }

  /* Add touch feedback */
  .preview-text:active {
    opacity: 0.8;
    transform: scale(0.98);
    transition: all 0.1s ease;
  }

  /* Mobile-specific visual feedback for touch hold */
  .preview-text.touch-hold-active {
    opacity: 0.8;
    background: rgba(255, 251, 204, 0.2);
    border-radius: 8px;
    transition: all 0.2s ease;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .preview-text {
    cursor: default;
    touch-action: manipulation;
  }

  /* Remove all hover effects on touch devices */
  .font-row[data-font="coco-water"]:hover .preview-text {
    cursor: default;
  }

  .font-row[data-font="coco-water"]:hover .font-preview {
    background: none;
  }

  .try-button:hover {
    background: #CDEBFF;
    transform: none;
  }
}

/* Additional mobile fixes and overrides */
@media (max-width: 768px) {

  /* Prevent specific components from causing horizontal scroll */
  .typevault-frame,
  .font-showcase-grid,
  .font-row,
  .font-preview,
  .preview-text,
  .font-actions,
  .font-actions button,
  .try-button,
  .not-ready-button,
  .request-button,
  .client-work-button,
  .modal-content,
  .font-tester-input {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* FORCE horizontal layout for font actions - override all other rules */
  .typevault-frame .font-showcase-grid .font-row .font-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 4px !important;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: static !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    margin-top: 4px !important; /* Reverted to original value since bottom padding is the correct fix */
    width: 100% !important;
  }

  .font-actions::-webkit-scrollbar {
    display: none;
  }

  /* Additional mobile-specific positioning for font buttons */
  .typevault-frame .font-showcase-grid .font-row .font-actions .font-button {
    position: static !important;
  }

  /* CRITICAL: Ensure main containers don't block scrolling */
  .typevault-frame,
  .font-showcase-grid,
  .font-row {
    position: static !important;
    transform: none !important;
    will-change: auto !important;
  }
}

/* Font Tester Modal */
.font-tester-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #FFFBCC;
  border: 2px solid #000;
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    padding: 16px;
    max-height: 90vh;
    border-radius: 12px;
  }

  .modal-header h3 {
    font-size: 20px;
  }

  .modal-body .font-tester-input {
    min-height: 100px;
    font-size: 36px;
    padding: 16px;
  }

  .tester-controls {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .tester-controls button,
  .tester-controls select {
    width: 100%;
    min-height: 44px; /* Touch-friendly minimum size */
    font-size: 16px;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 24px;
  font-weight: 600;
  color: #000;
  margin: 0;
  font-family: 'NaN Rage Soft VF', sans-serif;
}

.close-modal {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #000;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body .font-tester-input {
  width: 100%;
  min-height: 120px;
  padding: 20px;
  border: 2px solid #000;
  border-radius: 8px;
  font-size: 48px;
  line-height: 1.2;
  background: #FFF;
  color: #000;
  resize: vertical;
  outline: none;
  margin-bottom: 16px;
  font-family: 'Cheltender', serif;
  box-sizing: border-box;
}

.tester-controls {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.random-phrase-btn {
  background: #D4F7DC;
  border: 1px solid #000;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #000;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  font-family: 'NaN Rage Soft VF', sans-serif;
}

.random-phrase-btn:hover {
  background: #B8F2C4;
  transform: translateY(-1px);
}

.size-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.size-control label {
  font-size: 14px;
  font-weight: 600;
  color: #000;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'NaN Rage Soft VF', sans-serif;
}

#fontSizeSlider {
  width: 120px;
  height: 6px;
  border-radius: 3px;
  background: #E5E7EB;
  outline: none;
  cursor: pointer;
}

#fontSizeValue {
  font-size: 12px;
  font-weight: 600;
  color: #000;
  min-width: 40px;
  text-align: center;
  font-family: 'NaN Rage Soft VF', sans-serif;
}

/* ===========================================
   FONT ROW WITH PROJECT VISUAL
   =========================================== */

.font-row.has-visual {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important;
  padding: 0 !important;
  border-radius: 24px !important;
  overflow: hidden !important;
  min-height: 180px !important;
}

.font-project-visual {
  position: relative;
  width: 240px;
  min-width: 240px;
  display: block;
  text-decoration: none;
  overflow: hidden;
  background: #f5f5f5;
}

.font-project-visual:hover .font-thumbnail {
  transform: scale(1.05);
}

.font-thumbnail {
  width: 100%;
  height: 100%;
  min-height: 180px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.3s ease;
  position: relative;
}

.font-thumbnail video,
.font-thumbnail iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
}

.font-thumbnail #mikey-sleek-slideshow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.font-thumbnail #mikey-sleek-slideshow img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%);
  transition: filter 0.3s ease;
}

.font-project-visual:hover .font-thumbnail #mikey-sleek-slideshow img {
  filter: none;
}

.visual-year {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #E8E8E8;
  border: 1px solid #000;
  border-radius: 200px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 400;
  color: #000;
  font-family: 'NaN Rage Soft VF', sans-serif;
  z-index: 10;
}

.font-row.has-visual .font-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px;
  position: relative;
}

.font-row.has-visual .font-tag {
  position: static;
  transform: none;
  margin-bottom: 0;
}

.font-row.has-visual .font-preview {
  position: static;
  transform: none;
  text-align: left;
  width: 100%;
  margin-bottom: 0;
}

.font-row.has-visual .font-actions {
  position: static;
  transform: none;
  flex-direction: row;
  justify-content: flex-start;
}

/* Specific thumbnail backgrounds - reuse existing S3 assets */
.font-thumbnail.sleek-thumbnail {
  background-color: #f8f8f8;
}

.font-thumbnail.sooper-thumbnail {
  background-image: url(https://codia-f2c.s3.us-west-1.amazonaws.com/image/2025-07-04/cwvSuCSiWQ.png);
  background-size: cover;
  background-position: center;
}

.font-thumbnail.otique-thumbnail {
  background-image: url(https://codia-f2c.s3.us-west-1.amazonaws.com/image/2025-07-04/0mJahRpbEq.png);
  background-size: cover;
  background-position: center;
}

.font-thumbnail.cason-thumbnail {
  background-image: url(https://codia-f2c.s3.us-west-1.amazonaws.com/image/2025-07-04/mPdSNnSh2L.png);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Coming soon overlay */
.font-row.coming-soon .font-project-visual {
  cursor: default;
}

.coming-soon-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.coming-soon-text {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'NaN Rage Soft VF', sans-serif;
}

/* Cason font preview styling */
.font-row[data-font="cason"] .preview-text {
  font-family: 'Cason', sans-serif;
  font-size: 40px;
}

/* ===========================================
   MOBILE STYLES FOR FONT ROWS WITH VISUALS
   =========================================== */
@media (max-width: 768px) {
  .font-row.has-visual {
    flex-direction: column;
    min-height: auto;
    border-radius: 20px;
  }

  .font-project-visual {
    width: 100%;
    min-width: 100%;
    height: 160px;
  }

  .font-thumbnail {
    min-height: 160px;
  }

  .font-row.has-visual .font-info {
    padding: 12px 16px;
  }

  .font-row.has-visual .font-tag {
    display: block;
    margin-bottom: 8px;
  }

  .font-row.has-visual .font-preview {
    text-align: center;
    margin-bottom: 12px;
  }

  .font-row.has-visual .font-actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .visual-year {
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    font-size: 10px;
  }
}
