/* The House Ledger — shared design system.
 *
 * Single source of truth for typography, palette, atmosphere, and core
 * component primitives. Every served page links this. Page-specific tweaks
 * live in the page itself and cascade on top.
 *
 * Design direction: "Warm Modernist Hospitality"
 * Boutique hotel lobby meets modern SaaS. Rich earth tones, generous space,
 * precise typography, deliberate motion.
 */

/* ── Tokens ──────────────────────────────────────────────────────────── */
:root {
  /* Warm paper palette */
  --bg:            #EEE2CD;
  --bg-deep:       #E4D4B5;
  --surface:       #FBF6ED;
  --surface-warm:  #F7EED9;
  --surface-inset: #F0E5CE;

  /* Ink scale */
  --ink:           #241B14;
  --ink-soft:      #5B4A3A;
  --ink-fade:      #8B7A66;
  --ink-ghost:     #B3A38E;

  /* Hairlines */
  --line:          #D9C39C;
  --line-soft:     #E8D9BC;
  --line-strong:   #C4A978;

  /* Accents */
  --clay:          #B8452B;
  --clay-deep:     #8E3414;
  --clay-light:    #D4714F;
  --sage:          #7A8968;
  --sage-deep:     #4F5B43;
  --sage-light:    #A3B18A;
  --ember:         #D97441;
  --glow:          #F4C49A;
  --glow-soft:     #F9DDBF;
  --danger:        #A8341F;

  /* Effects */
  --shadow-paper:  0 1px 0 rgba(36, 27, 20, 0.04),
                   0 14px 36px -18px rgba(36, 27, 20, 0.18);
  --shadow-card:   0 1px 0 rgba(36, 27, 20, 0.05),
                   0 30px 60px -30px rgba(36, 27, 20, 0.25);
  --shadow-float:  0 4px 12px rgba(36, 27, 20, 0.08),
                   0 32px 80px -20px rgba(36, 27, 20, 0.3);
  --shadow-glow:   0 0 0 3px var(--glow-soft), 0 0 0 1px var(--glow);

  /* Radii */
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     18px;
  --radius-xl:     24px;
  --radius-pill:   999px;

  /* Motion */
  --ease-out:      cubic-bezier(.2, .7, .2, 1);
  --ease-spring:   cubic-bezier(.34, 1.56, .64, 1);
  --ease-smooth:   cubic-bezier(.4, 0, .2, 1);
  --dur-fast:      120ms;
  --dur-base:      200ms;
  --dur-slow:      400ms;
  --dur-enter:     550ms;
}

/* ── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
input, select, textarea, button { font: inherit; }

/* ── Body atmosphere: warm vignette + paper grain ───────────────────── */
body {
  font-family: 'Manrope', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02";
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(1400px 800px at 15% -10%, rgba(217, 116, 65, 0.16), transparent 60%),
    radial-gradient(1000px 700px at 120% 110%, rgba(122, 137, 104, 0.14), transparent 60%);
  pointer-events: none; z-index: 0;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='9'/><feColorMatrix values='0 0 0 0 0.14  0 0 0 0 0.1  0 0 0 0 0.07  0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: .45; mix-blend-mode: multiply; pointer-events: none; z-index: 0;
}

/* ── Typography ──────────────────────────────────────────────────────── */
.hl-display, .hl-display * {
  font-family: 'Fraunces', Georgia, 'Iowan Old Style', serif;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.hl-display em { font-style: italic; color: var(--clay-deep); font-weight: 400; }

.hl-mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.hl-eyebrow {
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--clay);
}

.hl-section-label {
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-fade);
  margin: 28px 0 12px;
}

/* ── Brand mark ──────────────────────────────────────────────────────── */
.hl-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--clay);
}
.hl-mark::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border: 1.5px solid var(--clay);
  transform: rotate(45deg);
  margin-right: 2px;
}
.hl-mark .issue {
  color: var(--ink-fade);
  font-weight: 500;
  letter-spacing: 0.14em;
}

.hl-colophon {
  text-align: center;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 12px;
  color: var(--ink-fade);
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  letter-spacing: 0.02em;
}
.hl-colophon::before { content: "\2014\00a0"; color: var(--clay); font-style: normal; }
.hl-colophon::after  { content: "\00a0\2014"; color: var(--clay); font-style: normal; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.hl-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-paper);
  position: relative;
  z-index: 1;
  transition: box-shadow var(--dur-base) var(--ease-smooth),
              transform var(--dur-fast) var(--ease-out);
}
.hl-card:hover {
  box-shadow: var(--shadow-card);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.hl-btn {
  font-family: 'Manrope', sans-serif;
  font-weight: 500;
  font-size: 15px;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-base) var(--ease-smooth),
              border-color var(--dur-base) var(--ease-smooth),
              color var(--dur-base) var(--ease-smooth),
              box-shadow var(--dur-base) var(--ease-smooth);
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.hl-btn:active { transform: translateY(1px); }
.hl-btn:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }

