/**
 * Gist /try Page Styles
 *
 * Design system aligned with options.html branding.
 * Features light/dark mode via prefers-color-scheme.
 *
 * COLOR PALETTE:
 * - Gradient: #FF6B6B → #FFD93D → #FF8E53 (coral → gold → orange)
 * - Ink hierarchy: primary (#1C1C24), secondary, tertiary, faint
 * - Paper hierarchy: background, surface, wash
 *
 * TYPOGRAPHY:
 * - System fonts: -apple-system, BlinkMacSystemFont, Inter, Helvetica Neue
 * - Weights: 400 (body), 500 (medium), 600 (semibold), 700 (bold), 800 (headline)
 * - Tracking: -0.03em for headlines, normal for body
 */

/* ============================================
   DESIGN TOKENS
   Aligned with options.css for consistent Gist branding.
   ============================================ */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Helvetica Neue', sans-serif;

  /* Light mode (matched to options.css) */
  --ink: #1C1C24;
  --ink-secondary: #4a4a4a;
  --ink-tertiary: #666666;
  --ink-faint: #b0b0b0;
  --paper: #ffffff;
  --wash: #fafafa;
  --surface: #ffffff;
  --border: #e8e8e8;
  --border-light: #f0f0f0;

  /* Brand gradient */
  --gradient-start: #FF6B6B;
  --gradient-mid: #FFD93D;
  --gradient-end: #FF8E53;
  --gradient: linear-gradient(135deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));

  /* Focus ring */
  --focus-ring: 0 0 0 3px rgba(255, 107, 107, 0.15);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* Dark mode (matched to options.css) */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f5f5f5;
    --ink-secondary: #c0c0c0;
    --ink-tertiary: #888888;
    --ink-faint: #555555;
    --paper: #0a0a0a;
    --wash: #000000;
    --surface: #161616;
    --border: #2a2a2a;
    --border-light: #1f1f1f;
  }
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--wash);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   LAYOUT
   ============================================ */
.try-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================
   HEADER
   ============================================ */
.try-header {
  padding: var(--space-6) var(--space-8);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.try-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.1em;
  text-decoration: none;
  color: var(--ink);
}

.try-logo-bolt {
  width: 0.85em;
  height: 1.4em;
}

.try-logo-text {
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.try-nav {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.try-nav-link {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink-tertiary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.try-nav-link:hover {
  color: var(--ink);
}

.try-auth-status {
  font-size: 0.875rem;
  color: var(--ink-secondary);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}

.try-auth-status.visible {
  display: inline-block;
}

.try-signin-btn {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-secondary);
  background: transparent;
  border: 1px solid var(--border);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.try-signin-btn:hover {
  background: var(--wash);
  border-color: var(--ink-tertiary);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.try-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-6) var(--space-12);
}

/* ============================================
   HERO SECTION
   ============================================ */
.try-hero {
  text-align: center;
  max-width: 720px;
  margin-bottom: var(--space-12);
}

.try-headline {
  font-weight: 800;
  font-size: clamp(2.5rem, 7vw, 4rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-5);
}

.try-headline-line {
  display: block;
}

.try-gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.try-subheadline {
  font-size: 1rem;
  color: var(--ink-secondary);
  line-height: 1.5;
  max-width: 400px;
  margin: 0 auto;
}

/* ============================================
   INPUT CONTAINER
   ============================================ */
.try-input-wrap {
  width: 100%;
  max-width: 680px;
}

.try-input-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.try-input-container:focus-within {
  border-color: var(--gradient-start);
  box-shadow: var(--focus-ring);
}

.try-input-container.drag-over {
  border-color: var(--gradient-mid);
  background: rgba(255, 217, 61, 0.04);
}

.try-textarea {
  width: 100%;
  min-height: 120px;
  max-height: 300px;
  resize: none;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.9375rem;
  padding: var(--space-5) var(--space-6);
  color: var(--ink);
  outline: none;
  line-height: 1.5;
}

.try-textarea::placeholder {
  color: var(--ink-faint);
}

/* ============================================
   FILE PREVIEW
   ============================================ */
.try-file-preview {
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin: 0 var(--space-4) var(--space-3);
  background: var(--wash);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--ink-secondary);
}

.try-file-preview.visible {
  display: flex;
}

.try-file-icon {
  width: 18px;
  height: 18px;
  color: var(--gradient-start);
  flex-shrink: 0;
}

.try-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.try-file-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.try-file-remove:hover {
  background: var(--border);
  color: var(--ink);
}

/* ============================================
   CONTROLS ROW
   ============================================ */
.try-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-light);
  background: var(--wash);
}

