/* Stanford identity palette: Cardinal, Palo Alto green, Sandstone, Fog, Stanford Black. */
:root {
  --bg: #f9f7f3;
  --surface: #ffffff;
  --surface-2: #f1ede4;
  --hero-bg: #f4efe4;
  --text: #2e2d29;
  --muted: #53565a;
  --border: #dad7cb;
  --accent: #8c1515;
  --btn-bg: #8c1515;
  --btn-bg-hover: #820000;
  --on-accent: #ffffff;
  --cardinal: #8c1515;
  --oak: #175e54;
  --oak-hi: #2f7a68;
  --bark: #5d4b3c;
  --sandstone: #d2c295;
  --disc: #ffffff;
  --ok: #175e54;
  --ok-bg: #e2eeea;
  --out: #6b5424;
  --out-bg: #f3ead2;
  --late: #b1040e;
  --late-bg: #f9e5e4;
  --footer-bg: #2e2d29;
  --footer-text: #dad7cb;
  --footer-link: #d2c295;
  --focus: rgba(140, 21, 21, 0.35);
  --shadow: 0 1px 2px rgba(46, 45, 41, 0.05), 0 10px 24px -14px rgba(46, 45, 41, 0.2);
  --radius: 12px;
  --sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #181715;
    --surface: #22211e;
    --surface-2: #2e2d29;
    --hero-bg: #201f1c;
    --text: #f4f1ea;
    --muted: #b6b1a9;
    --border: #3b3934;
    --accent: #ec8a82;
    --btn-bg: #b1040e;
    --btn-bg-hover: #c8161f;
    --on-accent: #ffffff;
    --cardinal: #c8161f;
    --oak: #4f8a70;
    --oak-hi: #6fa287;
    --bark: #a08a73;
    --sandstone: #d2c295;
    --disc: #2e2d29;
    --ok: #86c9a6;
    --ok-bg: rgba(111, 162, 135, 0.16);
    --out: #dccb9a;
    --out-bg: rgba(210, 194, 149, 0.14);
    --late: #ff8f85;
    --late-bg: rgba(255, 143, 133, 0.14);
    --footer-bg: #11100f;
    --footer-text: #b6b1a9;
    --footer-link: #d2c295;
    --focus: rgba(236, 138, 130, 0.45);
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 640px) { .wrap { padding: 0 32px; } }

/* ---- Stanford brand bar ---- */

.brandbar { background: #8c1515; color: #ffffff; }
.brandbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}
.brand-stanford { font: 600 20px/1 var(--serif); letter-spacing: 0.01em; }
.brand-divider { width: 1px; height: 20px; background: rgba(255, 255, 255, 0.55); }
.brand-unit { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }

/* ---- Hero ---- */

.hero {
  background: var(--hero-bg);
  border-bottom: 4px solid var(--sandstone);
  margin-bottom: 32px;
}
.hero-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 32px;
  padding-top: 48px;
  padding-bottom: 44px;
}

.eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 8px 0 12px;
  font: 600 clamp(38px, 7vw, 58px)/1.05 var(--serif);
  letter-spacing: -0.015em;
}

.lede {
  margin: 0;
  max-width: 50ch;
  font-size: 18px;
  color: var(--muted);
}

.emblem { width: 190px; height: 190px; display: block; }
.e-disc { fill: var(--disc); }
.e-ring { fill: none; stroke: var(--cardinal); stroke-width: 4; }
.e-ring-dots { fill: none; stroke: var(--sandstone); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 0.1 7.2; }
.e-ground { fill: var(--sandstone); opacity: 0.7; }
.e-bark { fill: var(--bark); }
.e-canopy { fill: var(--oak); }
.e-canopy-hi { fill: var(--oak-hi); }

@media (max-width: 640px) {
  .brand-stanford { font-size: 18px; }
  .brand-unit { font-size: 14px; }
  .hero-inner { grid-template-columns: 1fr; gap: 16px; padding-top: 28px; padding-bottom: 28px; }
  .emblem { order: -1; width: 76px; height: 76px; }
}

