/* =============================================
   ISLAMIC LEGACY LETTERS
   Parchment feel — deep green, gold, cream
   Emotional, sacred, intimate
============================================= */
:root {
  --green-deep:  #1A3A2A;
  --green-mid:   #2D5A3D;
  --green-light: #EAF3ED;
  --gold:        #C9973A;
  --gold-light:  #E8C97A;
  --gold-pale:   #FDF6E8;
  --cream:       #FAF8F0;
  --parchment:   #F5F0E8;
  --white:       #FFFFFF;
  --text:        #1C1C1C;
  --text-mid:    #4B5563;
  --text-muted:  #9CA3AF;
  --border:      #E0D8CC;
  --radius:      12px;
  --ink:         #2C2416;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--cream);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--green-mid); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- HEADER ---- */
.site-header {
  background: var(--green-deep);
  border-bottom: 3px solid var(--gold);
  padding: 1.1rem 1.5rem;
  text-align: center;
}
.header-back {
  display: block;
  font-size: 0.72rem;
  color: rgba(232,201,122,0.55);
  margin-bottom: 0.4rem;
  text-align: left;
}
.header-back:hover { color: var(--gold); text-decoration: none; }
.header-bismillah {
  font-family: 'Amiri', serif;
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 0.3rem;
}
.header-title {
  font-family: 'Amiri', serif;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  color: #fff;
  line-height: 1.2;
  margin-bottom: 0.2rem;
}
.header-tagline {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  font-style: italic;
}

/* ---- LANDING ---- */
.landing-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  width: 100%;
}

.ayah-banner {
  background: var(--green-deep);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin-bottom: 2.5rem;
}
.ayah-arabic {
  font-family: 'Amiri', serif;
  font-size: 1.5rem;
  color: var(--gold);
  direction: rtl;
  line-height: 1.9;
  margin-bottom: 0.6rem;
}
.ayah-translation {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.7);
  font-style: italic;
  line-height: 1.65;
  margin-bottom: 0.3rem;
}
.ayah-ref { font-size: 0.7rem; color: rgba(255,255,255,0.35); }

.landing-intro {
  text-align: center;
  margin-bottom: 2.5rem;
}
.landing-title {
  font-family: 'Amiri', serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--green-deep);
  margin-bottom: 0.5rem;
}
.landing-sub {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto;
}

/* Letter type grid */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.type-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.15s, border-color 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.type-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  transform: translateY(-3px);
  border-color: var(--gold);
  text-decoration: none;
}
.type-icon { font-size: 1.75rem; margin-bottom: 0.5rem; display: block; }
.type-label {
  font-family: 'Amiri', serif;
  font-size: 1.05rem;
  color: var(--green-deep);
  margin-bottom: 0.2rem;
}
.type-desc { font-size: 0.75rem; color: var(--text-muted); line-height: 1.45; }

/* Open existing */
.open-existing {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 2rem;
}
.open-title {
  font-family: 'Amiri', serif;
  font-size: 1rem;
  color: var(--green-deep);
  margin-bottom: 0.75rem;
}
.open-row { display: flex; gap: 0.5rem; }
.open-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  background: var(--white);
  outline: none;
}
.open-input:focus { border-color: var(--gold); }
.btn-open {
  background: var(--green-mid);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
}

/* How it works */
.how-section { margin-top: 2rem; }
.how-title {
  font-family: 'Amiri', serif;
  font-size: 1.2rem;
  color: var(--green-deep);
  text-align: center;
  margin-bottom: 1.25rem;
}
.how-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  text-align: center;
}
.how-step-num {
  font-family: 'Amiri', serif;
  font-size: 1.8rem;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.35rem;
}
.how-step-title { font-weight: 600; font-size: 0.85rem; color: var(--green-deep); margin-bottom: 0.2rem; }
.how-step-desc  { font-size: 0.75rem; color: var(--text-muted); line-height: 1.5; }

/* ---- WRITER ---- */
.writer-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  width: 100%;
}

.writer-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--green-light);
  color: var(--green-mid);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}

.writer-header {
  margin-bottom: 1.75rem;
}
.writer-title {
  font-family: 'Amiri', serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--green-deep);
  margin-bottom: 0.3rem;
}
.writer-sub { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }

/* Prompts sidebar */
.writer-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1.5rem;
  align-items: start;
}

.prompts-panel {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  position: sticky;
  top: 1.5rem;
}
.prompts-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 0.75rem;
}
.prompt-item {
  font-size: 0.78rem;
  color: var(--text-mid);
  line-height: 1.55;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.14s;
  margin-bottom: 0.3rem;
  border-left: 2px solid transparent;
}
.prompt-item:hover {
  background: var(--green-light);
  border-left-color: var(--gold);
  color: var(--green-deep);
}
.prompt-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-style: italic;
}

