/* ==========================================================================
   Castana Bend Capital LP — base layer
   Tokens, reset, shared chrome (header, footer, buttons, forms, notices).
   Loaded on every page. Page-specific rules live in home.css / portal.css.
   ========================================================================== */

:root {
  /* palette — warm cream ground, crimson accent, umber hairlines */
  --cream: #f7f2e9;
  --cream-deep: #efe7d9;
  --paper: #fbf8f2;
  --ink: #241f1a;
  --ink-soft: #4d423a;
  --muted: #6e6156;
  --faint: #75675b;
  --umber: 90, 45, 35;                 /* rgb triplet for hairlines + motif */
  --line: rgba(var(--umber), 0.16);
  --line-soft: rgba(var(--umber), 0.08);
  --crimson: #852c27;
  --crimson-deep: #64211e;
  --crimson-soft: rgba(166, 40, 30, 0.10);
  --wash: rgba(140, 30, 20, 0.025);    /* faint tinted panel fill */

  /* status colours tuned for the cream ground */
  --ok: #2f6f3e;
  --ok-bg: rgba(47, 111, 62, 0.10);
  --ok-line: rgba(47, 111, 62, 0.28);
  --err: #a6281e;
  --err-bg: rgba(166, 40, 30, 0.08);
  --err-line: rgba(166, 40, 30, 0.28);
  --info: #4d423a;
  --info-bg: rgba(var(--umber), 0.05);
  --info-line: rgba(var(--umber), 0.18);

  /* type */
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* layout */
  --container: 1240px;
  --gutter: clamp(1.25rem, 4.5vw, 4rem);
  --header-h: 5rem;
  --radius: 0.7rem;
  --radius-lg: 1rem;
  --ease: cubic-bezier(0.22, 0.68, 0.32, 1);
}

/* ---------- reset ---------- */

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% -4%, rgba(166, 40, 30, 0.07), transparent 28%),
    linear-gradient(180deg, #faf6ee 0%, var(--cream) 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main { flex: 1 0 auto; }

img, svg { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

h1, h2, h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.1;
}

p { margin: 0; }

[hidden] { display: none !important; }

::selection { background: rgba(166, 40, 30, 0.18); }

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

.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;
}

.skip-link {
  position: absolute;
  top: -4rem;
  left: 1rem;
  z-index: 1000;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  background: var(--crimson);
  color: #fdfaf4;
  font-weight: 600;
  font-size: 0.9rem;
  transition: top 0.2s var(--ease);
}

.skip-link:focus { top: 1rem; }

.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

/* ---------- typographic helpers ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 1.4;
  color: var(--crimson);
}

.eyebrow--rule::before {
  content: "";
  width: 2.25rem;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
  flex-shrink: 0;
}

.eyebrow + h1,
.eyebrow + h2 { margin-top: 0.6rem; }

.lede {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 1.15rem + 0.8vw, 1.75rem);
  line-height: 1.38;
  letter-spacing: 0.002em;
  color: var(--ink);
  text-wrap: pretty;
}

.link {
  color: var(--crimson);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(166, 40, 30, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}

.link:hover { text-decoration-color: currentColor; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 242, 233, 0.84);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--line-soft);
  box-shadow: 0 10px 28px -22px rgba(36, 31, 26, 0.45);
}

.header-inner {
  position: relative;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 1.1rem + 0.8vw, 1.7rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--crimson);
  white-space: nowrap;
}

.brand-suffix {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.6rem;
}

.site-nav a {
  position: relative;
  padding: 0.35rem 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s ease;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--crimson);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease);
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a.is-active { color: var(--ink); }

.site-nav a:hover::after,
.site-nav a.is-active::after { transform: scaleX(1); }

.site-nav__login { display: none; }

.header-cta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-toggle {
  display: none;
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.nav-toggle span {
  display: block;
  width: 1rem;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.25s var(--ease), opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(0.225rem) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child  { transform: translateY(-0.225rem) rotate(-45deg); }

@media (max-width: 1020px) {
  .nav-ready .nav-toggle { display: inline-flex; }

  .header-inner:has(.site-nav) { flex-wrap: wrap; padding-block: 1rem; }
  .header-right { width: 100%; }
  .site-nav { flex-wrap: wrap; gap: 0.4rem 1.2rem; }
  .nav-ready .header-inner:has(.site-nav) { flex-wrap: nowrap; padding-block: 0; }
  .nav-ready .header-right { width: auto; }

  .nav-ready .site-nav {
    position: absolute;
    top: 100%;
    left: calc(-1 * var(--gutter));
    right: calc(-1 * var(--gutter));
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem var(--gutter) 1rem;
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 24px 40px -30px rgba(36, 31, 26, 0.5);
  }

  .nav-ready .site-nav.is-open { display: flex; }

  .nav-ready .site-nav a {
    padding: 0.85rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--line-soft);
  }

  .nav-ready .site-nav a::after { display: none; }

  .site-nav__login {
    display: block;
    color: var(--crimson);
    font-weight: 600;
    border-bottom: 0 !important;
  }

  .header-cta .header-login { display: none; }
}

@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; gap: 0.75rem; padding-block: 0.85rem; }
  .header-cta { flex-wrap: wrap; }
  .brand { white-space: normal; line-height: 1.15; }
  .brand-suffix { flex-shrink: 0; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.82rem 1.55rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  line-height: 1.2;
  white-space: normal;
  min-height: 2.75rem;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease,
              transform 0.22s ease, opacity 0.22s ease;
}

.btn--primary {
  background: var(--crimson);
  border-color: var(--crimson);
  color: #fdfaf4;
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--crimson-deep);
  border-color: var(--crimson-deep);
  transform: translateY(-1px);
}

.btn--ghost {
  color: var(--crimson);
  border-color: rgba(166, 40, 30, 0.32);
  background: transparent;
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  border-color: var(--crimson);
  background: var(--crimson-soft);
}

.btn--quiet {
  color: var(--ink-soft);
  border-color: var(--line);
  background: rgba(var(--umber), 0.02);
}

.btn--quiet:hover,
.btn--quiet:focus-visible {
  color: var(--ink);
  border-color: rgba(var(--umber), 0.3);
  background: rgba(var(--umber), 0.05);
}

.btn--sm {
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
}

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

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-arrow { transition: transform 0.22s var(--ease); }
.btn:hover .btn-arrow { transform: translateX(3px); }

.spinner {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -0.1em;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */

