/* ==========================================================================
   AMEWS — "Roll-call Ledger" design system
   Al Murtaza Society · Jaamia Al-Murtaza Mohammad ﷺ
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  /* Palette */
  --ink-teal:      #123832;
  --ink-teal-dark: #0B2622;
  --ink-teal-soft: #1B4C43;
  --ledger-cream:  #FBF6EA;
  --ledger-cream-dim: #F1EAD7;
  --brass:         #B8863B;
  --brass-dark:    #97692A;
  --seal-green:    #2F6B4F;
  --seal-green-soft: #E4EFE7;
  --stamp-red:     #A23E32;
  --stamp-red-soft:#F5E6E2;
  --ink:           #1C2622;
  --ink-faint:     #5B6863;
  --rule:          #D9CFB4;

  /* Type */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --radius-card: 18px;
  --radius-pill: 999px;
  --shadow-card: 0 10px 30px rgba(18, 56, 50, 0.10);
  --shadow-raised: 0 4px 14px rgba(18, 56, 50, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--ink-teal);
  min-height: 100vh;
  padding-bottom: 84px; /* space for bottom nav */
}

a { color: inherit; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* --------------------------------------------------------------------------
   Top chrome
   -------------------------------------------------------------------------- */

.ledger-header {
  background: linear-gradient(180deg, var(--ink-teal) 0%, var(--ink-teal-dark) 100%);
  color: var(--ledger-cream);
  padding: 28px 20px 40px;
  position: relative;
}

.ledger-header .eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ledger-header .eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brass);
  display: inline-block;
}

.ledger-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  line-height: 1.2;
}

.ledger-header .sub {
  font-size: 14px;
  color: rgba(251, 246, 234, 0.72);
  margin-top: 6px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ledger-cream);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.85;
  padding: 6px 0;
}

.back-link:hover { opacity: 1; }

/* torn-paper edge separating header from page body */
.ledger-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 18px;
  background: var(--ledger-cream);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 18' preserveAspectRatio='none'%3E%3Cpath d='M0 18 L0 6 Q5 0 10 6 T20 6 T30 6 T40 6 T50 6 T60 6 T70 6 T80 6 T90 6 T100 6 T110 6 T120 6 L120 18 Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 18' preserveAspectRatio='none'%3E%3Cpath d='M0 18 L0 6 Q5 0 10 6 T20 6 T30 6 T40 6 T50 6 T60 6 T70 6 T80 6 T90 6 T100 6 T110 6 T120 6 L120 18 Z'/%3E%3C/svg%3E");
  -webkit-mask-size: 120px 18px;
  mask-size: 120px 18px;
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
}

/* --------------------------------------------------------------------------
   Page body
   -------------------------------------------------------------------------- */

.page {
  background: var(--ledger-cream);
  min-height: calc(100vh - 120px);
  padding: 24px 16px 40px;
}

.container { max-width: 720px; margin: 0 auto; }

.section-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 14px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.section-label:first-child { margin-top: 0; }

/* --------------------------------------------------------------------------
   Flash / toast
   -------------------------------------------------------------------------- */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--seal-green-soft);
  border: 1px solid rgba(47, 107, 79, 0.25);
  color: var(--seal-green);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
}

.flash.flash-error {
  background: var(--stamp-red-soft);
  border-color: rgba(162, 62, 50, 0.25);
  color: var(--stamp-red);
}

.flash .flash-icon { font-size: 18px; line-height: 1.3; }
.flash strong { display: block; color: var(--ink); font-weight: 700; margin-bottom: 2px; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 22px;
}

/* Class tab card (dashboard) */
.class-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.class-card {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 18px 16px 16px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-card);
  border-top: 3px solid var(--brass);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 108px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.class-card:active { transform: scale(0.97); }

.class-card .class-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
}

.class-card .class-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}

.status-stamp {
  position: absolute;
  top: 12px; right: 12px;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  border: 2px solid;
}

