/* ==========================================================================
   Witzzart refinement layer
   Loaded LAST (after Generic.css / witzzart-premium.css). One place for:
   brand tokens, typography, buttons, forms, cards, tables, modals, motion,
   and mobile-safety rules shared by every page.
   ========================================================================== */

/* ---------- 1. Brand tokens (single source of truth) ----------------------
   The logo and Generic.css use #ff3131. witzzart-premium.css had overridden
   --color-brand with a rose tone, so header/footer/buttons disagreed with
   hard-coded reds elsewhere. Re-assert the real brand red here. */
:root {
  --color-brand: #ff3131;
  --wtz-accent: #ff3131;
  --brand-600: #e11d1d;           /* hover / pressed */
  --brand-700: #c21414;
  --brand-100: #ffe3e3;
  --brand-50:  #fff4f4;
  --wtz-ink: #1f1f24;
  --wtz-muted: #6b6b76;
  --wtz-canvas: #f8f6f2;
  --wtz-paper: #ffffff;
  --wtz-line: #ebe6df;
  --color-text-primary: var(--wtz-ink);
  --color-text-secondary: var(--wtz-muted);
  --color-bg-gray: var(--wtz-canvas);
  --color-border: var(--wtz-line);

  --success: #1f8a5b;
  --warning: #b7791f;
  --info: #2b6cb0;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-card: 18px;
  --radius-pill: 999px;
  --radius-btn: 999px;

  --shadow-xs: 0 1px 2px rgba(31, 31, 36, .06);
  --shadow-sm: 0 2px 8px rgba(31, 31, 36, .07);
  --shadow-md: 0 10px 28px rgba(31, 31, 36, .10);
  --shadow-lg: 0 18px 44px rgba(31, 31, 36, .16);
  --shadow-brand: 0 8px 22px rgba(255, 49, 49, .28);

  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: .2s;
  --header-offset: 76px;
}

/* ---------- 2. Base ------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--header-offset); }
body {
  background: var(--wtz-canvas) !important;
  color: var(--wtz-ink);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: rgba(255, 49, 49, .12);
}
::selection { background: var(--brand-100); color: var(--brand-700); }
a { text-underline-offset: 3px; }
a:not(.btn):hover { color: var(--brand-600); }
img, video, canvas, iframe { max-width: 100%; }
img { height: auto; }
img[loading="lazy"] { background: linear-gradient(110deg, #efeae3 8%, #f7f3ee 18%, #efeae3 33%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) {
  img[loading="lazy"]:not([data-wtz-loaded]) { animation: wtz-shimmer 1.4s linear infinite; }
}
@keyframes wtz-shimmer { to { background-position-x: -200%; } }
img[data-wtz-loaded] { animation: none; background: none; }

/* ---------- 3. Typography ------------------------------------------------ */
h1, h2, h3, h4, h5, h6 { color: var(--wtz-ink); letter-spacing: -.012em; font-weight: 700; text-wrap: balance; overflow-wrap: break-word; }
h1, .h1 { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.75rem); line-height: 1.12; }
h2, .h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem);  line-height: 1.18; }
h3, .h3 { font-size: clamp(1.25rem, 1.05rem + .9vw, 1.6rem); line-height: 1.25; }
h4, .h4 { font-size: clamp(1.1rem, 1rem + .5vw, 1.3rem); }
p, li { overflow-wrap: break-word; }
.text-muted, .text-secondary { color: var(--wtz-muted) !important; }
.lead { font-size: clamp(1.02rem, .95rem + .35vw, 1.2rem); color: var(--wtz-muted); font-weight: 400 !important; }

/* ---------- 4. Layout safety -------------------------------------------- */
body { overflow-x: clip; }
:where(.container, .container-fluid, .row, [class*="col-"]) { min-width: 0; }
.content { min-height: 60vh; }
@media (max-width: 767.98px) {
  :where(.container, .container-fluid) { padding-left: 16px; padding-right: 16px; }
  :where(.row) { --bs-gutter-x: 1rem; }
}
/* notches / home indicator */
.fixed-bottom, .sticky-bottom, [class*="bottom-bar"], [class*="sticky-footer"] { padding-bottom: env(safe-area-inset-bottom); }

