/* ===================================================================
   AL IHSAN INSTITUTE — KUTUB SITTA TRACKER
   Design language: a night-study ledger. Deep ink pages, brass leaf
   accents, and a beadwork (misbaha) motif standing in for progress —
   because counting ahadith and counting tasbih are the same gesture.
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root{
  --ink:        #0E1620;
  --ink-2:      #14202B;
  --panel:      #182833;
  --parchment:  #F3ECDA;
  --parchment-dim: #D9CFB4;
  --brass:      #C9A24B;
  --brass-hi:   #E7CD82;
  --maroon:     #A24B4B;
  --sage:       #5F9271;
  --hairline:   rgba(201,162,75,0.22);
  --text-dim:   #92A0AC;
  --radius:     10px;
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }

body{
  margin: 0;
  background: var(--ink);
  background-image:
    radial-gradient(ellipse at top, rgba(201,162,75,0.06), transparent 60%),
    repeating-linear-gradient(rgba(255,255,255,0.012) 0 1px, transparent 1px 3px);
  color: var(--parchment);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono{ font-family: 'JetBrains Mono', monospace; }

a{ color: var(--brass-hi); }

/* ---------- layout shell ---------- */
.wrap{
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ---------- header ---------- */
header.top{
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 40px;
}
.eyebrow{
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--brass);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before{
  content: "";
  width: 22px; height: 1px;
  background: var(--brass);
  display: inline-block;
}
h1.title{
  font-family: 'Amiri', serif;
  font-weight: 700;
  font-size: clamp(32px, 5vw, 52px);
  margin: 10px 0 6px;
  color: var(--parchment);
}
.subtitle{
  color: var(--text-dim);
  font-size: 15px;
  max-width: 640px;
}

.top-grid{
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  align-items: end;
  flex-wrap: wrap;
}

.countdown-box{
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 18px 22px;
  background: linear-gradient(180deg, var(--panel), var(--ink-2));
  text-align: right;
  min-width: 240px;
}
.countdown-box .label{
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 6px;
}
.countdown-box .num{
  font-family: 'JetBrains Mono', monospace;
  font-size: 36px; font-weight: 600; color: var(--brass-hi);
  line-height: 1;
}
.countdown-box .sub{ font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* ---------- hero bead chain (overall progress) ---------- */
.hero-progress{
  margin-top: 36px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 26px 28px 22px;
  background: linear-gradient(180deg, rgba(201,162,75,0.05), transparent);
}
.hero-progress .row{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.hero-progress .row h2{
  font-family: 'Amiri', serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--parchment);
}
.hero-progress .stat{
  font-family: 'JetBrains Mono', monospace;
  color: var(--brass-hi);
  font-size: 15px;
}
.hero-progress .stat span{ color: var(--text-dim); }

.bead-chain{
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
}
.bead-chain .cluster{
  display: flex; gap: 3px;
  padding-right: 8px;
  margin-right: 5px;
  border-right: 1px dashed var(--hairline);
}
.bead-chain .cluster:last-child{ border-right: none; }
.bead{
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink-2);
  border: 1px solid var(--hairline);
  flex: 0 0 auto;
}
.bead.filled{
  background: radial-gradient(circle at 30% 30%, var(--brass-hi), var(--brass) 70%);
  border-color: var(--brass);
  box-shadow: 0 0 6px rgba(201,162,75,0.35);
}

/* ---------- book grid ---------- */
.section-heading{
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 56px 0 20px;
  flex-wrap: wrap; gap: 10px;
}
.section-heading h2{
  font-family: 'Amiri', serif;
  font-size: 26px;
  margin: 0;
}
.section-heading .hint{ color: var(--text-dim); font-size: 13px; }

.book-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.book-card{
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  transition: border-color .2s ease, transform .2s ease;
}
.book-card:hover{ border-color: rgba(201,162,75,0.5); transform: translateY(-2px); }

.book-card .card-top{
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
}
.book-card h3{
  font-family: 'Amiri', serif;
  font-size: 19px;
  margin: 0 0 3px;
  color: var(--parchment);
}
.book-card .arabic{
  font-size: 13px; color: var(--text-dim); direction: rtl;
}

.bead-ring{ position: relative; width: 64px; height: 64px; flex: 0 0 auto; }
.bead-ring svg{ transform: rotate(-90deg); }
.bead-ring .pct{
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; font-weight: 600; color: var(--brass-hi);
}

.book-card .figures{
  display: flex; gap: 20px;
  margin: 16px 0 10px;
  font-family: 'JetBrains Mono', monospace;
}
.book-card .figures div span{
  display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-dim); font-family: 'Inter', sans-serif; margin-bottom: 3px;
}
.book-card .figures div b{ font-size: 16px; color: var(--parchment); font-weight: 600; }