/* The letter editor */
.letter-form { }

.letter-meta {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.form-group { margin-bottom: 0.85rem; }
.form-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.form-control {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.14s;
}
.form-control:focus { border-color: var(--gold); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* The letter textarea — the heart of it */
.letter-editor-wrap {
  background: var(--parchment);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.03);
}
.letter-editor-top {
  background: var(--green-deep);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.letter-editor-label {
  font-family: 'Amiri', serif;
  font-size: 0.9rem;
  color: var(--gold-light);
  opacity: 0.85;
}
.letter-word-count {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.35);
}
.letter-textarea {
  width: 100%;
  min-height: 420px;
  border: none;
  background: var(--parchment);
  padding: 1.5rem;
  font-family: 'Georgia', 'Amiri', serif;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.85;
  resize: vertical;
  outline: none;
}
.letter-textarea::placeholder { color: var(--text-muted); font-style: italic; }

/* Actions */
.writer-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.btn-save {
  background: var(--gold);
  color: var(--green-deep);
  border: none;
  border-radius: 999px;
  padding: 0.7rem 2rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.14s;
}
.btn-save:hover { opacity: 0.9; }
.btn-save:disabled { opacity: 0.5; cursor: wait; }
.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-decoration: none;
}

/* ---- READ / VIEW ---- */
.read-wrap {
  max-width: 700px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  width: 100%;
}

.letter-envelope {
  background: var(--parchment);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
.envelope-header {
  background: var(--green-deep);
  padding: 1.75rem 2rem;
  text-align: center;
}
.envelope-bismillah {
  font-family: 'Amiri', serif;
  font-size: 1.4rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}
.envelope-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-light);
  opacity: 0.7;
  margin-bottom: 0.35rem;
}
.envelope-title {
  font-family: 'Amiri', serif;
  font-size: 1.6rem;
  color: #fff;
  line-height: 1.2;
}
.envelope-from {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  margin-top: 0.35rem;
}

.envelope-body {
  padding: 2.5rem 2rem;
}
.letter-content {
  font-family: 'Georgia', 'Amiri', serif;
  font-size: 1.02rem;
  color: var(--ink);
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
}

.envelope-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.envelope-date { font-size: 0.75rem; color: var(--text-muted); }
.envelope-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn-share {
  background: var(--gold);
  color: var(--green-deep);
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
}
.btn-wa {
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-edit-letter {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-decoration: none;
}

/* ---- SUCCESS / SHARE ---- */
.share-box {
  background: var(--green-light);
  border: 1.5px solid var(--green-mid);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin: 2rem 0;
}
.share-box-title {
  font-family: 'Amiri', serif;
  font-size: 1.2rem;
  color: var(--green-deep);
  margin-bottom: 0.35rem;
}
.share-box-sub { font-size: 0.82rem; color: var(--text-mid); margin-bottom: 1rem; line-height: 1.55; }
.share-link-row { display: flex; gap: 0; border-radius: 8px; overflow: hidden; border: 1.5px solid var(--border); margin-bottom: 0.75rem; }
.share-link-input { flex: 1; border: none; padding: 0.6rem 0.85rem; font-size: 0.78rem; font-family: 'Inter', sans-serif; background: var(--white); outline: none; color: var(--text-mid); }
.share-copy-btn { background: var(--green-deep); color: #fff; border: none; padding: 0.6rem 1rem; font-size: 0.78rem; font-weight: 600; font-family: 'Inter', sans-serif; cursor: pointer; }

/* ---- ALERTS ---- */
.alert { padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.85rem; margin-bottom: 1rem; }
.alert-success { background: #F0FDF4; border: 1px solid #BBF7D0; color: #166534; }
.alert-error   { background: #FEF2F2; border: 1px solid #FECACA; color: #DC2626; }

/* ---- FOOTER ---- */
.site-footer {
  background: var(--green-deep);
  border-top: 2px solid var(--gold);
  padding: 1.5rem;
  text-align: center;
  margin-top: auto;
}
.footer-hadith { font-size: 0.82rem; color: rgba(232,201,122,0.6); font-style: italic; margin-bottom: 0.4rem; font-family: 'Amiri', serif; }
.footer-links  { font-size: 0.72rem; color: rgba(232,201,122,0.4); }
.footer-links a { color: var(--gold); opacity: 0.7; }

/* ---- RESPONSIVE ---- */
@media (max-width: 700px) {
  .writer-layout { grid-template-columns: 1fr; }
  .prompts-panel { position: static; }
  .how-steps { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .envelope-body { padding: 1.5rem; }
}
@media (max-width: 400px) {
  .type-grid { grid-template-columns: 1fr; }
}