.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.field > label,
.field-row > label {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.field-row .link { font-size: 0.875rem; }

.field-hint {
  font-size: 0.875rem;
  color: var(--faint);
}

.input {
  width: 100%;
  padding: 0.78rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input::placeholder { color: rgba(110, 97, 86, 0.5); }

.input:focus {
  border-color: var(--crimson);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(166, 40, 30, 0.12);
}

.input:focus-visible { outline: none; }

.input[aria-invalid="true"] { border-color: var(--err); }

textarea.input {
  resize: vertical;
  min-height: 7.5rem;
  line-height: 1.6;
}

.field-error {
  font-size: 0.875rem;
  color: var(--err);
}

.field-error:empty { display: none; }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 4.25rem; }

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  transform: translateY(-50%);
  padding: 0.3rem 0.5rem;
  border: 0;
  border-radius: 0.35rem;
  background: none;
  font-size: 0.875rem;
  min-height: 2.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  transition: color 0.2s ease, background 0.2s ease;
}

.pw-toggle:hover,
.pw-toggle:focus-visible {
  color: var(--ink);
  background: rgba(var(--umber), 0.06);
}

/* ---------- notices ---------- */

.notice {
  padding: 0.8rem 1rem;
  border: 1px solid var(--info-line);
  border-radius: 0.6rem;
  background: var(--info-bg);
  color: var(--info);
  font-size: 0.86rem;
  line-height: 1.55;
}

.notice--ok  { border-color: var(--ok-line);  background: var(--ok-bg);  color: var(--ok); }
.notice--err { border-color: var(--err-line); background: var(--err-bg); color: var(--err); }

.notice + .notice { margin-top: 0.6rem; }

/* ---------- ridge motif (hero + auth backdrop) ----------
   Three receding angular ranges in the hairline umber. Decorative only. */

.ridge {
  position: absolute;
  inset: auto 0 0 0;
  pointer-events: none;
  overflow: hidden;
}

.ridge svg {
  width: 100%;
  height: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .ridge svg { animation: haze 1.9s ease-out 0.2s both; }
}

@keyframes haze { from { opacity: 0; } }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 3rem 0 2.5rem;
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
}

.footer-mark {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.015em;
  color: var(--crimson);
}

.footer-tag {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.88rem;
}

.footer-links a {
  color: var(--muted);
  transition: color 0.2s ease;
}

.footer-links a:hover,
.footer-links a:focus-visible { color: var(--ink); }

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.82rem;
  color: var(--faint);
}

.footer-bottom a:hover,
.footer-bottom a:focus-visible { color: var(--ink); }

.footer-bottom--flat {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.legal {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--muted);
}

@media (max-width: 600px) {
  .site-footer { padding: 2.5rem 0 2rem; }
  .footer-bottom { flex-direction: column; }
}