.tag-row{ display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.tag{
  font-size: 11px; padding: 3px 9px; border-radius: 100px;
  border: 1px solid var(--hairline); color: var(--text-dim);
  text-transform: capitalize;
}
.tag.pace-detailed{ color: var(--brass-hi); border-color: var(--brass); }
.tag.pace-fast{ color: var(--sage); border-color: var(--sage); }

.pace-line{
  font-size: 12.5px; color: var(--text-dim); margin-top: 8px; padding-top: 10px;
  border-top: 1px dashed var(--hairline);
}
.pace-line b{ color: var(--parchment); font-weight: 600; }
.pace-line.behind b.flag{ color: var(--maroon); }
.pace-line.ontrack b.flag{ color: var(--sage); }

.book-note{
  font-size: 12px; color: var(--text-dim); font-style: italic; margin-top: 8px;
}

.inline-edit{
  margin-top: 12px; display: flex; gap: 8px; align-items: center;
}
.inline-edit input{
  width: 90px; background: var(--ink-2); border: 1px solid var(--hairline);
  color: var(--parchment); border-radius: 6px; padding: 6px 8px; font-family: 'JetBrains Mono', monospace;
}
.inline-edit button{
  font-size: 12px;
}

/* ---------- buttons ---------- */
button, .btn{
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid var(--brass);
  background: transparent;
  color: var(--brass-hi);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
button:hover, .btn:hover{ background: var(--brass); color: var(--ink); }
button.ghost{ border-color: var(--hairline); color: var(--text-dim); }
button.ghost:hover{ background: var(--panel); color: var(--parchment); }
button.small{ padding: 6px 10px; font-size: 12px; }
button.danger{ border-color: var(--maroon); color: var(--maroon); }
button.danger:hover{ background: var(--maroon); color: var(--parchment); }

/* ---------- class log ---------- */
.log-summary{
  display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 18px;
}
.log-summary .item{ font-family: 'JetBrains Mono', monospace; }
.log-summary .item b{ font-size: 20px; color: var(--brass-hi); display:block; }
.log-summary .item span{ font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }

table.log{
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.log thead th{
  text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline);
}
table.log tbody td{
  padding: 10px 10px;
  border-bottom: 1px solid rgba(201,162,75,0.08);
  color: var(--parchment);
}
table.log tbody tr:hover{ background: rgba(201,162,75,0.04); }
.status-pill{
  font-size: 11px; padding: 3px 9px; border-radius: 100px; border: 1px solid;
}
.status-pill.held{ color: var(--sage); border-color: var(--sage); }
.status-pill.missed{ color: var(--maroon); border-color: var(--maroon); }
.status-pill.rescheduled{ color: var(--brass-hi); border-color: var(--brass); }
.type-extra{ color: var(--brass-hi); font-size: 12px; }

.log-actions{ display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- add entry form ---------- */
.add-form{
  margin-top: 22px;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius);
  padding: 18px;
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
  gap: 12px;
  align-items: end;
}
.add-form.open{ display: grid; }
.add-form label{
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); display: block; margin-bottom: 5px;
}
.add-form input, .add-form select, .add-form textarea{
  width: 100%; background: var(--ink-2); border: 1px solid var(--hairline);
  color: var(--parchment); border-radius: 6px; padding: 8px 10px; font-family: 'Inter', sans-serif; font-size: 13px;
}
.add-form .full{ grid-column: 1 / -1; }

/* ---------- draft banner ---------- */
.draft-banner{
  display: none;
  background: linear-gradient(90deg, rgba(201,162,75,0.15), rgba(201,162,75,0.03));
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 28px;
  font-size: 13px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.draft-banner.show{ display: flex; }
.draft-banner b{ color: var(--brass-hi); }

/* ---------- sync badge ---------- */
.sync-badge{
  display: inline-block;
  margin-top: 12px;
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid var(--hairline);
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}
.sync-badge.live{ color: var(--sage); border-color: var(--sage); }
.sync-badge.offline{ color: var(--brass-hi); border-color: var(--brass); }

/* ---------- hero pace / actions ---------- */
.hero-pace{
  font-size: 13px; color: var(--text-dim); margin: 14px 0 4px;
}
.hero-pace b{ color: var(--brass-hi); font-family: 'JetBrains Mono', monospace; }
.hero-actions{ display:flex; gap:10px; margin-top:14px; flex-wrap:wrap; }

/* ---------- share confirm toast ---------- */
.share-confirm{
  display: none;
  align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(95,146,113,0.15), rgba(95,146,113,0.03));
  border: 1px solid var(--sage);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 28px;
  font-size: 13px;
}
.share-confirm.show{ display: flex; }

/* ---------- sparkline ---------- */
.spark-row{
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--hairline);
  gap: 10px; flex-wrap: wrap;
}
.spark-label{ font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); flex-shrink:0; }
.spark-empty{ font-size: 11.5px; color: var(--text-dim); font-style: italic; }

.card-actions{ margin-top: 14px; }

/* ---------- trend chart ---------- */
.trend-wrap{
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--panel);
}
.trend-chart{ width: 100%; height: auto; display: block; }
.trend-empty{ color: var(--text-dim); font-size: 13.5px; text-align: center; margin: 30px 0; }

/* ---------- table scroll (mobile) ---------- */
.table-scroll{ overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table{ min-width: 560px; }

/* ---------- footer ---------- */
footer{
  margin-top: 70px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
  color: var(--text-dim);
  font-size: 12.5px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}

@media (max-width: 720px){
  .wrap{ padding: 0 16px 60px; }
  header.top{ padding: 32px 0 24px; }
  .top-grid{ grid-template-columns: 1fr; gap: 18px; }
  .countdown-box{ text-align: left; min-width: 0; }
  .hero-progress{ padding: 20px 18px 18px; }
  .hero-progress .row{ flex-direction: column; align-items: flex-start; }
  .book-grid{ grid-template-columns: 1fr; }
  .section-heading{ margin: 40px 0 16px; }
  .add-form{ grid-template-columns: 1fr 1fr; }
  .log-summary{ gap: 18px; }
  table.log{ font-size: 12.5px; }
  .card-top{ flex-wrap: wrap; }
}

@media (max-width: 420px){
  h1.title{ font-size: 26px; }
  .add-form{ grid-template-columns: 1fr; }
  .bead-chain{ overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; }
}
