/*
 * Tokens and primitives, inherited from the Excellency Group CRM so the two
 * products read as one system. Values are the CRM's own, copied from its
 * globals.css rather than approximated — including the reasoning behind them.
 */

@font-face {
  font-family: 'JakartaVar';
  src: url('/fonts/jakarta-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JakartaVar';
  src: url('/fonts/jakarta-latin-ext.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'FrauncesVar';
  src: url('/fonts/fraunces-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'FrauncesVar';
  src: url('/fonts/fraunces-latin-ext.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;

  --bg: #faf9f6;
  --panel: #ffffff;
  --rail: #f3f1ec;
  --rail-hover: #f7f5f0;
  --rail-active: #f3f1ea;
  --ink: #1a1713;
  --ink-2: #6b6459;
  --ink-3: #756f65;
  --line: #d8d3c6;
  --line-strong: #d3cdbf;

  /* The mark's khaki-gold darkened to 5:1 on cream, so it can carry text. */
  --accent: #7e6b38;
  --accent-hover: #665630;
  --accent-press: #4a3d1e;
  --accent-wash: #f6f2e6;
  /* The brand gold exactly as the mark uses it. Decorative only: rules,
     dots, the active venue swatch. Never text, never a meaningful border. */
  --brand-gold: #a89a6c;

  --success: #2f6a4a;
  --success-wash: #eef4f0;
  --warning: #846026;
  --warning-wash: #f8f3e9;
  --danger: #a0423a;
  --danger-wash: #f9efee;
  --info: #3c6183;
  --info-wash: #eff3f7;

  --series-track: #efece4;

  --font-ui: 'JakartaVar', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Only the plan document wears this, the way the CRM's contract and plan
     booklets do. The product UI stays on a single sans. */
  --font-serif: 'FrauncesVar', ui-serif, Georgia, serif;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --radius-panel: 10px;
  --radius-control: 8px;

  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --shadow-float: 0 16px 36px -12px rgba(26, 23, 19, 0.22), 0 3px 10px -4px rgba(26, 23, 19, 0.12);

  --shell: 1440px;
  --rail-w: 15rem;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

* { margin: 0; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

/* Browser surfaces belong to the design system, not to the browser. */
::selection { background: #e8dfc4; color: var(--ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

:where(a) {
  color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: from-font;
}

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

:where(input, textarea) { caret-color: var(--accent); }

:where(h1, h2, h3, h4) {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
:where(p) { text-wrap: pretty; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 6px;
}

/* Every figure in this product aligns in its column. */
table,
.tnum,
time,
input[type='number'] { font-variant-numeric: tabular-nums; }

.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.shell { width: min(100% - 32px, var(--shell)); margin-inline: auto; }
.prose-measure { max-width: 70ch; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-control);
  font-weight: 600;
  z-index: 100;
  transition: top 160ms var(--ease-out-expo);
}
.skip-link:focus { top: 12px; }

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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 2.5rem;
  padding: 0 1rem;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition: background-color 150ms var(--ease-out-expo), border-color 150ms var(--ease-out-expo),
    color 150ms var(--ease-out-expo), box-shadow 150ms var(--ease-out-expo);
}
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn--quiet { background: transparent; color: var(--ink-2); border-color: transparent; padding: 0 0.625rem; }
.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--sm { height: 2rem; padding: 0 0.625rem; font-size: 0.8125rem; }
.btn--sm svg { width: 14px; height: 14px; }
.btn--lg { height: 2.75rem; padding: 0 1.25rem; font-size: 0.9375rem; }
.btn--block { width: 100%; }

.btn:active:not(:disabled) { background: #f5f3ee; }
.btn--primary:active:not(:disabled) { background: var(--accent-press); }
.btn--danger:active:not(:disabled) { background: #781c16; }
.btn--ghost:active:not(:disabled),
.btn--quiet:active:not(:disabled) { background: #e7e3d9; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { border-color: var(--line-strong); background: #fbfaf7; }
  .btn--primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
  .btn--ghost:hover:not(:disabled),
  .btn--quiet:hover:not(:disabled) { background: #efece4; color: var(--ink); border-color: transparent; }
  .btn--danger:hover:not(:disabled) { background: #8d201a; border-color: #8d201a; }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2rem; height: 2rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: background-color 150ms var(--ease-out-expo), color 150ms var(--ease-out-expo);
}
.icon-btn svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: #efece4; color: var(--ink); }
  .icon-btn--danger:hover { background: var(--danger-wash); color: var(--danger); }
}

/* ----------------------------------------------------------------- fields */

.field { display: grid; gap: 0.375rem; }
.field > label,
.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}
.field-hint { font-size: 0.75rem; color: var(--ink-3); font-weight: 400; }

.input,
.select,
.textarea {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--ink);
  font-size: 0.875rem;
  transition: border-color 150ms var(--ease-out-expo);
}
.textarea { height: auto; min-height: 6rem; padding: 0.5rem 0.75rem; line-height: 1.6; resize: vertical; }
.input::placeholder,
.textarea::placeholder { color: var(--ink-3); }
.input:hover,
.select:hover,
.textarea:hover { border-color: var(--line-strong); }
.input:focus,
.select:focus,
.textarea:focus { border-color: var(--accent); }
.input:disabled,
.textarea:disabled { background: #f7f5f0; color: var(--ink-3); }
.input[aria-invalid='true'] { border-color: var(--danger); }

.select {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23756f65' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px;
}

.field-row { display: grid; gap: 0.875rem; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); }

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.check input {
  appearance: none;
  width: 1.125rem; height: 1.125rem;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out-expo), border-color 150ms var(--ease-out-expo);
}
.check input::after {
  content: '';
  width: 9px; height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0.6);
  opacity: 0;
  transition: opacity 120ms var(--ease-out-expo), transform 180ms var(--ease-out-expo);
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { opacity: 1; transform: rotate(-45deg) scale(1); }

/* ----------------------------------------------------------------- panels */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 1rem;
}
.card--flush { padding: 0; overflow: hidden; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.875rem;
}
/* Keeps the action on the right even once it wraps onto its own line. */
.section-head > *:last-child:not(:only-child) { margin-left: auto; }
.section-head h2 { font-size: 1.25rem; line-height: 1.3; }
.section-head h3 { font-size: 1rem; line-height: 1.4; }

/* ------------------------------------------------------------ status bits */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.125rem 0.5rem;
  margin-left: 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: 1px;
  background: var(--rail);
  color: var(--ink-2);
}
.chip--booked { background: var(--success-wash); color: var(--success); }
.chip--tbc { background: var(--warning-wash); color: var(--warning); }
.chip--none { background: var(--rail); color: var(--ink-2); }
.chip--important { background: var(--accent-wash); color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  background: var(--rail);
  color: var(--ink-2);
}
.badge svg { width: 12px; height: 12px; }
.badge--rev { background: var(--accent-wash); color: var(--accent); }
.badge--live { background: var(--success-wash); color: var(--success); }
.badge--draft { background: var(--warning-wash); color: var(--warning); }

/* The one place raw venue brand colour appears. Decorative, never the only cue. */
.venue-dot {
  display: inline-block;
  width: 0.5rem; height: 0.5rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  flex: none;
  margin-right: 0.375rem;
  vertical-align: 0;
}

.dot {
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.4;
  margin: 0 0.5rem;
  vertical-align: 3px;
}

/* ------------------------------------------------------------ empty/load */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
}
.empty svg { width: 24px; height: 24px; color: var(--ink-3); margin-bottom: 0.75rem; }
.empty h3 { font-size: 0.9375rem; font-weight: 600; }
.empty p { max-width: 70ch; margin-top: 0.25rem; font-size: 0.8125rem; color: var(--ink-2); }
.empty > *:last-child:not(p):not(h3):not(svg) { margin-top: 1rem; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 999px;
  opacity: 0.6;
  animation: spin 620ms linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-wrap { display: grid; place-items: center; padding: 4.5rem 0; color: var(--ink-3); }

.skeleton {
  background: linear-gradient(90deg, #efece4 0%, #f7f5f0 50%, #efece4 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position-x: -200%; } }

/* ------------------------------------------------------------------ toast */

.toast-rail {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + var(--safe-b));
  transform: translateX(-50%);
  display: grid;
  gap: 0.5rem;
  z-index: 90;
  width: min(100% - 1.5rem, 27rem);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-float);
  color: var(--ink);
  font-size: 0.875rem;
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 200ms var(--ease-out-expo), transform 200ms var(--ease-out-expo);
}
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.toast--ok svg { color: var(--success); }
.toast--bad svg { color: var(--danger); }
.toast[data-leaving='true'] { opacity: 0; transform: translateY(4px); }
@starting-style {
  .toast { opacity: 0; transform: translateY(8px); }
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: var(--danger-wash);
  border-radius: var(--radius-control);
  color: var(--danger);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.form-error svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }

/* -------------------------------------------------------- sheet / dialog */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 19, 0.32);
  z-index: 80;
  opacity: 1;
  transition: opacity 200ms var(--ease-out-expo);
}
.scrim[data-leaving='true'] { opacity: 0; }
@starting-style { .scrim { opacity: 0; } }

.sheet {
  position: fixed;
  z-index: 81;
  background: var(--panel);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 2.5rem);
  inset: auto 0 0 0;
  border-radius: 14px 14px 0 0;
  padding-bottom: var(--safe-b);
  transform: translateY(0);
  transition: transform 300ms var(--ease-drawer), opacity 200ms var(--ease-out-expo);
}
.sheet[data-leaving='true'] { transform: translateY(100%); }
@starting-style { .sheet { transform: translateY(100%); } }

.sheet-grab {
  width: 2.125rem; height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  margin: 0.5rem auto 0;
  flex: none;
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.125rem 0.75rem;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sheet-head h2 { font-size: 1rem; font-weight: 600; line-height: 1.4; }
.sheet-head p { font-size: 0.8125rem; color: var(--ink-2); margin-top: 0.125rem; }
/* Flex column rather than grid: a grid track sizes a child whose own overflow
   is not visible to nothing, which flattened panels and code blocks inside
   sheets. Flex children with flex:none always take their content height. */
.sheet-body {
  padding: 1.125rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sheet-body > * { flex: 0 0 auto; }
.sheet-foot {
  display: flex;
  gap: 0.5rem;
  padding: 0.875rem 1.125rem;
  border-top: 1px solid var(--line);
  flex: none;
  background: var(--panel);
}
.sheet-foot .btn { flex: 1; }

@media (min-width: 720px) {
  .sheet {
    inset: 50% auto auto 50%;
    width: min(100% - 3rem, 34rem);
    transform: translate(-50%, -50%) scale(1);
    border-radius: var(--radius-panel);
    max-height: min(84dvh, 48rem);
    transition: transform 200ms var(--ease-out-expo), opacity 180ms var(--ease-out-expo);
    opacity: 1;
  }
  .sheet[data-leaving='true'] { transform: translate(-50%, -50%) scale(0.98); opacity: 0; }
  @starting-style {
    .sheet { transform: translate(-50%, -50%) scale(0.98); opacity: 0; }
  }
  .sheet-grab { display: none; }
  .sheet--wide { width: min(100% - 3rem, 46rem); }
  .sheet-foot { justify-content: flex-end; }
  .sheet-foot .btn { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .sheet,
  .toast { transform: none !important; }
}
