/* ===========================================================
   JestAccess — "Request Slip" design language
   The digital form mirrors the paper request slip parents fill
   at the school office: letterhead, ruled fields, a ledger of
   results, an itemised receipt line, and an ink stamp on success.
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,500;0,600;0,700;1,600&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --paper:      #F8F7F2;
  --paper-deep: #F1EFE7;
  --line:       #DAD5C6;
  --line-soft:  #E9E6DB;
  --ink:        #16233F;
  --ink-soft:   #58627C;
  --ink-faint:  #8990A3;
  --brass:      #A9812E;
  --brass-deep: #856521;
  --stamp:      #2F6F4E;
  --stamp-void: #9C3B3B;
  --white:      #FFFFFF;
  --radius-s:   4px;
  --radius-m:   8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  background-image:
    linear-gradient(var(--paper) 0%, var(--paper) 100%);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: 'Lora', Georgia, serif; }
.mono  { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 28px 18px 56px;
}

/* ---------------- Letterhead ---------------- */

.letterhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--ink);
  position: relative;
  animation: ruleIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.letterhead::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -5px;
  height: 1px;
  background: var(--ink);
  opacity: 0.55;
}

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

.crest-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.school-logo {
  height: 36px;
  width: 36px;
  object-fit: cover;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
}

.wordmark {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.wordmark em {
  font-style: normal;
  color: var(--brass);
}

.form-no {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  text-align: right;
  line-height: 1.5;
}
.form-no strong { color: var(--ink-soft); display: block; font-size: 11px; }

/* ---------------- The slip ---------------- */

.slip {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 30px 26px 28px;
  box-shadow: 0 1px 0 var(--white), 0 12px 28px rgba(22, 35, 63, 0.06);
  position: relative;
  animation: slipIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.08s;
}

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

.step { display: none; }
.step.active {
  display: block;
  animation: stepIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

h1.title {
  font-size: 23px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.subtitle {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 24px;
  line-height: 1.5;
}

.error-banner {
  background: #FBF0EF;
  border: 1px solid #E9C7C2;
  color: var(--stamp-void);
  padding: 10px 14px;
  border-radius: var(--radius-s);
  font-size: 13px;
  margin-bottom: 18px;
}

/* ---------------- Ruled form fields (the "paper" input) ---------------- */

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 18px;
  margin-bottom: 8px;
}
.field-grid .span-2 { grid-column: 1 / -1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.field label .opt {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--ink-faint);
  font-size: 11px;
}

.field input,
.field select {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  padding: 6px 2px 9px;
  border: none;
  border-bottom: 1.5px solid var(--line);
  background: transparent;
  border-radius: 0;
  outline: none;
  transition: border-color 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2358627C'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 16px;
}
.field input::placeholder { color: var(--ink-faint); font-weight: 400; }
.field input:focus,
.field select:focus { border-bottom-color: var(--brass); }

.divider-dots {
  border: none;
  border-top: 1.5px dotted var(--line);
  margin: 22px 0 18px;
}

.search-field { margin-bottom: 4px; }
.search-field label { margin-bottom: 7px; display: block; }
.search-wrap { position: relative; }
.search-wrap input {
  width: 100%;
  padding-right: 26px;
}
.search-icon {
  position: absolute;
  right: 2px; bottom: 10px;
  color: var(--ink-faint);
  pointer-events: none;
  font-size: 14px;
}

/* ---------------- Ledger results ---------------- */

.results {
  margin-top: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  animation: rowIn 0.3s ease both;
}
.result-row:first-child { border-top: 1px solid var(--line-soft); }
.result-row:hover .result-name { color: var(--brass-deep); }
.result-row:hover { background: #FCFBF7; }
.result-row:active { background: var(--paper-deep); }

@keyframes rowIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.result-index {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-faint);
  width: 20px;
  flex-shrink: 0;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--ink);
  color: #EFE6CC;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid var(--line);
}

.result-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.result-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  transition: color 0.15s ease;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-meta {
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 1px;
}

.empty-state {
  font-size: 13px;
  color: var(--ink-faint);
  padding: 22px 4px;
  text-align: center;
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--brass);
  border-radius: 50%;
  margin: 20px auto;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Step 2: confirm / receipt ---------------- */

.back-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12.5px; font-weight: 600;
  color: var(--ink-faint);
  margin-bottom: 18px;
  display: inline-flex; align-items: center; gap: 5px;
}
.back-link:hover { color: var(--ink); }

.selected-block {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0 20px;
  border-bottom: 1.5px solid var(--ink);
}
.selected-block .avatar { width: 46px; height: 46px; font-size: 16px; }
.selected-block-name { font-family: 'Lora', serif; font-weight: 600; font-size: 18px; }
.selected-block-meta { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }

.receipt-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 20px 0 22px;
  font-size: 14px;
}
.receipt-line .rl-label { color: var(--ink-soft); white-space: nowrap; }
.receipt-line .rl-fill {
  flex: 1;
  border-bottom: 1.5px dotted var(--line);
  transform: translateY(-4px);
}
.receipt-line .rl-amount {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
}

.pay-note {
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 10px;
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-block;
  text-align: center;
  padding: 13px 20px;
  border-radius: var(--radius-s);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-block { display: block; width: 100%; }
.btn-primary {
  background: var(--ink);
  color: var(--white);
}
.btn-primary:hover { background: #0d1730; }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-outline:hover { background: var(--ink); color: var(--white); }

.btn-text {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
}
.btn-text:hover { color: var(--ink); text-decoration-color: var(--ink); }

.btn-row { display: flex; gap: 10px; margin: 22px 0 4px; }
.btn-row .btn { flex: 1; }

/* ---------------- Success / stamp state ---------------- */

.result-card { text-align: center; }

.stamp {
  width: 108px; height: 108px;
  margin: 4px auto 18px;
  border-radius: 50%;
  border: 3px double var(--stamp);
  color: var(--stamp);
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-9deg);
  position: relative;
  animation: stampHit 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  animation-delay: 0.15s;
}
.stamp.void { border-color: var(--stamp-void); color: var(--stamp-void); }
.stamp-text {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@keyframes stampHit {
  0%   { opacity: 0; transform: rotate(-9deg) scale(1.9); }
  60%  { opacity: 1; transform: rotate(-9deg) scale(0.94); }
  100% { transform: rotate(-9deg) scale(1); }
}

.success-name { font-family: 'Lora', serif; font-weight: 600; font-size: 20px; margin: 2px 0; }

.notice {
  background: var(--paper-deep);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12.5px;
  padding: 12px 14px;
  border-radius: var(--radius-s);
  margin: 18px 0;
  text-align: left;
  line-height: 1.5;
}

/* ---------------- Footer ---------------- */

.foot {
  text-align: center;
  color: var(--ink-faint);
  font-size: 11.5px;
  margin-top: 22px;
  letter-spacing: 0.01em;
}
.foot a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.foot a:hover { color: var(--ink); border-color: var(--ink); }

/* ---------------- Responsive ---------------- */

@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
  .slip { padding: 24px 18px 24px; }
  .wordmark { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
