/* CoachCertify translation review — tokens mirror frontend/src/app/globals.css */

:root {
  --background: #faf2e6;
  --card: #fefdfb;
  --muted: #f9f7f3;
  --foreground: #131519;
  --muted-foreground: #6b7280;
  --primary: #2c3a8c;
  --primary-soft: #eceffb;
  --border: #e6e3dc;
  --border-strong: #d8d3c8;

  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --warn: #9a6400;
  --warn-soft: #fdf3df;
  --danger: #b3261e;
  --danger-soft: #fbeae9;

  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-arabic: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Geeza Pro", "Segoe UI", sans-serif;

  --topbar-h: 3.5rem;
  --sidebar-w: 17rem;
  --ar-scale: 1;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0;
}

a {
  color: var(--primary);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--card);
  padding: 0.5rem 0.75rem;
  z-index: 100;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

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

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--primary);
  white-space: nowrap;
}

.topbar-sep {
  width: 1px;
  height: 1.1rem;
  background: var(--border-strong);
}

.topbar-title {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--card);
}

.sidebar-search {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-search input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  color: inherit;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.library {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem 1.5rem;
}

.library-group + .library-group {
  margin-top: 1rem;
}

.library-heading {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
  padding: 0 0.5rem 0.35rem;
}

.library-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: 0.86rem;
  color: inherit;
  cursor: pointer;
  line-height: 1.35;
}

.library-link:hover {
  background: var(--muted);
}

.library-link[aria-current="true"] {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

.library-link .library-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--muted-foreground);
  font-weight: 400;
  margin-top: 0.1rem;
}

.library-empty {
  padding: 0.5rem 0.6rem;
  font-size: 0.82rem;
  color: var(--muted-foreground);
}

.sidebar-foot {
  margin: 0;
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--muted-foreground);
}

.main {
  min-width: 0;
  padding: 1.5rem 1.5rem 5rem;
  max-width: 82rem;
}

/* ---------- controls bar ---------- */

.doc-header {
  margin-bottom: 1.25rem;
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
  margin: 0 0 0.35rem;
}

.doc-title {
  font-size: 1.75rem;
  line-height: 1.25;
}

.doc-title-ar {
  font-family: var(--font-arabic);
  font-size: 1.35rem;
  direction: rtl;
  color: var(--muted-foreground);
  margin-top: 0.3rem;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 500;
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}
.chip-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 22%, transparent);
}

.toolbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgb(19 21 25 / 4%);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.toolbar-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}

.toolbar-spacer {
  flex: 1;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.segmented button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: calc(var(--radius-sm) - 1px);
  cursor: pointer;
  color: var(--muted-foreground);
}

.segmented button[aria-pressed="true"] {
  background: var(--card);
  color: var(--primary);
  font-weight: 500;
  box-shadow: 0 1px 2px rgb(19 21 25 / 8%);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  color: var(--muted-foreground);
}

.switch input {
  accent-color: var(--primary);
  margin: 0;
}

.btn {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: inherit;
  cursor: pointer;
}

.btn:hover {
  background: var(--muted);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted-foreground);
}

.sidebar-toggle {
  display: none;
}

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 1px 2px rgb(19 21 25 / 4%);
  margin-bottom: 1.1rem;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
}

/* Collapsible cards use <details>/<summary>. */
summary.card-head {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

summary.card-head::-webkit-details-marker {
  display: none;
}

summary.card-head:hover {
  background: var(--primary-soft);
}

details.card:not([open]) > summary.card-head {
  border-bottom: 0;
}

.card-chevron {
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.15rem;
  border-right: 1.5px solid var(--muted-foreground);
  border-bottom: 1.5px solid var(--muted-foreground);
  transform: rotate(-45deg);
  transition: transform 0.15s ease-out;
}

details.card[open] > summary.card-head .card-chevron {
  transform: rotate(45deg);
}

.card-num {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  white-space: nowrap;
}

.card-head-title {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.card-head-flags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---------- field rows ---------- */

.field {
  border-top: 1px solid var(--border);
}

.field:first-child {
  border-top: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem 0;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-foreground);
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
  padding: 0.35rem 1rem 0.85rem;
}

.pane {
  min-width: 0;
}

.pane-en {
  padding-right: 1.5rem;
  border-right: 1px solid var(--border);
}

.pane-ar {
  direction: rtl;
  text-align: right;
  font-family: var(--font-arabic);
  font-size: calc(0.97rem * var(--ar-scale));
  line-height: 1.85;
}

.pane p {
  margin: 0 0 0.5rem;
}

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

.pane-missing {
  color: var(--danger);
  font-style: italic;
  font-size: 0.85rem;
}

/* single-language modes collapse the grid to one column */
body[data-view="en"] .pane-ar,
body[data-view="ar"] .pane-en {
  display: none;
}

body[data-view="en"] .field-pair,
body[data-view="ar"] .field-pair {
  grid-template-columns: minmax(0, 1fr);
}

body[data-view="en"] .pane-en {
  border-right: 0;
  padding-right: 0;
}

/* correct-answer emphasis */
.field-correct .field-label {
  color: var(--ok);
}

.field-correct .field-pair {
  background: color-mix(in srgb, var(--ok-soft) 55%, transparent);
}

.tag-correct {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 22%, transparent);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.flag {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  white-space: nowrap;
}

.flag-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
}

.flag-warn {
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
}

.flag-info {
  color: var(--muted-foreground);
  background: var(--muted);
  border: 1px solid var(--border-strong);
}

/* ---------- states ---------- */

.notice {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  max-width: 42rem;
}

.notice h2 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.notice code {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.35rem;
  font-size: 0.85em;
}

.notice pre {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  font-size: 0.82rem;
}

.empty-result {
  color: var(--muted-foreground);
  font-size: 0.9rem;
  padding: 1rem 0;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    width: min(20rem, 85vw);
    z-index: 45;
    box-shadow: 0 8px 30px rgb(19 21 25 / 12%);
  }

  body.sidebar-open .sidebar {
    display: flex;
  }

  .sidebar-toggle {
    display: inline-block;
  }

  .main {
    padding: 1rem 1rem 4rem;
  }

  .field-pair {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
  }

  .pane-en {
    border-right: 0;
    padding-right: 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
  }

  .toolbar {
    position: static;
  }
}

/* ---------- print ---------- */

@media print {
  :root {
    --background: #fff;
    --card: #fff;
  }

  .topbar,
  .sidebar,
  .toolbar,
  .skip-link {
    display: none !important;
  }

  body {
    font-size: 10.5pt;
  }

  .main {
    padding: 0;
    max-width: none;
  }

  .card {
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
    border-color: #ccc;
  }
}
