/* styles.css — FreeLaw static document library
   Goal:
   - Dark header/cards/controls with WHITE text
   - Light page background (behind cards, below header)
   - Any text that sits directly on the page background uses --page-text / --page-muted
   Quick test knobs:
   - --page-bg-start / --page-bg-end
   - --page-text / --page-muted
*/

:root{
  /* Page background + on-background text (solid) */
  --page-bg-start: #658bc7;
  --page-bg-end: #7e99c4;

  --page-text: #000000;     /* black-ish */
  --page-muted: #ffffff;    /* gray */
  --page-border: #d0d7e2;   /* light gray border */

  /* Dark UI surfaces (cards/header/inputs) + on-surface text (solid) */
  --bg: #071225;

  --panel: #0e1a35;         /* solid replacement for rgba panel */
  --panel-2: #132442;       /* solid replacement for rgba panel-2 */

  --text: #ffffff;          /* white */
  --muted: #b9c7dd;         /* muted blue-gray */

  --border: #2b3d62;        /* solid border on dark surfaces */

  --accent: #4ea1ff;
  --accent-2: #7bd3ff;

  --danger: #ff6a6a;

  --radius: 14px;
  --radius-sm: 10px;

  --container: 1160px;
  --gap: 16px;

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.5;

  /* IMPORTANT:
     Default text is for content that sits directly on the light page background. */
  color: var(--page-text);
  background: linear-gradient(180deg, var(--page-bg-start) 0%, var(--page-bg-end) 100%);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(var(--container), calc(100% - 32px));
  margin: 0 auto;
}

/* Visually hidden but still accessible */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ===== Header (dark surface, white text) ===== */
.site-header {
  padding: 34px 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);

  /* Dark, not "very dark" */
  background:
    radial-gradient(900px 260px at 12% 0%, rgba(78, 161, 255, 0.22), transparent 62%),
    linear-gradient(180deg, rgba(16, 32, 64, 0.95), rgba(12, 22, 44, 0.88));

  backdrop-filter: blur(6px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.20);

  color: var(--text);
}

.site-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.2px;
  color: var(--text);
}

.site-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

/* ===== Controls ===== */
.controls {
  margin: 22px 0 14px;
  display: grid;
  grid-template-columns: 1fr; /* search row + category row */
  gap: var(--gap);
}

/* Field label sits directly on page background -> use page-muted (black-ish) */
.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 13px;
  color: var(--page-muted);
}

/* Inputs are UI surfaces -> dark with white text */
input[type="search"],
select {
  width: 100%;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.20);

  background: linear-gradient(180deg, rgba(16, 28, 52, 0.70), rgba(12, 22, 44, 0.62));
  color: var(--text);

  outline: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.10);
}

input[type="search"]::placeholder {
  color: rgba(255, 255, 255, 0.60);
}

input[type="search"]:focus,
select:focus {
  border-color: rgba(78, 161, 255, 0.60);
  box-shadow: 0 0 0 3px rgba(78, 161, 255, 0.18);
}

/* ===== Category chips menu ===== */
.category-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 2px;
}

/* Chips are UI surfaces -> dark with white text */
.category-menu button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(16, 28, 52, 0.55);
  color: rgba(255, 255, 255, 0.90);

  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;

  font-weight: 650;
  font-size: 13px;
  letter-spacing: 0.1px;
}

.category-menu button:hover {
  background: rgba(16, 28, 52, 0.68);
}

.category-menu button.is-active {
  border-color: rgba(78, 161, 255, 0.65);
  background: rgba(78, 161, 255, 0.22);
  color: rgba(255, 255, 255, 0.96);
}

/* ===== Cards (3-column grid) ===== */
.doc-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding-bottom: 60px;
}

@media (max-width: 1100px) {
  .doc-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .doc-list {
    grid-template-columns: 1fr;
  }
}

.doc-card {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(800px 260px at 15% 0%, rgba(78, 161, 255, 0.10), transparent 60%),
    linear-gradient(180deg, rgba(20, 36, 66, 0.88), rgba(16, 28, 52, 0.82));

  border-radius: var(--radius);
  padding: 16px 16px;

  /* Strong contrast against light page background */
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.05) inset;

  display: flex;
  flex-direction: column;
  min-height: 220px;

  color: var(--text);
}

.doc-card:hover {
  border-color: rgba(78, 161, 255, 0.42);
  box-shadow:
    0 22px 58px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(78, 161, 255, 0.10) inset;
}

.doc-title {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--text);
}

.doc-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.doc-desc {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.86);
}

.doc-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
}

/* Empty state sits on page background -> light panel with black text */
.empty {
  border: 1px dashed var(--page-border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--page-muted);
  background: rgba(255, 255, 255, 0.65);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  padding: 10px 12px;
  border-radius: var(--radius-sm);

  border: 1px solid rgba(78, 161, 255, 0.40);
  background: rgba(78, 161, 255, 0.16);

  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  user-select: none;
}

.btn:hover {
  background: rgba(78, 161, 255, 0.22);
  text-decoration: none;
}

.btn.secondary {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.09);
}

.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.13);
}

.is-disabled,
.btn[disabled],
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== Notice (dark surface, white text) ===== */
.notice {
  margin: 16px 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, rgba(20, 36, 66, 0.78), rgba(16, 28, 52, 0.72));
  border-radius: var(--radius);
  padding: 12px 12px;
  color: var(--muted);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 50;
}

.modal {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);

  width: min(720px, calc(100% - 32px));
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.16);

  background:
    radial-gradient(900px 260px at 12% 0%, rgba(78, 161, 255, 0.14), transparent 62%),
    linear-gradient(180deg, rgba(20, 36, 66, 0.96), rgba(14, 26, 50, 0.92));

  box-shadow: var(--shadow);
  color: var(--text);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.modal-title {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.modal-close {
  width: 40px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.11);
}

.modal-body {
  padding: 14px 14px 16px;
}

.modal-description {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.88);
}

.modal-ack {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  padding: 12px 12px;
  margin-bottom: 14px;
}

.checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 14px;
}

.checkbox input {
  margin-top: 3px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .modal-actions {
    grid-template-columns: 1fr;
  }
}

.modal-note {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* Prevent background scroll when modal open */
body.modal-open {
  overflow: hidden;
}