/* ---- Toolbar ---- */

.banner {
  margin: 0 0 20px;
  border-left: 4px solid var(--sandstone);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--out-bg);
  color: var(--text);
  font-size: 15px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 20px;
}

.summary { margin: 0; font-weight: 600; color: var(--muted); }

.filters {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.filters button {
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  background: transparent;
  color: var(--muted);
  font: 600 14px/1.2 var(--sans);
  cursor: pointer;
}
.filters button:hover { color: var(--text); }
.filters button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ---- Item grid ---- */

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge--ok { color: var(--ok); background: var(--ok-bg); }
.badge--out { color: var(--out); background: var(--out-bg); }
.badge--late { color: var(--late); background: var(--late-bg); }

.desc { margin: 0; color: var(--muted); font-size: 15px; }

.meta {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  font-size: 14px;
  color: var(--muted);
}
.meta strong { color: var(--text); font-weight: 600; }

.card-actions { margin-top: auto; padding-top: 6px; }
.card-actions .btn { width: 100%; }

.empty {
  grid-column: 1 / -1;
  padding: 32px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.skeleton {
  min-height: 150px;
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -150% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---- How it works ---- */

.how { margin: 56px 0 0; padding-top: 32px; border-top: 1px solid var(--border); }
.how h2::after { content: ''; display: block; width: 40px; height: 3px; margin-top: 10px; background: var(--cardinal); }
.how h2 { margin: 0 0 16px; font: 600 22px/1.2 var(--serif); }
.how ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
  counter-reset: step;
}
@media (min-width: 720px) { .how ol { grid-template-columns: repeat(3, 1fr); gap: 24px; } }
.how li {
  position: relative;
  padding-left: 40px;
  color: var(--muted);
  counter-increment: step;
}
.how li b { display: block; color: var(--text); }
.how li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
}

.site-footer {
  margin-top: 56px;
  padding: 36px 0 32px;
  background: var(--footer-bg);
  color: var(--footer-text);
  font-size: 15px;
  border-top: 4px solid var(--cardinal);
}
.site-footer a { color: var(--footer-link); }
.site-footer p { margin: 0; }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 40px;
}
.footer-inner > div { max-width: 52ch; display: grid; gap: 4px; }
.footer-title { font: 600 20px/1.2 var(--serif); color: #ffffff; }
.footer-note { margin-top: 24px !important; font-size: 13px; opacity: 0.75; }

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

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: 700 15px/1.2 var(--sans);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn--primary { background: var(--btn-bg); color: var(--on-accent); }
.btn--primary:hover:not(:disabled) { background: var(--btn-bg-hover); }
.btn--secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn--secondary:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

/* ---- Request dialog ---- */

dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(20, 16, 14, 0.5); }

.dialog-body { padding: 24px; }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.dialog-head h2 { margin: 0; font: 600 26px/1.2 var(--serif); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.field { display: grid; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field > span { font-size: 14px; font-weight: 700; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }

input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.4 var(--sans);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid var(--focus); outline-offset: 0; }
textarea { resize: vertical; min-height: 84px; }
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%238a817a' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
input[type="date"] { display: block; -webkit-appearance: none; appearance: none; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 400px) { .row { grid-template-columns: 1fr; } }

.return-by {
  margin: -4px 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 15px;
  color: var(--muted);
}
.return-by strong { color: var(--text); }

.alert {
  margin: -4px 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--late-bg);
  color: var(--late);
  font-size: 15px;
  font-weight: 600;
}

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.success { text-align: center; padding: 8px 4px 4px; }
.success-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--ok-bg);
  color: var(--ok);
}
.success h3 { margin: 0 0 8px; font: 600 24px/1.2 var(--serif); }
.success p { margin: 0 0 20px; color: var(--muted); }

[hidden] { display: none !important; }
