/* ============================================================================
   SALZ Connect — base.css
   Design tokens, RTL bootstrap, font loading, minimal reset.
   ============================================================================ */

/* ---------- Font Faces (Hebrew + Latin subsets) -------------------------- */

/* Heebo — default UI font + contract default */
@font-face {
  font-family: "Heebo";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Heebo-400.woff2") format("woff2");
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: "Heebo";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Heebo-Latin-400.woff2") format("woff2");
  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: "Heebo";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/Heebo-500.woff2") format("woff2");
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: "Heebo";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/Heebo-Latin-500.woff2") format("woff2");
  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: "Heebo";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/Heebo-700.woff2") format("woff2");
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: "Heebo";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/Heebo-Latin-700.woff2") format("woff2");
  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;
}

/* David Libre — formal, classical Hebrew serif */
@font-face {
  font-family: "David Libre";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/DavidLibre-400.woff2") format("woff2");
}
@font-face {
  font-family: "David Libre";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/DavidLibre-700.woff2") format("woff2");
}

/* Frank Ruhl Libre — refined editorial Hebrew serif */
@font-face {
  font-family: "Frank Ruhl Libre";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/FrankRuhlLibre-400.woff2") format("woff2");
}
@font-face {
  font-family: "Frank Ruhl Libre";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/FrankRuhlLibre-700.woff2") format("woff2");
}

/* Assistant — modern Hebrew sans */
@font-face {
  font-family: "Assistant";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Assistant-400.woff2") format("woff2");
}
@font-face {
  font-family: "Assistant";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/Assistant-700.woff2") format("woff2");
}

/* Rubik — geometric Hebrew sans */
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Rubik-400.woff2") format("woff2");
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/Rubik-700.woff2") format("woff2");
}

/* ---------- Design Tokens ----------------------------------------------- */

:root {
  /* Color — paper-and-ink editorial palette with warm gold accent */
  --color-bg: oklch(99% 0 0);
  --color-surface: oklch(97% 0 0);
  --color-surface-hover: oklch(94% 0 0);
  --color-text: oklch(18% 0 0);
  --color-text-muted: oklch(45% 0 0);
  --color-border: oklch(90% 0 0);
  --color-border-strong: oklch(82% 0 0);
  --color-primary: oklch(35% 0.05 250);
  --color-primary-hover: oklch(28% 0.05 250);
  --color-accent: oklch(60% 0.15 50);
  --color-accent-hover: oklch(54% 0.15 50);
  --color-success: oklch(60% 0.15 150);
  --color-error: oklch(55% 0.20 25);
  --color-info: oklch(55% 0.10 240);

  /* Hex fallbacks for browsers without oklch */
  --color-bg-fallback: #fefdfb;
  --color-surface-fallback: #f7f5f0;
  --color-text-fallback: #1a1a1a;
  --color-text-muted-fallback: #6b6b6b;
  --color-border-fallback: #e0ddd5;
  --color-primary-fallback: #2d3748;
  --color-accent-fallback: #c47b3a;
  --color-success-fallback: #3a8a5c;
  --color-error-fallback: #b84545;
  --color-info-fallback: #4a6fa5;

  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);

  /* Animation */
  --duration-fast: 120ms;
  --duration-normal: 220ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Contract typography defaults — overridden inline per contract */
  --contract-font: "Heebo", system-ui, sans-serif;
  --contract-size: 11pt;
  --contract-line: 1.6;
  --contract-align: right;
}

/* ---------- Reset ------------------------------------------------------- */

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

html,
body {
  margin: 0;
  padding: 0;
}

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

body {
  font-family: "Heebo", system-ui, "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  direction: rtl;
  background: var(--color-bg-fallback);
  background: var(--color-bg);
  color: var(--color-text-fallback);
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

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

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

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

table {
  border-collapse: collapse;
  width: 100%;
}

ul,
ol {
  margin: 0;
  padding-inline-start: 1.5em;
}

/* ---------- Typography Defaults ----------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-md) 0;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
}

h3 {
  font-size: 1.25rem;
}

p {
  margin: 0 0 var(--space-md) 0;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--color-info-fallback);
  color: var(--color-info);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-fast) var(--ease-out);
}

a:hover {
  border-bottom-color: currentColor;
}

small {
  font-size: 0.875em;
  color: var(--color-text-muted-fallback);
  color: var(--color-text-muted);
}

code,
kbd,
samp {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* ---------- Focus Styles ----------------------------------------------- */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-accent-fallback);
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Utility Classes -------------------------------------------- */

.no-print {
  /* visible on screen, hidden in print (handled in print.css) */
}

.print-only {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--color-text-muted-fallback);
  color: var(--color-text-muted);
}

/* ---------- Draft Watermark -------------------------------------------- */

.draft-watermark {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
  user-select: none;
  -webkit-user-select: none;
}

.draft-watermark::before {
  content: "טיוטה — לא חתום";
  font-family: "Heebo", system-ui, sans-serif;
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 700;
  color: #1a1a1a;
  opacity: 0.08;
  transform: rotate(-30deg);
  white-space: nowrap;
  letter-spacing: 0.05em;
}

/* Hide watermark for non-draft documents on screen */
body[data-status="signed"] .draft-watermark,
body[data-status="archived"] .draft-watermark {
  display: none;
}

/* ---------- Selection -------------------------------------------------- */

::selection {
  background: var(--color-accent-fallback);
  background: var(--color-accent);
  color: #fff;
}

/* ---------- Scrollbar (subtle) ----------------------------------------- */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-fallback);
  background: var(--color-border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted-fallback);
  background: var(--color-text-muted);
}
