/* ============================================================
   Cover Letter Builder — DOLY Studio
   Design System: Linear.app
   ============================================================ */

/* --- CSS Variables (Linear palette) --- */
:root {
  --primary: #5e6ad2;
  --primary-hover: #828fff;
  --primary-focus: #5e69d1;
  --on-primary: #fff;
  --ink: #f7f8f8;
  --ink-muted: #d0d6e0;
  --ink-subtle: #8a8f98;
  --ink-tertiary: #62666d;
  --canvas: #010102;
  --surface-1: #0f1011;
  --surface-2: #141516;
  --surface-3: #18191a;
  --hairline: #23252a;
  --hairline-strong: #34343a;
  --success: #27a644;
  --rounded-sm: 6px;
  --rounded-md: 8px;
  --rounded-lg: 12px;
  --rounded-pill: 9999px;
}

[data-theme="light"] {
  --ink: #121212;
  --ink-muted: #333;
  --ink-subtle: #666;
  --ink-tertiary: #999;
  --canvas: #fff;
  --surface-1: #f5f6f6;
  --surface-2: #ebeced;
  --surface-3: #e0e1e3;
  --hairline: #d0d0d0;
  --hairline-strong: #bbb;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
  letter-spacing: -0.05px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* --- Global Header --- */
.global-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 32px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  letter-spacing: -0.4px;
}
.breadcrumb { font-size: 13px; color: var(--ink-subtle); }
.breadcrumb a { color: var(--ink-subtle); }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { margin: 0 6px; }
.back-to-hub {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-subtle);
  padding: 6px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  transition: all 0.15s;
}
.back-to-hub:hover { color: var(--ink); border-color: var(--hairline-strong); }
.theme-toggle {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  color: var(--ink-subtle);
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--hairline-strong); }

/* --- 3-Column Layout --- */
.layout {
  display: grid;
  grid-template-columns: 180px 1fr 320px;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px;
}
.sidebar { position: sticky; top: 80px; align-self: start; }
.sidebar--left .ad-slot { min-width: 160px; }
.sidebar--right .ad-slot { min-width: 300px; }

/* --- Hero --- */
.hero-section {
  margin-bottom: 32px;
}
.hero-section h1 {
  font-size: 40px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -1px;
  margin-bottom: 12px;
}
.subtitle {
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink-muted);
  letter-spacing: -0.1px;
  max-width: 640px;
}

/* --- Template Picker --- */
.template-picker { margin-bottom: 24px; }
.template-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.template-tab {
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--rounded-pill);
  background: var(--surface-2);
  color: var(--ink-subtle);
  cursor: pointer;
  transition: all 0.15s;
}
.template-tab:hover { color: var(--ink); }
.template-tab.active {
  background: var(--primary);
  color: var(--on-primary);
}

/* --- Builder Card --- */
.builder-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-lg);
  padding: 24px;
  margin-bottom: 32px;
}
.builder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.form-heading {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--ink);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline);
}
.form-heading:not(:first-child) { margin-top: 24px; }

/* --- Form --- */
.form-row--2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 4px;
  letter-spacing: 0.4px;
}
.required { color: var(--primary); }
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  transition: border-color 0.15s;
  line-height: 1.5;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-focus);
  box-shadow: 0 0 0 2px rgba(94, 106, 210, 0.25);
}
.form-group textarea { resize: vertical; }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--ink-tertiary); }

/* --- Live Preview --- */
.builder-preview {
  display: flex;
  flex-direction: column;
}
.preview-heading {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline);
}
.preview-paper {
  flex: 1;
  background: #fff;
  color: #1a1a1a;
  border-radius: var(--rounded-md);
  padding: 32px;
  font-size: 13px;
  line-height: 1.7;
  font-family: 'Georgia', 'Times New Roman', serif;
  min-height: 400px;
  overflow-y: auto;
}
.preview-date {
  color: #555;
  margin-bottom: 16px;
  font-size: 12px;
}
.preview-contact {
  margin-bottom: 16px;
  font-size: 12px;
  color: #333;
  white-space: pre-line;
}
.preview-recipient {
  margin-bottom: 4px;
  font-size: 12px;
  color: #333;
  white-space: pre-line;
}
.preview-salutation {
  margin-bottom: 12px;
  font-weight: 600;
}
.preview-body p {
  margin-bottom: 12px;
  text-align: justify;
}
.preview-closing {
  margin-top: 12px;
  margin-bottom: 4px;
}
.preview-signature {
  font-weight: 600;
}
.preview-empty {
  color: #999;
  font-style: italic;
  font-family: 'Inter', sans-serif;
}