/* ---------- 5. Focus & motion ------------------------------------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--color-brand);
  outline-offset: 2px;
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- 6. Buttons --------------------------------------------------- */
.btn {
  border-radius: var(--radius-btn);
  font-weight: 600;
  letter-spacing: .005em;
  min-height: 44px;
  padding-inline: 1.35rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn-sm { min-height: 36px; padding-inline: 1rem; }
.btn-lg { min-height: 52px; padding-inline: 1.9rem; }
.btn-primary, .btn-danger {
  background-color: var(--color-brand); border-color: var(--color-brand); color: #fff;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active,
.btn-danger:hover, .btn-danger:focus, .btn-danger:active {
  background-color: var(--brand-600) !important; border-color: var(--brand-600) !important; color: #fff;
}
.btn-outline-primary, .btn-outline-danger { color: var(--color-brand); border-color: var(--color-brand); background: transparent; }
.btn-outline-primary:hover, .btn-outline-danger:hover { background: var(--color-brand); border-color: var(--color-brand); color: #fff; }
.btn-light, .btn-outline-secondary, .btn-outline-dark { border-color: var(--wtz-line); }
@media (hover: hover) {
  .btn:not(:disabled):not(.disabled):hover { transform: translateY(-1px); }
  .btn-primary:not(:disabled):hover, .btn-danger:not(:disabled):hover { box-shadow: var(--shadow-brand); }
}
.btn:not(:disabled):not(.disabled):active { transform: scale(.98); }
.btn:disabled, .btn.disabled { opacity: .55; }
.btn.is-loading, button.is-loading { position: relative; pointer-events: none; opacity: .85; }
.btn.is-loading::after, button.is-loading::after {
  content: ""; width: 1em; height: 1em; margin-left: .55rem; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: wtz-spin .7s linear infinite; display: inline-block;
}
@keyframes wtz-spin { to { transform: rotate(360deg); } }
@media (max-width: 575.98px) {
  .btn-block-mobile, .wtz-actions-stack .btn { width: 100%; }
}

/* ---------- 7. Forms ----------------------------------------------------- */
.form-label { font-weight: 600; font-size: .875rem; color: var(--wtz-ink); margin-bottom: .35rem; text-transform: none !important; letter-spacing: 0 !important; padding-left: 0 !important; }
.form-control, .form-select, textarea.form-control {
  min-height: 46px;
  border: 1.5px solid #ddd6cc;
  border-radius: var(--radius-sm);
  background-color: #fff;
  color: var(--wtz-ink);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea.form-control { min-height: 110px; border-radius: var(--radius-sm) !important; }
.form-control::placeholder { color: #a39d94; }
.form-control:hover, .form-select:hover { border-color: #c9c1b5; }
.form-control:focus, .form-select:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 4px rgba(255, 49, 49, .14);
  outline: none;
}
.form-control.is-invalid, .input-validation-error { border-color: #d92d20; }
.field-validation-error, .invalid-feedback { color: #d92d20; font-size: .8125rem; margin-top: .3rem; }
.form-check-input:checked { background-color: var(--color-brand); border-color: var(--color-brand); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(255, 49, 49, .14); border-color: var(--color-brand); }
.input-group > .form-control:not(:last-child), .input-group > .form-select:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
@media (max-width: 767.98px) {
  /* 16px stops iOS Safari zooming into focused fields */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea, .form-control, .form-select { font-size: 16px !important; }
}

/* ---------- 8. Cards, badges, alerts ------------------------------------ */
.card {
  border: 1px solid var(--wtz-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-xs);
  background: var(--wtz-paper);
}
.card.card-hover, a.card, .wtz-card-link { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
@media (hover: hover) { .card.card-hover:hover, a.card:hover, .wtz-card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); } }
.card-header, .card-footer { background: transparent; border-color: var(--wtz-line); }
.badge { border-radius: var(--radius-pill); font-weight: 600; letter-spacing: .02em; padding: .4em .75em; }
.alert { border-radius: var(--radius-sm); border-width: 1px; }
.alert-success { background: #ecf8f2; border-color: #bfe6d3; color: #14603f; }
.alert-danger  { background: var(--brand-50); border-color: #ffc9c9; color: #a11212; }
.alert-warning { background: #fff8e8; border-color: #f4dba6; color: #7a4f06; }
.alert-info    { background: #eef5fc; border-color: #c4dbf2; color: #1f4f7f; }

/* ---------- 9. Tables ---------------------------------------------------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead > tr > th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  color: var(--wtz-muted); background: #faf8f4; border-bottom: 1px solid var(--wtz-line); white-space: nowrap;
}
.table > :not(caption) > * > * { padding: .85rem 1rem; }
.table > tbody > tr > td { vertical-align: middle; border-color: var(--wtz-line); }
.table-hover > tbody > tr:hover > * { background: var(--brand-50); }
.wtz-table-wrap, .table-responsive {
  overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
  border: 1px solid var(--wtz-line); border-radius: var(--radius-card); background: #fff;
}
.wtz-table-wrap > .table, .table-responsive > .table { margin: 0; }
.wtz-table-wrap::-webkit-scrollbar, .table-responsive::-webkit-scrollbar { height: 8px; }
.wtz-table-wrap::-webkit-scrollbar-thumb, .table-responsive::-webkit-scrollbar-thumb { background: #d6cfc4; border-radius: 8px; }

/* ---------- 10. Modals, dropdowns, toasts ------------------------------- */
.modal-content { border: 0; border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { border-bottom-color: var(--wtz-line); }
.modal-footer { border-top-color: var(--wtz-line); }
.modal-backdrop.show { opacity: .55; }
.dropdown-menu {
  border: 1px solid var(--wtz-line); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-width: calc(100vw - 1rem); padding: .4rem;
}
.dropdown-item { border-radius: 8px; padding: .55rem .8rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--brand-50); color: var(--brand-700); }
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-fullscreen) { margin: .5rem; }
  .modal-content { max-height: calc(100dvh - 1rem); }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
}

/* ---------- 11. Pagination / tabs / nav pills ---------------------------- */
.page-link { border-radius: 10px !important; margin: 0 2px; color: var(--wtz-ink); border-color: var(--wtz-line); min-width: 40px; text-align: center; }
.page-item.active .page-link { background: var(--color-brand); border-color: var(--color-brand); color: #fff; }
.nav-pills .nav-link { border-radius: var(--radius-pill); font-weight: 600; }
.nav-pills .nav-link { color: var(--wtz-ink); border: 1px solid transparent; }
.nav-pills .nav-link:hover { background: var(--brand-50); color: var(--brand-700); }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { background: var(--color-brand) !important; border-color: var(--color-brand) !important; color: #fff !important; }
.nav-tabs { border-bottom-color: var(--wtz-line); }
.nav-tabs .nav-link.active { border-bottom-color: var(--color-brand); color: var(--brand-700); }
.nav-tabs:not(.flex-column), .nav-pills:not(.flex-column) { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav-tabs:not(.flex-column)::-webkit-scrollbar, .nav-pills:not(.flex-column)::-webkit-scrollbar { display: none; }
.nav-tabs .nav-link, .nav-pills .nav-link { white-space: nowrap; }

/* ---------- 12. Empty states / helpers ---------------------------------- */
.wtz-empty { text-align: center; padding: 3rem 1.25rem; color: var(--wtz-muted); }
.wtz-empty i { font-size: 2.4rem; color: var(--brand-100); display: block; margin-bottom: .75rem; }
.wtz-section { padding-block: clamp(2rem, 1.2rem + 3vw, 4rem); }
.wtz-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wtz-hide-scrollbar { scrollbar-width: none; }
.wtz-hide-scrollbar::-webkit-scrollbar { display: none; }

/* ---------- 13. Touch ergonomics (phones/tablets) ------------------------ */
@media (pointer: coarse) {
  .btn, .form-control, .form-select, .dropdown-item, .page-link, .nav-link { min-height: 44px; }
  .form-check-input { width: 1.25em; height: 1.25em; }
}

/* ---------- 14. Footer breathing room on phones -------------------------- */
@media (max-width: 575.98px) {
  footer, .wtz-footer { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}

/* ---------- 15. Print ---------------------------------------------------- */
@media print {
  header, footer, .wtz-skip-link, #siteHeader, .modal, .btn { display: none !important; }
  body { background: #fff !important; }
}
