/* =========================================================
   Nourvia design system
   Shared by every page. Page files keep only their own
   layout rules and build on the tokens defined here.
   ========================================================= */

/* ---------- 0. Fonts (bundled in /fonts, no internet needed) ---------- */
@font-face {
  font-family: "Lora";
  src: url("fonts/Lora-Variable.woff") format("woff");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/Lora-Italic-Variable.woff") format("woff");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

/* ---------- 1. Tokens ---------- */
:root {
  /* Surfaces */
  --ivory: #F6F2E9;          /* page canvas */
  --paper: #FFFDF8;          /* cards and panels */
  --paper-2: #FAF7F0;        /* inset areas inside cards */
  --line: #E4DDCF;           /* borders and dividers */
  --line-strong: #D3CAB8;

  /* Greens */
  --forest: #17322A;         /* sidebar */
  --forest-2: #21423A;       /* sidebar hover */
  --ink: #1D2B26;            /* main text */
  --muted: #5A6760;          /* secondary text */
  --sage: #3F6B58;           /* actions, links */
  --sage-deep: #2F5546;      /* action hover */
  --sage-soft: #8FAE97;      /* decorative accent */
  --sage-mist: #E6EDE3;      /* tinted backgrounds */
  --sage-wash: #F0F4EE;

  /* Status */
  --success: #2F6B4A;
  --success-mist: #E2EFE6;
  --honey: #7F5713;
  --honey-mist: #F6EBD6;
  --info: #3F5A8A;
  --info-mist: #E7ECF5;
  --danger: #A1503D;
  --danger-mist: #F6E6E0;

  /* Type */
  --font-display: "Lora", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Shape and depth */
  --radius-lg: 20px;         /* panels */
  --radius-md: 14px;         /* items inside panels */
  --radius-sm: 10px;         /* controls */
  --shadow-sm: 0 1px 2px rgba(23, 50, 42, 0.05);
  --shadow-md: 0 1px 2px rgba(23, 50, 42, 0.04), 0 10px 28px -14px rgba(23, 50, 42, 0.18);
  --shadow-lg: 0 2px 4px rgba(23, 50, 42, 0.05), 0 24px 48px -20px rgba(23, 50, 42, 0.28);
  --ring: 0 0 0 3px rgba(63, 107, 88, 0.22);

  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Older names used inside page files, pointed at the new palette */
  --cream: var(--ivory);
  --border: var(--line);

  /* Text scale; client-preferences.js sets data-text-size on <html> */
  --text-scale: 1;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

/* Larger text (client setting). Font sizes are in rem, so they all
   follow this, on top of the browser's own default text size. */
html[data-text-size="large"] {
  --text-scale: 1.125;
  font-size: 112.5%;
}

body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { color: var(--ink); margin-top: 0; }

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.875rem, calc(3.2vw * var(--text-scale)), 2.625rem);
  line-height: 1.12;
  letter-spacing: -0.012em;
  margin: 6px 0 8px;
}

h2 {
  font-family: var(--font-display);
  font-weight: 450;
  font-size: 1.4375rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 0 0 14px;
}

h3 {
  font-family: var(--font-ui);
  font-weight: 650;
  font-size: 0.96875rem;
  line-height: 1.35;
  margin: 0 0 6px;
}

p { margin: 0 0 12px; }

a {
  color: var(--sage);
  text-decoration-color: rgba(63, 107, 88, 0.35);
  text-underline-offset: 3px;
  transition: color .15s var(--ease), text-decoration-color .15s var(--ease);
}
a:hover { color: var(--sage-deep); text-decoration-color: currentColor; }

strong { font-weight: 650; }

.muted, .subtitle { color: var(--muted); }
.subtitle { line-height: 1.6; }

.hidden { display: none !important; }