.try-controls-left {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.try-controls-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================
   ICON BUTTON
   ============================================ */
.try-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: none;
  border-radius: var(--radius-md);
  color: var(--ink-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.try-icon-btn:hover {
  background: var(--surface);
  color: var(--ink);
}

.try-icon-btn svg {
  width: 20px;
  height: 20px;
}

.try-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ============================================
   LANGUAGE SELECTOR
   ============================================ */
.try-lang-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.try-lang-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: none;
  border-radius: var(--radius-md);
  color: var(--ink-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.try-lang-trigger:hover {
  background: var(--surface);
  color: var(--ink);
}

.try-lang-trigger svg {
  width: 20px;
  height: 20px;
}

.try-lang-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-secondary);
  display: none;
}

.try-lang-label.visible {
  display: block;
}

.try-lang-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 200px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  padding: var(--space-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.15s ease;
  z-index: 100;
}

.try-lang-selector.open .try-lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.try-lang-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
}

.try-lang-section-title:first-child {
  margin-top: 0;
}

.try-lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.1s ease;
}

.try-lang-option:hover {
  background: var(--wash);
}

.try-lang-option.selected {
  color: var(--gradient-start);
}

.try-lang-check {
  width: 14px;
  height: 14px;
  opacity: 0;
}

.try-lang-option.selected .try-lang-check {
  opacity: 1;
}

/* ============================================
   SUBMIT BUTTON
   ============================================ */
.try-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--gradient);
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  /* Always dark text on gradient background (like options.css threshold-option.always) */
  color: #1C1C24;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.try-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(255, 107, 107, 0.35);
}

.try-submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.try-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.try-submit-icon {
  width: 14px;
  height: 24px;
}

/* ============================================
   HELPER TEXT
   ============================================ */
.try-helper {
  text-align: center;
  margin-top: var(--space-4);
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

/* ============================================
   STATUS MESSAGE
   ============================================ */
.try-status {
  text-align: center;
  margin-top: var(--space-4);
  font-size: 0.875rem;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  display: none;
}

.try-status.visible {
  display: block;
}

.try-status.loading {
  color: var(--ink-secondary);
  background: var(--wash);
}

.try-status.success {
  color: #059669;
  background: #ecfdf5;
}

.try-status.error {
  color: #dc2626;
  background: #fef2f2;
}

@media (prefers-color-scheme: dark) {
  .try-status.success {
    color: #34d399;
    background: #0f2922;
  }

  .try-status.error {
    color: #f87171;
    background: #2d1f1f;
  }
}

/* ============================================
   AUTH MODAL
   ============================================ */
.try-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.try-auth-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.try-auth-modal {
  position: relative;
  width: min(420px, 92vw);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.try-auth-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: transparent;
  border: none;
  color: var(--ink-tertiary);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}

.try-auth-close:hover {
  background: var(--wash);
  color: var(--ink);
}

.try-auth-close svg {
  width: 18px;
  height: 18px;
}

.try-auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.try-auth-subtitle {
  font-size: 0.95rem;
  color: var(--ink-secondary);
  margin-bottom: var(--space-6);
}

.try-auth-error {
  display: none;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid rgba(220, 38, 38, 0.2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
}

.try-auth-error.visible {
  display: block;
}

@media (prefers-color-scheme: dark) {
  .try-auth-error {
    color: #f87171;
    background: #2d1f1f;
    border-color: rgba(248, 113, 113, 0.2);
  }
}

.try-auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.try-auth-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.try-auth-input {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 0.95rem;
  color: var(--ink);
}

.try-auth-input:focus {
  outline: none;
  border-color: var(--gradient-start);
  box-shadow: var(--focus-ring);
}

.try-auth-submit {
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: none;
  background: var(--gradient);
  color: #1C1C24;
  font-weight: 700;
  cursor: pointer;
}

.try-auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.try-auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--ink-faint);
  font-size: 0.85rem;
  margin: var(--space-5) 0;
}

.try-auth-divider::before,
.try-auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.try-auth-google {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.try-auth-google:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================
   FOOTER
   ============================================ */
/* ============================================
   FOOTER
   ============================================ */
.try-footer {
  padding: var(--space-6) var(--space-8);
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  border-top: 1px solid var(--border-light);
}

.try-footer-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-faint);
  text-decoration: none;
  transition: color 0.15s ease;
}

.try-footer-link:hover {
  color: var(--ink-secondary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .try-header {
    padding: var(--space-5) var(--space-5);
  }

  .try-nav {
    gap: var(--space-4);
  }

  .try-nav-link {
    display: none;
  }

  .try-auth-status {
    display: none !important;
  }

  .try-main {
    padding: var(--space-6) var(--space-4) var(--space-10);
  }

  .try-hero {
    margin-bottom: var(--space-8);
  }

  .try-subheadline {
    font-size: 1rem;
  }

  .try-textarea {
    min-height: 100px;
    padding: var(--space-4) var(--space-5);
    font-size: 0.9375rem;
  }

  .try-controls {
    padding: var(--space-3);
  }

  .try-submit-btn {
    padding: var(--space-3) var(--space-4);
    font-size: 0.875rem;
  }

  .try-lang-label {
    display: none !important;
  }

  .try-footer {
    padding: var(--space-5);
    gap: var(--space-6);
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