.status-stamp.marked {
  color: var(--seal-green);
  border-color: var(--seal-green);
  background: var(--seal-green-soft);
}

.status-stamp.unmarked {
  color: var(--rule);
  border-color: var(--rule);
  background: transparent;
}

.status-stamp.partial {
  color: var(--brass);
  border-color: var(--brass);
  background: rgba(184, 134, 59, 0.12);
}

/* Quick action card */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-card {
  background: var(--ink-teal);
  color: var(--ledger-cream);
  border-radius: 14px;
  padding: 20px 16px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-raised);
}

.action-card .icon { font-size: 22px; color: var(--brass); }
.action-card .title { font-weight: 600; font-size: 14.5px; }
.action-card .desc { font-size: 12px; color: rgba(251,246,234,0.7); line-height: 1.4; }

/* --------------------------------------------------------------------------
   Buttons & forms
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-brass { background: var(--brass); color: #fff; box-shadow: 0 4px 14px rgba(184,134,59,0.35); }
.btn-teal { background: var(--ink-teal); color: var(--ledger-cream); }
.btn-outline { background: transparent; border: 2px solid var(--ink-teal); color: var(--ink-teal); }
.btn-block { width: 100%; }

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-faint);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.field-wrap { position: relative; margin-bottom: 18px; }

.field-wrap input[type="text"],
.field-wrap input[type="password"],
.field-wrap select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--rule);
  border-radius: 12px;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--ledger-cream);
  appearance: none;
}

.field-wrap select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%235B6863' stroke-width='2' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.field-wrap input:focus,
.field-wrap select:focus {
  outline: none;
  border-color: var(--brass);
  background: #fff;
}

.field-wrap.disabled select,
.field-wrap.disabled input {
  opacity: 0.5;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Student roster / stamp interaction (signature element)
   -------------------------------------------------------------------------- */

.roster-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.roster-toolbar input[type="search"] {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid var(--rule);
  border-radius: 12px;
  font-size: 14px;
  background: var(--ledger-cream);
}

.roster-toolbar input[type="search"]:focus { outline: none; border-color: var(--brass); }

.roster-list { display: flex; flex-direction: column; }

.roster-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px dashed var(--rule);
}

.roster-row:last-child { border-bottom: none; }

.roster-person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.roster-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--ink-teal);
  color: var(--ledger-cream);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.roster-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The stamp button itself */