/* --- Action Buttons --- */
.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
}
.btn {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: var(--rounded-md);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.2;
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-focus); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--hairline);
}
.btn-secondary:hover { border-color: var(--hairline-strong); }
.btn-tertiary {
  background: transparent;
  color: var(--ink-subtle);
}
.btn-tertiary:hover { color: var(--ink); }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-1);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Ad Slots --- */
.ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--surface-1);
  border-radius: var(--rounded-sm);
  overflow: hidden;
}
.ad-slot--inline { margin: 32px 0; }
.ad-slot--bottom { margin-top: 32px; }

/* --- Educational Content --- */
.content-section {
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--hairline);
}
.content-section h2 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.6px;
  margin-bottom: 16px;
}
.content-section h2:not(:first-child) { margin-top: 48px; }
.content-section h3 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.2px;
  margin-top: 24px;
  margin-bottom: 8px;
}
.content-section p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-muted);
  margin-bottom: 12px;
  max-width: 720px;
}
.content-section a { color: var(--primary); }
.content-section a:hover { color: var(--primary-hover); }

/* --- FAQ --- */
.faq-section { margin-top: 48px; }
.faq-section details {
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  margin-bottom: 8px;
  overflow: hidden;
}
.faq-section summary {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  background: var(--surface-1);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.faq-section summary::-webkit-details-marker { display: none; }
.faq-section summary::after {
  content: '+';
  font-size: 18px;
  color: var(--ink-subtle);
  transition: transform 0.15s;
}
.faq-section details[open] summary::after {
  content: '-';
}
.faq-answer {
  padding: 0 16px 14px;
  background: var(--surface-1);
}
.faq-answer p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-muted);
}

/* --- Cross-Links --- */
.cross-links {
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--hairline);
}
.cross-links h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin-bottom: 16px;
}
.cross-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.cross-link-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-lg);
  transition: background 0.15s, border-color 0.15s;
}
.cross-link-card:hover {
  background: var(--surface-2);
  border-color: var(--hairline-strong);
}
.cross-link-icon { font-size: 24px; }
.cross-link-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.cross-link-desc {
  font-size: 13px;
  color: var(--ink-subtle);
  line-height: 1.4;
}

/* --- Global Footer --- */
.global-footer {
  border-top: 1px solid var(--hairline);
  padding: 32px;
  text-align: center;
  color: var(--ink-subtle);
  font-size: 13px;
}
.footer-links { margin-bottom: 8px; }
.footer-links a {
  color: var(--ink-subtle);
  margin: 0 12px;
}
.footer-links a:hover { color: var(--ink); }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr 300px;
  }
  .sidebar--left { display: none; }
}

@media (max-width: 768px) {
  .global-header { padding: 0 16px; }
  .breadcrumb { display: none; }
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
  .sidebar { display: none; }
  .hero-section h1 { font-size: 28px; letter-spacing: -0.6px; }
  .subtitle { font-size: 15px; }
  .builder-grid {
    grid-template-columns: 1fr;
  }
  .form-row--2col {
    grid-template-columns: 1fr;
  }
  .action-buttons {
    flex-wrap: wrap;
  }
  .action-buttons .btn { flex: 1; min-width: 120px; text-align: center; }
  .content-section h2 { font-size: 22px; }
  .ad-slot--inline { display: flex; }
}

@media (max-width: 480px) {
  .hero-section h1 { font-size: 24px; }
  .template-tabs { gap: 6px; }
  .template-tab { font-size: 13px; padding: 5px 10px; }
  .builder-card { padding: 16px; }
  .preview-paper { padding: 20px; font-size: 12px; }
}