.hl-btn-primary {
  background: var(--ink); color: var(--surface);
}
.hl-btn-primary:hover { background: var(--clay-deep); }

.hl-btn-ghost {
  background: transparent; color: var(--ink); border-color: var(--line);
}
.hl-btn-ghost:hover { border-color: var(--ink); background: var(--surface); }

.hl-btn-danger {
  background: var(--clay); color: var(--surface);
}
.hl-btn-danger:hover { background: var(--clay-deep); }

.hl-btn-sage {
  background: var(--sage); color: var(--surface);
}
.hl-btn-sage:hover { background: var(--sage-deep); }

.hl-btn[disabled], .hl-btn:disabled {
  opacity: 0.4; pointer-events: none;
}

/* ── Form inputs ─────────────────────────────────────────────────────── */
.hl-field {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  color: var(--ink);
  transition: border-color var(--dur-base) var(--ease-smooth),
              box-shadow var(--dur-base) var(--ease-smooth);
}
.hl-field:focus {
  outline: none;
  border-color: var(--glow);
  box-shadow: var(--shadow-glow);
}
.hl-field::placeholder {
  color: var(--ink-ghost);
}

.hl-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

/* Checkbox refinement */
.hl-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-smooth);
}
.hl-check:hover { color: var(--ink); }
.hl-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--clay);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Tabs ────────────────────────────────────────────────────────────── */
.hl-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.hl-tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-fade);
  cursor: pointer;
  transition: color var(--dur-base) var(--ease-smooth),
              border-color var(--dur-base) var(--ease-smooth);
}
.hl-tab:hover { color: var(--ink-soft); }
.hl-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ── Badge / pill ────────────────────────────────────────────────────── */
.hl-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.hl-badge-open       { background: #FDE8D0; color: var(--ember); }
.hl-badge-acknowledged { background: #E8F0D8; color: var(--sage-deep); }
.hl-badge-resolved   { background: var(--surface-warm); color: var(--ink-fade); }
.hl-badge-clay       { background: rgba(184, 69, 43, 0.12); color: var(--clay); }

/* ── Dialogs ─────────────────────────────────────────────────────────── */
dialog.hl-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 28px;
  background: var(--surface);
  max-width: 520px;
  width: 92%;
  color: var(--ink);
  font-family: 'Manrope', sans-serif;
  box-shadow: var(--shadow-float);
  animation: hl-dialog-in var(--dur-enter) var(--ease-out) both;
}
dialog.hl-dialog::backdrop {
  background: rgba(36, 27, 20, 0.55);
  backdrop-filter: blur(6px);
  animation: hl-fade-in var(--dur-slow) var(--ease-smooth) both;
}
@keyframes hl-dialog-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes hl-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Toast ───────────────────────────────────────────────────────────── */
.hl-toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--surface);
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 20px 40px -10px rgba(36, 27, 20, 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-smooth),
              transform var(--dur-slow) var(--ease-spring);
  z-index: 1000;
}
.hl-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Page-load motion: staggered reveal ──────────────────────────────── */
@keyframes hl-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.hl-rise {
  animation: hl-rise var(--dur-enter) var(--ease-out) both;
}
.hl-rise:nth-child(1) { animation-delay: 0ms; }
.hl-rise:nth-child(2) { animation-delay: 70ms; }
.hl-rise:nth-child(3) { animation-delay: 140ms; }
.hl-rise:nth-child(4) { animation-delay: 210ms; }
.hl-rise:nth-child(5) { animation-delay: 280ms; }
.hl-rise:nth-child(6) { animation-delay: 350ms; }
.hl-rise:nth-child(n+7) { animation-delay: 400ms; }

/* Container-level entrance */
@keyframes hl-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}
.hl-fade-up {
  animation: hl-fade-up 0.7s var(--ease-out) both;
}

/* ── Divider ─────────────────────────────────────────────────────────── */
.hl-divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 24px 0;
}

/* ── Selection / scrollbar / link ────────────────────────────────────── */
::selection { background: var(--glow); color: var(--ink); }
a { color: var(--clay); text-decoration: none; transition: color var(--dur-base) var(--ease-smooth); }
a:hover { color: var(--clay-deep); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* Scrollbar (webkit) */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* ── Responsive utility ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .hl-section-label { margin: 22px 0 10px; }
}