.stamp-btn {
  appearance: none;
  border: none;
  background: none;
  width: 52px; height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stamp-btn .stamp-mark {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2.5px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  transform: rotate(-8deg) scale(1);
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.stamp-btn[data-state="present"] .stamp-mark {
  color: var(--seal-green);
  border-color: var(--seal-green);
  background: var(--seal-green-soft);
}

.stamp-btn[data-state="absent"] .stamp-mark {
  color: var(--stamp-red);
  border-color: var(--stamp-red);
  background: var(--stamp-red-soft);
  transform: rotate(6deg) scale(1);
}

.stamp-btn.just-stamped .stamp-mark {
  animation: stampHit 0.28s ease;
}

@keyframes stampHit {
  0% { transform: scale(1.55) rotate(0deg); opacity: 0.4; }
  60% { transform: scale(0.92) rotate(-6deg); opacity: 1; }
  100% { transform: scale(1) rotate(-8deg); }
}

.roster-row.is-absent { background: linear-gradient(90deg, rgba(162,62,50,0.04), transparent); }

/* Sticky summary + save bar */
.sticky-bar {
  position: sticky;
  bottom: 76px;
  background: rgba(251,246,234,0.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--rule);
  padding: 12px 4px 4px;
  margin-top: 8px;
}

.stat-strip {
  display: flex;
  justify-content: space-around;
  gap: 10px;
  margin-bottom: 12px;
  font-family: var(--font-mono);
}

.stat-strip .stat {
  text-align: center;
  flex: 1;
}

.stat-strip .stat .num { font-size: 22px; font-weight: 600; display: block; }
.stat-strip .stat .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
.stat-strip .stat.present .num { color: var(--seal-green); }
.stat-strip .stat.absent .num { color: var(--stamp-red); }

/* --------------------------------------------------------------------------
   Tables (records / summary)
   -------------------------------------------------------------------------- */

.ledger-table { width: 100%; border-collapse: collapse; }

.ledger-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  padding: 0 8px 10px;
  border-bottom: 2px solid var(--rule);
}

.ledger-table td {
  padding: 12px 8px;
  border-bottom: 1px dashed var(--rule);
  font-size: 14px;
  vertical-align: middle;
}

.ledger-table tr:last-child td { border-bottom: none; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.status-chip.present { background: var(--seal-green-soft); color: var(--seal-green); }
.status-chip.absent { background: var(--stamp-red-soft); color: var(--stamp-red); }

.pct-chip { font-family: var(--font-mono); font-weight: 600; }
.pct-excellent { color: var(--seal-green); }
.pct-good { color: #2E6C8E; }
.pct-average { color: var(--brass-dark); }
.pct-poor { color: var(--stamp-red); }

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-faint);
}

.empty-state .glyph { font-size: 40px; margin-bottom: 12px; color: var(--rule); }
.empty-state h4 { color: var(--ink); font-size: 17px; margin-bottom: 6px; font-family: var(--font-display); font-weight: 600; }
.empty-state p { font-size: 13.5px; line-height: 1.5; }

/* --------------------------------------------------------------------------
   Stamp confirmation overlay (shown right after saving attendance)
   -------------------------------------------------------------------------- */

.stamp-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: overlayFadeIn 0.25s ease;
}

.stamp-overlay.closing { animation: overlayFadeOut 0.25s ease forwards; }

@keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayFadeOut { from { opacity: 1; } to { opacity: 0; } }

.stamp-overlay-backdrop {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(11, 38, 34, 0.72);
  backdrop-filter: blur(2px);
}

.stamp-modal {
  position: relative;
  background: var(--ledger-cream);
  border-radius: 22px;
  padding: 34px 28px 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
  animation: modalPop 0.35s cubic-bezier(.34,1.56,.64,1) 0.05s both;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.88) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.big-stamp {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.big-stamp-ring {
  width: 92px; height: 92px;
  border-radius: 50%;
  border: 4px solid var(--seal-green);
  background: var(--seal-green-soft);
  color: var(--seal-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 700;
  transform: rotate(-8deg) scale(0.4);
  opacity: 0;
  animation: bigStampHit 0.5s cubic-bezier(.34,1.56,.64,1) 0.2s both;
  box-shadow: 0 8px 24px rgba(47, 107, 79, 0.25);
}

@keyframes bigStampHit {
  0% { transform: rotate(0deg) scale(1.8); opacity: 0; }
  55% { transform: rotate(-10deg) scale(0.92); opacity: 1; }
  100% { transform: rotate(-8deg) scale(1); opacity: 1; }
}

.stamp-modal h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--ink);
}

.stamp-modal-sub {
  font-size: 13.5px;
  color: var(--ink-faint);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Bottom navigation
   -------------------------------------------------------------------------- */

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--ink-teal-dark);
  border-top: 1px solid rgba(251,246,234,0.08);
  display: flex;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: rgba(251,246,234,0.55);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 6px 2px;
  border-radius: 10px;
}

.bottom-nav a .nav-icon { font-size: 18px; }

.bottom-nav a.active { color: var(--brass); }
.bottom-nav a.active .nav-icon { transform: translateY(-1px); }

/* --------------------------------------------------------------------------
   Misc / responsive
   -------------------------------------------------------------------------- */

.welcome-block { margin-bottom: 4px; }
.welcome-block h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.welcome-block p { font-size: 13.5px; color: var(--ink-faint); margin-top: 4px; }

@media (min-width: 600px) {
  .class-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 380px) {
  .class-grid { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: 1fr; }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
}