::selection { background: var(--sage-mist); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- 3. App shell ---------- */
.layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

aside {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  width: 252px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 16px 24px;
  background-color: var(--forest);
  color: #E9EFE9;
  overflow-y: auto;
  /* Signature: faint contour lines at the foot of the sidebar */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='300' viewBox='0 0 260 300' fill='none' stroke='%23ffffff' stroke-opacity='0.07' stroke-width='1.2'%3E%3Cpath d='M-20 250c40-34 78-40 118-22s74 22 112-6 64-20 70-12'/%3E%3Cpath d='M-20 222c44-38 86-44 124-26s70 20 106-10 66-22 74-12'/%3E%3Cpath d='M-20 194c48-42 92-48 128-30s66 16 100-14 70-24 78-12'/%3E%3Cpath d='M-20 166c52-44 96-50 132-34s62 12 94-18 74-26 82-12'/%3E%3Cpath d='M-20 138c56-46 100-52 136-38s58 8 88-22 78-28 86-12'/%3E%3Cpath d='M-20 278c38-28 72-32 110-16s78 24 118-2 62-16 66-10'/%3E%3Cellipse cx='176' cy='262' rx='34' ry='14'/%3E%3Cellipse cx='176' cy='262' rx='18' ry='7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% auto;
}

.logo {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.9375rem;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #F6F2E9;
  padding: 2px 12px 0;
  margin: 0 0 34px;
}

aside nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

aside nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(233, 239, 233, 0.74);
  text-decoration: none;
  font-size: 0.90625rem;
  font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease);
}

aside nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  opacity: 0.85;
}

aside nav a:hover {
  background: var(--forest-2);
  color: #FFFFFF;
}

aside nav a.active {
  background: rgba(246, 242, 233, 0.11);
  color: #FFFFFF;
  box-shadow: inset 2px 0 0 var(--sage-soft);
}

aside nav a.nav-exit {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(233, 239, 233, 0.1);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 0.84375rem;
  color: rgba(233, 239, 233, 0.55);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: rgba(233, 239, 233, 0.5);
}

.sidebar-footer strong {
  display: block;
  font-weight: 600;
  color: rgba(233, 239, 233, 0.82);
  margin-bottom: 2px;
}

main {
  flex: 1;
  min-width: 0;
  padding: 40px clamp(20px, 4vw, 56px) 64px;
  max-width: 1360px;
  animation: nv-enter .45s var(--ease) both;
}

@keyframes nv-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Page header pattern: a context line, a title, a short description */
.page-context {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--muted);
  margin: 0 0 4px;
}

.demo-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--honey-mist);
  color: var(--honey);
  font-size: 0.71875rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

/* ---------- 4. Surfaces ---------- */
.panel, .card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.panel > h2:first-child,
.card > h2:first-child { margin-top: 0; }

.inset {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

/* ---------- 5. Buttons ---------- */
button, .button, .btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--sage);
  color: #FFFFFF;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, var(--shadow-sm);
  transition: background .16s var(--ease), border-color .16s var(--ease),
              color .16s var(--ease), transform .16s var(--ease), box-shadow .16s var(--ease);
}

button:hover, .button:hover, .btn:hover {
  background: var(--sage-deep);
  color: #FFFFFF;
}

button:active, .button:active, .btn:active { transform: translateY(1px); }

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

button.secondary, .button.secondary, .btn.secondary, .secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

button.secondary:hover, .button.secondary:hover, .btn.secondary:hover {
  background: var(--sage-wash);
  border-color: var(--sage-soft);
  color: var(--ink);
}

button.danger, .button.danger {
  background: var(--paper);
  color: var(--danger);
  border-color: #E3C3B8;
}
button.danger:hover, .button.danger:hover { background: var(--danger-mist); color: var(--danger); }

button.ghost {
  background: transparent;
  color: var(--sage);
  border-color: transparent;
  box-shadow: none;
}
button.ghost:hover { background: var(--sage-wash); color: var(--sage-deep); }

/* ---------- 6. Forms ---------- */
label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.90625rem;
  line-height: 1.4;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}

textarea { min-height: 110px; resize: vertical; line-height: 1.55; }

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2366746C' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

input::placeholder, textarea::placeholder { color: #9AA39D; }

input:not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover { border-color: var(--sage-soft); }

/* Checkboxes and radios keep the :focus-visible outline: Safari doesn't
   draw a box-shadow ring on them, so keyboard focus would be invisible. */
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: var(--ring);
}

/* Stacked forms: space before each new label that follows a field */
input + label, select + label, textarea + label,
input + .field, select + .field, textarea + .field { margin-top: 16px; }
form > button[type="submit"], form > .button { margin-top: 18px; }

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--sage);
  width: 17px;
  height: 17px;
  cursor: pointer;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 0 0 16px;
}
legend { font-weight: 600; padding: 0 6px; }

