/* ═══════════════════════════════════════════════
   UK VISA LETTER WRITER — LEARN READY
   style.css
═══════════════════════════════════════════════ */

/* ── Design tokens ── */
:root {
  --blue: #1E7FD8;
  --blue-dark: #1565B0;
  --blue-light: #EAF4FD;
  --pink: #E91E8C;
  --pink-light: #FDE8F4;
  --orange: #F47C20;
  --orange-light: #FEF3E8;
  --dark: #0F1B2D;
  --mid: #4A5568;
  --muted: #718096;
  --border: #E2E8F0;
  --bg: #F7FAFC;
  --white: #FFFFFF;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(30, 127, 216, 0.10);
  --shadow-lg: 0 8px 40px rgba(30, 127, 216, 0.16);
  --transition: 0.2s ease;
}

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

/* ── Base ── */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(15, 27, 45, 0.06);
}

.logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--blue);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-dot {
  color: var(--orange);
}

.logo-badge {
  background: var(--blue-light);
  color: var(--blue);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-cta {
  display: inline-block;
  background: var(--blue);
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: 30px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition);
}

.header-cta:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

/* ══════════════════════════════════════
   HERO
══════════════════════════════════════ */
.hero {
  background: linear-gradient(135deg, #0F1B2D 0%, #1a3255 60%, #1E4F8C 100%);
  color: white;
  padding: 4.5rem 2rem 3.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(244, 124, 32, 0.12);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(233, 30, 140, 0.10);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero-tag {
  display: inline-block;
  background: rgba(244, 124, 32, 0.25);
  border: 1px solid rgba(244, 124, 32, 0.4);
  color: #FDBA74;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 30px;
  margin-bottom: 1.5rem;
  letter-spacing: 0.5px;
}

.hero h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.9rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1.2rem;
}

.hero h1 span {
  color: #FDA4CF;
}

.hero p {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.75);
  max-width: 560px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
}

.hero-stat {
  text-align: center;
}

.hero-stat strong {
  display: block;
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: white;
}

.hero-stat span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
}

/* ══════════════════════════════════════
   MAIN WRAPPER
══════════════════════════════════════ */
.main-wrap {
  max-width: 820px;
  margin: -2rem auto 4rem;
  padding: 0 1.5rem;
  position: relative;
  z-index: 10;
}

/* ══════════════════════════════════════
   CARDS
══════════════════════════════════════ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 1.5rem;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.card-sub {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1.8rem;
  line-height: 1.6;
}

/* ── Step label ── */
.step-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
}

/* ══════════════════════════════════════
   LETTER TYPE GRID
══════════════════════════════════════ */
.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.type-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--white);
  text-align: left;
  font-family: inherit;
}

.type-card:hover {
  border-color: var(--blue);
  background: var(--blue-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.type-card.selected,
.type-card[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue-light);
}

.type-icon {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.type-name {
  font-family: 'Syne', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 4px;
}

.type-card.selected .type-name,
.type-card[aria-pressed="true"] .type-name {
  color: var(--blue-dark);
}

.type-desc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ══════════════════════════════════════
   FORM
══════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-lbl {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--dark);
}

.req {
  color: var(--pink);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  resize: none;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234A5568' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 127, 216, 0.12);
}

.form-textarea {
  min-height: 90px;
}

/* ── Radio pills ── */
.radio-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-pill input {
  display: none;
}

.radio-pill label {
  display: inline-block;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--mid);
}

.radio-pill input:checked + label {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.radio-pill label:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* ══════════════════════════════════════
   GENERATE BUTTON
══════════════════════════════════════ */
.generate-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 30px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  letter-spacing: 0.3px;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(30, 127, 216, 0.4);
}

.generate-btn:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

/* ══════════════════════════════════════
   LOADING
══════════════════════════════════════ */
#loadingWrap {
  text-align: center;
  padding: 3.5rem 1rem;
}

.loading-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  box-shadow: var(--shadow-lg);
}

.loading-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 4px solid var(--blue-light);
  border-top-color: var(--blue);
  animation: spin 0.9s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.loading-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.8rem;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}

.lstep {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.4s;
  padding: 8px 14px;
  border-radius: 30px;
}

.lstep.visible {
  opacity: 1;
  color: var(--blue);
  background: var(--blue-light);
}

.lstep.done {
  opacity: 1;
  color: #16a34a;
  background: #dcfce7;
}

