/* Nirog Nepal Initiative
   Palette is taken from Nepal's own flag — crimson #C1272D, blue #003893 —
   pushed darker for the chrome and lit by a sunrise for the auth pages. */

:root {
  --navy: #002B5C;
  --navy-deep: #001B3D;
  --navy-line: #16447A;
  --crimson: #C1272D;
  --green: #17875C;
  --green-bright: #1FA06D;

  --ink: #14202E;
  --ink-muted: #5B6B7F;
  --ink-faint: #8A98A8;
  --rule: #E2E7ED;
  --rule-strong: #C7D0DA;
  --surface-subtle: #F6F8FA;

  --nav-height: 68px;
  --radius: 8px;
  --radius-lg: 14px;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Karla", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --deva: "Mukta", var(--body);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: #ffffff;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--navy);
}

/* Class selectors that set `display` outrank the browser's own
   [hidden] { display: none }, so `hidden` silently stops working on them.
   This keeps the attribute authoritative everywhere. */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--green-bright);
  outline-offset: 2px;
}

/* Hide the page until auth.js has decided whether you belong here, so a
   protected page never flashes before redirecting. Only applies when JS runs. */
html.js-guard body {
  visibility: hidden;
}

html.js-guard.auth-ready body {
  visibility: visible;
}

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  border-bottom: 1px solid var(--navy-line);
}

.nav {
  max-width: 1200px;
  margin: 0 auto;
  min-height: var(--nav-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: #ffffff;
  text-decoration: none;
  padding: 12px 0;
  white-space: nowrap;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand-deva {
  font-family: var(--deva);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.2;
  color: #9DB8D8;
}

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 28px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.nav-links a {
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.94rem;
  letter-spacing: 0.01em;
  padding: 22px 0;
  display: inline-block;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  border-bottom-color: #6E9AD0;
}

.nav-links a[aria-current="page"] {
  border-bottom-color: var(--crimson);
}

.nav-auth {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-user {
  color: #C6D8EE;
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-user strong {
  color: #ffffff;
  font-weight: 700;
}

.nav-auth a,
.nav-auth button.linklike {
  color: #C6D8EE;
  font-family: inherit;
  font-size: 0.92rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.nav-auth a:hover,
.nav-auth button.linklike:hover {
  color: #ffffff;
}

.nav-auth a.btn-green {
  color: #ffffff;
}

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

.btn {
  display: inline-block;
  background: var(--navy);
  color: #ffffff;
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  padding: 11px 20px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  background: var(--navy-deep);
}

.btn-green {
  background: var(--green);
  border-color: var(--green);
}

.btn-green:hover {
  background: var(--green-bright);
}

.btn-block {
  display: block;
  width: 100%;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.9rem;
}

.btn-quiet {
  background: transparent;
  color: var(--navy);
  border-color: var(--rule-strong);
  font-weight: 600;
}

.btn-quiet:hover {
  background: var(--surface-subtle);
  color: var(--navy);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--rule);
  border-color: var(--rule);
  color: var(--ink-faint);
  cursor: not-allowed;
}

/* ---------- Auth pages (sunrise backdrop) ---------- */

.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--navy-deep);
  background-image: url("assets/himalaya.svg");
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 22px 32px;
}

.auth-header .brand-name {
  font-size: 1.3rem;
}

.auth-header .brand-deva {
  color: #CBDCF0;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 72px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 20, 45, 0.35);
  padding: 36px 34px 30px;
}

.auth-card-wide {
  max-width: 520px;
}

/* A crimson rule under the heading — the one flash of Nepal's flag red. */
.auth-title {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
}

.auth-title::after {
  content: "";
  display: block;
  width: 46px;
  height: 3px;
  background: var(--crimson);
  border-radius: 2px;
  margin-top: 14px;
}

.auth-subtitle {
  color: var(--ink-muted);
  margin: 0 0 26px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 20px;
  color: var(--ink-faint);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.auth-footer {
  margin-top: 22px;
  font-size: 0.92rem;
  color: var(--ink-muted);
  text-align: center;
}

.auth-footer a {
  color: var(--navy);
  font-weight: 700;
}

/* ---------- Forms ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 11px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(0, 43, 92, 0.12);
}

.field input::placeholder {
  color: var(--ink-faint);
}

.field-hint {
  display: block;
  font-size: 0.84rem;
  color: var(--ink-faint);
  margin-top: 7px;
}

.field-inline {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 22px;
  font-size: 0.89rem;
  color: var(--ink-muted);
}

.field-inline input {
  margin: 4px 0 0;
  flex-shrink: 0;
}

.note-optional {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  vertical-align: 1px;
  white-space: nowrap;
}

/* Status messages */
.form-message {
  display: none;
  margin-bottom: 18px;
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
}

.form-message.is-visible {
  display: block;
}

.form-message.is-error {
  background: #FDECEC;
  border: 1px solid #F3C6C6;
  color: #8E1226;
}

.form-message.is-info {
  background: var(--surface-subtle);
  border: 1px solid var(--rule);
  color: var(--ink-muted);
}

/* ---------- Standard content pages ---------- */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  min-height: calc(100vh - var(--nav-height));
}

.page-title {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 8px;
}

.page-intro {
  color: var(--ink-muted);
  margin: 0 0 32px;
}

.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface-subtle);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 32px;
  font-size: 0.93rem;
  color: var(--ink-muted);
}

/* ---------- Donation record ---------- */

.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 40px;
}

.summary-card {
  flex: 1 1 180px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.summary-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 6px;
}

.summary-value {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0;
}

.section-title {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 16px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.record-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.record-table th,
.record-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

.record-table thead th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: var(--surface-subtle);
}

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

.empty-state td {
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-muted);
  white-space: normal;
}

.empty-state p {
  margin: 0 0 16px;
}

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

@media (max-width: 860px) {
  .nav {
    gap: 18px;
  }

  .nav-links {
    order: 3;
    width: 100%;
    gap: 20px;
    padding-bottom: 6px;
  }

  .nav-links a {
    padding: 8px 0;
  }

  .nav-auth {
    padding: 12px 0;
  }
}

@media (max-width: 600px) {
  .nav {
    padding: 0 16px;
  }

  .page {
    padding: 32px 16px 64px;
  }

  .auth-header {
    padding: 18px 20px;
  }

  .auth-card {
    padding: 28px 22px 24px;
  }

  .auth-title {
    font-size: 1.7rem;
  }

  /* background-attachment: fixed is janky on mobile browsers */
  .auth-body {
    background-attachment: scroll;
  }
}

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