/* ---------- 7. Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th {
  text-align: left;
  font-size: 0.78125rem;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s var(--ease); }
tbody tr:hover { background: var(--sage-wash); }

/* ---------- 8. Small parts ---------- */
.pill, .badge, .status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--sage-mist);
  color: var(--sage-deep);
  font-size: 0.78125rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

/* Intake form statuses, e.g. <span class="badge intake-status completed"> */
.intake-status.not-started { background: var(--paper-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.intake-status.in-progress,
.intake-status.pending { background: var(--honey-mist); color: var(--honey); }
.intake-status.completed,
.intake-status.reviewed { background: var(--success-mist); color: var(--success); }
.intake-status.cancelled { background: var(--danger-mist); color: var(--danger); }
.intake-status.paused { background: var(--info-mist); color: var(--info); }

.notice, .warning {
  color: var(--muted);
  font-size: 0.78125rem;
}

.empty-state {
  padding: 22px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-2);
}

.number {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2.5rem;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums tabular-nums;
}

/* Fictional-data reminder that sits at the end of app pages */
.demo-footnote {
  margin-top: 32px;
  font-size: 0.78125rem;
  color: var(--muted);
}

/* Line icons placed inside icon containers */
.nv-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  vertical-align: middle;
}
.nv-icon-lg { width: 28px; height: 28px; color: var(--sage); }

/* Stacked panels directly inside a page get even spacing */
main > .panel + .panel,
main > .card + .card,
main > section + section,
main > .panel + section,
main > section + .panel { margin-top: 22px; }
main > h1 + .subtitle, main > h1 + p { margin-bottom: 24px; }

/* ---------- Clinical assessment review (Intake Forms, Results) ---------- */
.kind-badge { background: var(--info-mist); color: var(--info); }
.safety-badge { background: var(--danger-mist); color: var(--danger); }
.followup-badge { background: var(--sage-mist); color: var(--sage-deep); }
.safety-alert {
  margin: 16px 0 4px;
  padding: 16px 18px;
  border: 1px solid #E3C3B8;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--danger-mist);
}
.safety-alert strong { display: block; margin-bottom: 6px; color: var(--danger); }
.safety-alert p { margin: 0 0 6px; line-height: 1.55; }
.safety-alert.followed-up { border-color: var(--line); border-left-color: var(--sage); background: var(--sage-wash); }
.safety-alert.followed-up strong { color: var(--sage-deep); }
.safety-detail { color: var(--ink); font-size: 0.84375rem; }
.safety-demo-note { font-size: 0.8125rem; font-style: italic; color: var(--ink); }
.follow-up-form { display: grid; gap: 8px; margin-top: 10px; }
.follow-up-form label { margin: 0; }
.follow-up-form button { justify-self: start; }
.scoring-note {
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.84375rem;
}

/* ---------- 9. Responsive ---------- */
@media (max-width: 860px) {
  .layout { display: block; }

  aside {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background-image: none;
    overflow: visible;
    box-shadow: 0 6px 18px -10px rgba(23, 50, 42, 0.5);
  }

  .logo { font-size: 1.5625rem; margin: 0; padding: 0; flex-shrink: 0; }

  aside nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
            mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  aside nav::-webkit-scrollbar { display: none; }

  aside nav a {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.84375rem;
    gap: 8px;
  }
  aside nav a svg { width: 16px; height: 16px; }
  aside nav a.active { box-shadow: inset 0 -2px 0 var(--sage-soft); }
  aside nav a.nav-exit { margin: 0; padding-top: 8px; border-top: 0; border-radius: var(--radius-sm); }

  .sidebar-footer { display: none; }

  main { padding: 26px 16px 48px; }

  .panel, .card { padding: 18px; border-radius: 16px; }
}

/* ---------- 10. Motion preferences ---------- */
/* The operating system setting, and the client's "Reduce animations"
   setting (data-reduce-motion on <html>), get the same treatment. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  button:active, .button:active, .btn:active { transform: none; }
}

html[data-reduce-motion="true"] *,
html[data-reduce-motion="true"] *::before,
html[data-reduce-motion="true"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
html[data-reduce-motion="true"] :is(button, .button, .btn):active { transform: none; }