/* ══════════════════════════════════════
   RESULT
══════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-up {
  animation: fadeUp 0.4s ease both;
}

/* Result header */
.result-header {
  background: linear-gradient(135deg, #0F1B2D, #1a3255);
  border-radius: var(--radius);
  padding: 2rem;
  color: white;
  margin-bottom: 1.5rem;
}

.result-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.rbadge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.rbadge-blue   { background: rgba(30,  127, 216, 0.30); color: #90C8F8; border: 1px solid rgba(30,  127, 216, 0.4); }
.rbadge-pink   { background: rgba(233, 30,  140, 0.25); color: #FDA4CF; border: 1px solid rgba(233, 30,  140, 0.3); }
.rbadge-orange { background: rgba(244, 124, 32,  0.25); color: #FDBA74; border: 1px solid rgba(244, 124, 32,  0.3); }

.result-name {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.result-sub {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Action row */
.action-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 1.5rem;
}

.action-btn {
  padding: 12px 8px;
  border-radius: 30px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
}

.action-btn-blue    { background: var(--blue);   color: white; }
.action-btn-blue:hover    { background: var(--blue-dark); }
.action-btn-outline { background: white; color: var(--dark); border: 1.5px solid var(--border); }
.action-btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.action-btn-orange  { background: var(--orange); color: white; }
.action-btn-orange:hover  { background: #d96b15; }
.action-btn-dark    { background: var(--dark);   color: white; }
.action-btn-dark:hover    { background: #1a2f4a; }

.copied-msg {
  font-size: 0.78rem;
  color: #16a34a;
  text-align: center;
  margin-bottom: 0.5rem;
  font-weight: 500;
  min-height: 1.2em;
  transition: opacity var(--transition);
}

/* Letter card */
.letter-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.ai-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-dot {
  width: 8px;
  height: 8px;
  background: var(--blue);
  border-radius: 50%;
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

#letterOutput {
  font-size: 0.92rem;
  line-height: 1.9;
  color: var(--dark);
  white-space: pre-wrap;
  font-family: 'DM Sans', sans-serif;
}

/* Warning box */
.warning-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.warning-box a {
  color: var(--blue);
  text-decoration: underline;
}

.warning-box p {
  font-size: 0.85rem;
  color: #92400e;
  line-height: 1.6;
}

/* Tips box */
.tips-box {
  background: linear-gradient(135deg, #0F1B2D, #1a3255);
  border-radius: var(--radius);
  padding: 1.8rem;
  color: white;
  margin-bottom: 1.5rem;
}

.tips-title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tips-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tip-item {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}

.tip-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--orange);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* CTA box */
.cta-box {
  background: linear-gradient(135deg, var(--pink), #c4177a);
  border-radius: var(--radius);
  padding: 2rem;
  color: white;
  text-align: center;
  margin-bottom: 1.5rem;
}

.cta-box h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.cta-box p {
  font-size: 0.88rem;
  opacity: 0.9;
  margin-bottom: 1.2rem;
  line-height: 1.6;
}

.cta-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.cta-btn-white {
  background: white;
  color: var(--pink);
  border: none;
  padding: 11px 22px;
  border-radius: 30px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.cta-btn-white:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.cta-btn-outline {
  background: transparent;
  color: white;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  padding: 11px 22px;
  border-radius: 30px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color var(--transition);
}

.cta-btn-outline:hover {
  border-color: white;
}

/* Restart button */
.restart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px 0;
  width: 100%;
  transition: color var(--transition);
  margin-bottom: 1rem;
}

.restart-btn:hover {
  color: var(--blue);
}

/* ══════════════════════════════════════
   FOOTER
══════════════════════════════════════ */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  background: var(--white);
  line-height: 1.7;
}

footer a {
  color: var(--blue);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ══════════════════════════════════════
   PRINT STYLES
══════════════════════════════════════ */
@media print {
  header,
  footer,
  #formSection,
  .action-row,
  .cta-box,
  .tips-box,
  .restart-btn,
  .warning-box,
  .result-header,
  .ai-label,
  #loadingWrap,
  .hero {
    display: none !important;
  }

  body {
    background: white;
  }

  #resultArea {
    display: block !important;
  }

  .letter-card {
    box-shadow: none;
    border: none;
    padding: 0;
  }

  #letterOutput {
    font-size: 10pt;
    line-height: 1.8;
  }

  .main-wrap {
    margin: 0;
    padding: 0;
    max-width: 100%;
  }
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 640px) {
  .type-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-group.full {
    grid-column: 1;
  }

  .action-row {
    grid-template-columns: 1fr 1fr;
  }

  .hero {
    padding: 3rem 1.2rem 2.5rem;
  }

  .hero-stats {
    gap: 1.5rem;
  }

  .card {
    padding: 1.4rem 1.2rem;
  }

  header {
    padding: 0 1rem;
  }
}

/* ── Hidden utility (replaces display:none for a11y) ── */
[hidden] {
  display: none !important;
}
