/* ============================================================
   PARMARTH · STUDENTS DATABASE
   Design: a living register — warm paper, ledger rules, ink stamps
   ============================================================ */

:root{
  --paper: #F5FAFD;
  --paper-deep: #E9F3FA;
  --rule: #D9E7F2;
  --ink: #0B1E3D;
  --ink-soft: #45597A;
  --ink-faint: #8CA0BC;

  --marigold: #1AA6E0;
  --marigold-deep: #0E77A8;
  --marigold-pale: #DDF2FC;

  --teal: #0E7A8F;
  --teal-pale: #DCF0F0;

  --brick: #C0392B;
  --brick-pale: #FBE4E1;

  --indigo: #14345C;
  --indigo-pale: #E1EAF5;

  --card: #FFFFFF;
  --card-border: #DCE9F5;
  --shadow-sm: 0 2px 8px rgba(11,30,61,0.06);
  --shadow-md: 0 10px 30px rgba(11,30,61,0.10);
  --shadow-lg: 0 18px 50px rgba(11,30,61,0.16);

  --radius: 14px;
  --radius-sm: 8px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;
}

*, *::before, *::after{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
html, body{
  max-width: 100%;
  overflow-x: hidden;
}
body{
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

:focus-visible{
  outline: 2.5px solid var(--marigold-deep);
  outline-offset: 3px;
}

.wrap{
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- ledger background texture ---------- */
.ledger-bg{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 37px,
    var(--rule) 37px,
    var(--rule) 38px
  );
  opacity: 0.5;
  mask-image: linear-gradient(to bottom, black, black 60%, transparent 100%);
}

header, main, footer{ position: relative; z-index: 1; }

/* ---------- hero ---------- */
.hero{
  position: relative;
  padding: 52px 0 32px;
  border-bottom: 1px solid var(--rule);
}

.corner-logo{
  position: absolute;
  top: 20px;
  right: 24px;
  height: 76px;
  width: auto;
  z-index: 2;
}

@media (max-width: 640px){
  .corner-logo{ height: 48px; top: 16px; right: 16px; }
}

.eyebrow{
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--marigold-deep);
  margin: 0 0 18px;
}

.hero-title{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  color: var(--ink);
}

.hero-sub{
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 560px;
  margin: 0 0 32px;
}

.stat-row{
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.stat-pill{
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: var(--shadow-sm);
}

.stat-pill .num{
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 17px;
  color: var(--indigo);
}

.stat-pill .lbl{
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* ---------- section headers ---------- */
.section-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 28px;
  margin-bottom: 14px;
}

.section-head .eyebrow{ margin: 0; }

.hint{
  font-size: 12.5px;
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--font-display);
}

/* ---------- roll call scroller ---------- */
.scroller{
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 6px 24px 28px;
  margin: 0 -24px;
  scroll-snap-type: x proximity;
  scroll-padding-left: 24px;
  -webkit-overflow-scrolling: touch;
}

.scroller::-webkit-scrollbar{ height: 8px; }
.scroller::-webkit-scrollbar-track{ background: transparent; }
.scroller::-webkit-scrollbar-thumb{ background: var(--rule); border-radius: 8px; }

.roll-card{
  scroll-snap-align: start;
  flex: 0 0 208px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  text-align: left;
}

.roll-card:hover{
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.roll-card.active{
  border-color: var(--marigold-deep);
  box-shadow: 0 0 0 2.5px var(--marigold-pale), var(--shadow-md);
}

.roll-card .stamp{
  position: absolute;
  top: -10px;
  right: -8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px dashed var(--brick);
  color: var(--brick);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  transform: rotate(-9deg);
}

.roll-card .photo{
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--paper-deep);
  margin-bottom: 14px;
}

.roll-card .photo img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.roll-card .photo.initials{
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  color: var(--indigo);
  background: var(--indigo-pale);
}

.roll-card .name{
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 10px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fact-list{
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fact-list .fact{
  font-size: 12.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fact-list .fact .k{
  font-weight: 600;
  color: var(--marigold-deep);
}

.tag-row{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.tag.grp{ background: var(--teal-pale); color: var(--teal); }
.tag.addr{ background: var(--marigold-pale); color: var(--marigold-deep); }
.tag.cls{ background: var(--indigo-pale); color: var(--indigo); }

.tag.addr::before{
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--marigold-deep);
}

/* ---------- profile panel ---------- */
.profile-wrap{
  padding: 6px 0 8px;
}

.profile-card{
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  display: grid;
  grid-template-columns: 152px 1fr auto;
  gap: 26px;
  align-items: start;
  animation: unfold 0.32s cubic-bezier(.2,.8,.3,1);
}

@keyframes unfold{
  from{ opacity: 0; transform: translateY(-8px); }
  to{ opacity: 1; transform: translateY(0); }
}

.profile-card .photo{
  width: 152px;
  height: 152px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-deep);
  position: relative;
}

.profile-card .photo img{ width: 100%; height: 100%; object-fit: cover; display: block; }

.profile-card .photo.initials{
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 600;
  color: var(--indigo);
  background: var(--indigo-pale);
}

.profile-card .stamp{
  position: absolute;
  top: -12px;
  right: -12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px dashed var(--brick);
  color: var(--brick);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  transform: rotate(-9deg);
}

.profile-main .name{
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 6px;
}

.profile-main .tag-row{ margin-bottom: 18px; }

.info-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 28px;
}

.info-item{ min-width: 0; }

.info-item .k{
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 3px;
}

.info-item .v{
  font-size: 14.5px;
  color: var(--ink);
  margin: 0;
  word-break: break-word;
}

.info-item .v a{ color: var(--indigo); text-decoration: none; border-bottom: 1px solid var(--indigo-pale); }
.info-item .v a:hover{ border-color: var(--indigo); }
.info-item .v.empty{ color: var(--ink-faint); font-style: italic; }

.profile-close{
  background: var(--paper-deep);
  border: 1px solid var(--card-border);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.profile-close:hover{ background: var(--brick-pale); color: var(--brick); }

/* ---------- explore toggle ---------- */
.explore-toggle-section{
  padding: 28px 0 8px;
  text-align: center;
}

.explore-btn{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  color: var(--paper);
  background: var(--indigo);
  border: none;
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.explore-btn:hover{ transform: translateY(-2px); background: #2A3958; }

.explore-btn .chev{ transition: transform 0.25s ease; }
.explore-btn[aria-expanded="true"] .chev{ transform: rotate(180deg); }

/* ---------- explore section ---------- */
.explore{
  padding: 28px 0 48px;
  animation: unfold 0.3s ease;
}

.filter-bar{
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.filter-group{ min-width: 0; }

.filter-panel{
  display: contents;
}

.add-filters-btn{
  display: none;
}

.filter-label{
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 9px;
}

.search-input{
  width: 100%;
  border: 1px solid var(--card-border);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
}
.search-input:focus{ outline: none; border-color: var(--marigold-deep); background: var(--card); }

.chip-row{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip{
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--card-border);
  background: var(--paper);
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.chip:hover{ border-color: var(--marigold-deep); color: var(--ink); }

.chip[aria-pressed="true"]{
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
}

.reset-btn{
  align-self: end;
  justify-self: end;
  background: none;
  border: none;
  color: var(--brick);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 9px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.reset-btn:hover{ color: var(--brick); opacity: 0.75; }

.results-head{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px 14px;
}

.results-count{
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 0;
}

.results-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 640px;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
  margin-right: -4px;
}

.results-list::-webkit-scrollbar{ width: 8px; }
.results-list::-webkit-scrollbar-track{ background: var(--paper-deep); border-radius: 8px; }
.results-list::-webkit-scrollbar-thumb{ background: var(--rule); border-radius: 8px; }

.row-card{
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  min-height: 88px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.row-card:hover{ border-color: var(--marigold-deep); box-shadow: var(--shadow-sm); }

.row-left{
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.row-card .photo{
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--paper-deep);
  flex-shrink: 0;
}
.row-card .photo img{ width: 100%; height: 100%; object-fit: cover; display: block; }
.row-card .photo.initials{
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 22px;
  color: var(--indigo); background: var(--indigo-pale);
}

.row-left .name{
  font-weight: 700;
  font-size: 16px;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-right{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.no-results{
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}
.no-results .big{
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 8px;
}

/* ---------- footer ---------- */
.site-footer{
  border-top: 1px solid var(--rule);
  padding: 22px 0 40px;
}
.footer-inner{
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.site-footer p{
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}
.footer-dev{
  margin-top: 10px;
}
.footer-dev p{
  font-size: 11.5px;
  color: var(--ink-faint);
}
.footer-dev a{
  color: var(--marigold-deep);
  text-decoration: none;
  border-bottom: 1px dotted var(--marigold-deep);
}
.footer-dev a:hover{ color: var(--indigo); border-color: var(--indigo); }

/* ---------- auth: staff sign-in ---------- */

.auth-btn{
  position: absolute;
  top: 26px;
  right: 210px;
  z-index: 2;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--indigo);
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.auth-btn:hover{ border-color: var(--marigold-deep); color: var(--marigold-deep); }
.auth-btn.signed-in{
  color: var(--teal);
  border-color: var(--teal-pale);
  background: var(--teal-pale);
}

@media (max-width: 860px){
  .auth-btn{ top: 18px; right: 18px; font-size: 11.5px; padding: 7px 12px; }
  .corner-logo{ top: 74px; right: 24px; }
}
@media (max-width: 640px){
  .auth-btn{ top: 14px; right: 14px; }
  .corner-logo{ top: 60px; right: 16px; }
}

.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(11,30,61,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop[hidden]{ display: none; }

.modal{
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 28px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: unfold 0.22s ease;
}

.modal-close{
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--paper-deep);
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover{ background: var(--brick-pale); color: var(--brick); }

.modal-title{
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}

.modal-sub{
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 20px;
  line-height: 1.5;
}

.modal-field{
  margin-bottom: 14px;
}
.modal-field label{
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.modal-field input{
  width: 100%;
  border: 1px solid var(--card-border);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
}
.modal-field input:focus{ outline: none; border-color: var(--marigold-deep); background: var(--card); }

.modal-error{
  font-size: 12.5px;
  color: var(--brick);
  background: var(--brick-pale);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin: 0 0 14px;
}

.modal-submit{
  width: 100%;
  background: var(--indigo);
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}
.modal-submit:hover{ background: #2A3958; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 860px){
  .filter-bar{
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
  }

  .add-filters-btn{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--paper);
    border: 1px solid var(--card-border);
    color: var(--indigo);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 13.5px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .add-filters-btn .chev{ transition: transform 0.2s ease; }
  .add-filters-btn[aria-expanded="true"] .chev{ transform: rotate(180deg); }

  .filter-panel{
    display: none;
    flex-direction: column;
    gap: 16px;
  }
  .filter-panel.open{ display: flex; }

  .reset-btn{
    align-self: flex-start;
    justify-self: auto;
    padding-left: 0;
  }

  .row-card{
    flex-wrap: wrap;
    padding: 12px 14px;
    row-gap: 10px;
    min-height: 0;
  }
  .row-left{ width: 100%; }
  .row-right{ width: 100%; justify-content: flex-start; }
  .row-card .photo{ width: 52px; height: 52px; }
}

@media (max-width: 640px){
  .wrap{ padding: 0 18px; }
  .hero{ padding: 44px 0 32px; }
  .hero-sub{ font-size: 15.5px; }

  .profile-card{
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "photo close"
      "main main";
  }
  .profile-card .photo{ grid-area: photo; width: 96px; height: 96px; }
  .profile-close{ grid-area: close; justify-self: end; }
  .profile-main{ grid-area: main; }
  .info-grid{ grid-template-columns: 1fr 1fr; }

  .row-card .photo{ width: 46px; height: 46px; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
