/* Finducation policy & legal document layout (screen + print) */
@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root,
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-gradient-a: rgba(37, 99, 235, 0.08);
  --bg-gradient-b: rgba(14, 165, 233, 0.06);
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-muted: #475569;
  --heading-accent: #1e40af;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --border: rgba(148, 163, 184, 0.45);
  --table-head-bg: rgba(219, 234, 254, 0.85);
  --btn-bg: rgba(255, 255, 255, 0.95);
  --btn-border: rgba(37, 99, 235, 0.35);
  --btn-color: #1e40af;
  --note-bg: #eff6ff;
  --note-border: #2563eb;
  --note-text: #1e3a8a;
  --pill-bg: #eff6ff;
  --pill-border: #93c5fd;
  --pill-text: #1e3a8a;
  --link: #2563eb;
}

[data-theme="dark"] {
  --bg-primary: #020617;
  --bg-gradient-a: rgba(99, 102, 241, 0.28);
  --bg-gradient-b: rgba(56, 189, 248, 0.15);
  --card-bg: rgba(15, 23, 42, 0.82);
  --text-primary: #e2e8f0;
  --text-muted: #94a3b8;
  --heading-accent: #c7d2fe;
  --accent: #6366f1;
  --accent-soft: rgba(30, 41, 59, 0.65);
  --border: rgba(99, 102, 241, 0.28);
  --table-head-bg: rgba(30, 41, 59, 0.65);
  --btn-bg: rgba(15, 23, 42, 0.88);
  --btn-border: rgba(99, 102, 241, 0.35);
  --btn-color: #c7d2fe;
  --note-bg: rgba(30, 58, 138, 0.35);
  --note-border: #6366f1;
  --note-text: #c7d2fe;
  --pill-bg: rgba(30, 58, 138, 0.35);
  --pill-border: rgba(129, 140, 248, 0.5);
  --pill-text: #c7d2fe;
  --link: #a5b4fc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  background:
    radial-gradient(900px 500px at 20% -10%, var(--bg-gradient-a), transparent 60%),
    radial-gradient(900px 500px at 120% 20%, var(--bg-gradient-b), transparent 60%),
    linear-gradient(180deg, var(--bg-primary), var(--bg-primary));
  min-height: 100vh;
  line-height: 1.65;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 36px 20px 64px;
}

.brand {
  display: block;
  width: fit-content;
  margin: 0 auto 14px;
  text-decoration: none;
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #6366f1 0%, #0ea5e9 50%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
  animation: gradient-text-shift 6s ease-in-out infinite;
  position: relative;
  overflow: hidden;
  padding: 0.35rem 0.85rem;
  border-radius: 0.5rem;
  transition: color 0.3s ease;
}

.brand::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, #6366f1, #0ea5e9, #10b981, #6366f1);
  background-size: 300% 300%;
  opacity: 0;
  border-radius: inherit;
  z-index: -1;
  animation: brand-gradient-shift 3s ease infinite;
  transition: opacity 0.4s ease;
}

.brand-tm {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.68em;
  font-weight: 600;
  vertical-align: super;
  margin-left: 1px;
  -webkit-text-fill-color: #6366f1;
}

[data-theme="dark"] .brand-tm {
  -webkit-text-fill-color: #818cf8;
}

@media (hover: hover) and (pointer: fine) {
  .brand:hover::before {
    opacity: 0.4;
  }

  .brand:hover {
    transform: none;
    box-shadow: none;
  }
}

@keyframes gradient-text-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes brand-gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.card {
  border: 1px solid var(--border);
  background: var(--card-bg);
  backdrop-filter: blur(6px);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(2, 6, 23, 0.12);
}

.doc-title {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 3.5vw, 2.1rem);
  line-height: 1.25;
  text-align: center;
}

.doc-subtitle {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
}

.doc-product {
  margin: 0 0 4px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.meta-grid strong { color: var(--text-primary); }

.meta-line {
  color: var(--text-muted);
  margin: 0 0 18px;
  font-size: 0.95rem;
  text-align: center;
}

.meta {
  color: var(--text-muted);
  margin: 0 0 18px;
  font-size: 0.95rem;
  text-align: center;
}

.card > h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  line-height: 1.2;
  text-align: center;
}

.card > h2 {
  margin: 28px 0 8px;
  font-size: 1.16rem;
  color: var(--heading-accent);
}

.card > p { margin: 10px 0; }
.card > ul { margin: 10px 0 6px 22px; padding: 0; }
.card > li { margin: 5px 0; }

.card > table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 8px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.card > table th,
.card > table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.card > table th {
  color: var(--heading-accent);
  background: var(--table-head-bg);
  font-weight: 600;
}

.card > table tr:last-child td { border-bottom: none; }

.card a {
  color: var(--link);
  text-decoration: none;
}

.card a:hover { text-decoration: underline; }

.card code {
  font-size: 0.9em;
  color: var(--text-muted);
}

.policy-content h2 {
  margin: 28px 0 8px;
  font-size: 1.16rem;
  color: var(--heading-accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.policy-content h3 {
  margin: 18px 0 8px;
  font-size: 1rem;
  color: var(--heading-accent);
}

.policy-content p { margin: 10px 0; }
.policy-content ul { margin: 10px 0 6px 22px; padding: 0; }
.policy-content li { margin: 5px 0; }

.policy-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 8px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.policy-content th,
.policy-content td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.policy-content th {
  color: var(--heading-accent);
  background: var(--table-head-bg);
  font-weight: 600;
}

.policy-content tr:last-child td { border-bottom: none; }

.policy-content a {
  color: var(--link);
  text-decoration: none;
}

.policy-content a:hover { text-decoration: underline; }

.pill {
  display: inline-block;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: var(--pill-text);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}

.note {
  border-left: 4px solid var(--note-border);
  background: var(--note-bg);
  padding: 10px 12px;
  margin: 10px 0;
  color: var(--note-text);
  font-size: 14px;
}

.floating-actions {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}

.action-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, color 0.2s ease;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.15);
}

.action-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.action-btn svg { width: 20px; height: 20px; }
.action-btn.copied {
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.7);
}

.action-btn .icon-hidden { display: none; }

/* Print footer — hidden on screen */
.print-footer,
.print-footer-chrome-mask,
.print-footer-before,
.print-footer-after {
  display: none;
}

@media print {
  @page {
    margin: 0 0 52px 0;
    size: letter;

    @bottom-center {
      content: string(footer-before) counter(page) string(footer-after);
      font-family: system-ui, sans-serif;
      font-size: 8.5px;
      line-height: 1.3;
      color: #64748b;
      border-top: 1px solid #cbd5e1;
      padding-top: 8px;
      vertical-align: top;
      text-align: center;
      width: 100%;
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
    }
  }

  @page :first {
    counter-reset: page 1;
  }

  html,
  body {
    margin: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    min-height: auto;
    line-height: 1.45;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    padding: 12px 24px 0;
    box-sizing: border-box;
  }

  .print-footer-before,
  .print-footer-after {
    display: block !important;
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .print-footer-before {
    string-set: footer-before content(text);
  }

  .print-footer-after {
    string-set: footer-after content(text);
  }

  .print-footer,
  .print-footer-chrome-mask {
    display: none !important;
  }

  html[data-print-footer-mode='fixed'] .print-footer-before,
  html[data-print-footer-mode='fixed'] .print-footer-after {
    display: none !important;
  }

  html[data-print-footer-mode='fixed'] .print-footer-chrome-mask {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 18px;
    background: #fff;
    z-index: 10001;
    pointer-events: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html[data-print-footer-mode='fixed'] .print-footer {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 52px;
    align-items: center;
    justify-content: center;
    font-family: system-ui, sans-serif;
    font-size: 8.5px;
    line-height: 1.3;
    color: #64748b;
    background: #fff;
    border-top: 1px solid #cbd5e1;
    z-index: 10002;
    padding: 0 16px 18px;
    text-align: center;
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html[data-print-footer-mode='fixed'] .print-footer .page-number::after {
    content: counter(page);
  }

  html[data-print-footer-mode='fixed'] body {
    counter-reset: page 1;
  }

  .floating-actions,
  .brand {
    display: none !important;
  }

  .wrap {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .card {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    border-radius: 0;
    padding: 0;
  }

  .doc-title {
    font-size: 22px;
    text-align: center;
    margin-bottom: 4px;
  }

  .doc-subtitle,
  .doc-product,
  .meta-grid,
  .meta-line,
  .meta {
    display: none !important;
  }

  .card > h1 {
    font-size: 24px;
    text-align: center;
  }

  .card > h2 {
    margin-top: 18px;
  }

  /* Keep section headings intact and with their opening content */
  .card > h1,
  .card > h2,
  .policy-content h2,
  .policy-content h3 {
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: avoid;
    page-break-after: avoid;
  }

  .card > h2 + h3,
  .policy-content h2 + h3 {
    break-before: avoid;
    page-break-before: avoid;
  }

  .card > h2 + p,
  .card > h2 + ul,
  .card > h2 + ol,
  .card > h2 + table,
  .card > h2 + .note,
  .card > h2 + h3,
  .policy-content h2 + p,
  .policy-content h2 + ul,
  .policy-content h2 + ol,
  .policy-content h2 + table,
  .policy-content h2 + .note,
  .policy-content h2 + h3,
  .policy-content h3 + p,
  .policy-content h3 + ul,
  .policy-content h3 + ol,
  .policy-content h3 + table,
  .policy-content h3 + .note {
    break-before: avoid;
    page-break-before: avoid;
  }

  .card > h1,
  .card > h2,
  .card > p,
  .card > li,
  .card > td,
  .card > th,
  .policy-content h2,
  .policy-content h3,
  .policy-content p,
  .policy-content li,
  .policy-content td,
  .policy-content th {
    color: #000000 !important;
  }

  .policy-content h2 {
    margin-top: 18px;
    border-bottom-color: #aaa !important;
  }

  .table-scroll {
    display: block !important;
    overflow: visible !important;
    border: 0;
    margin: 12px 0 8px;
    border-radius: 0;
    max-width: none !important;
    width: auto !important;
  }

  .table-scroll table,
  .policy-content table,
  .card > table {
    display: table !important;
    border: 1px solid #888 !important;
    page-break-inside: auto;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: fixed;
  }

  .policy-content table thead,
  .card > table thead,
  .table-scroll table thead {
    display: table-header-group;
  }

  .policy-content table tbody,
  .card > table tbody,
  .table-scroll table tbody {
    display: table-row-group;
  }

  .policy-content th,
  .policy-content td,
  .table-scroll th,
  .table-scroll td,
  .card > table th,
  .card > table td {
    border-bottom: 1px solid #aaa !important;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0 !important;
  }

  .policy-content th {
    background: #f2f2f2 !important;
  }

  .policy-content tr,
  .card > table tr,
  .table-scroll table tr {
    break-inside: auto;
    page-break-inside: auto;
  }

  .policy-content td,
  .policy-content th,
  .card > table td,
  .card > table th,
  .table-scroll td,
  .table-scroll th {
    break-inside: auto;
    page-break-inside: auto;
  }

  .policy-content a {
    color: #000 !important;
    text-decoration: underline;
  }

  .pill,
  .note {
    border-color: #888 !important;
    background: #f5f5f5 !important;
    color: #000 !important;
  }

  .policy-content p,
  .card > p {
    orphans: 3;
    widows: 3;
  }

  .policy-content li,
  .card > li {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .policy-content .note,
  .card > .note {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

@media screen and (max-width: 768px) {
  html,
  body {
    overflow-x: hidden;
  }

  .wrap,
  .card,
  .policy-content {
    min-width: 0;
    max-width: 100%;
  }

  .wrap {
    padding: 20px 12px 96px;
  }

  .card {
    padding: 18px 14px;
    border-radius: 14px;
  }

  .doc-title {
    font-size: 1.35rem;
  }

  .doc-subtitle {
    font-size: 0.88rem;
  }

  .policy-content h2 {
    font-size: 1.05rem;
  }

  .floating-actions {
    right: 12px;
    bottom: 16px;
    top: auto;
    transform: none;
    flex-direction: row;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    margin: 12px 0 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
  }

  .table-scroll:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .table-scroll table {
    width: max-content;
    min-width: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  .table-scroll th,
  .table-scroll td {
    padding: 8px 10px;
    font-size: 0.84rem;
    vertical-align: top;
  }

  .table-scroll td:last-child,
  .table-scroll th:last-child {
    min-width: 11rem;
  }

  .table-scroll td:last-child a {
    word-break: break-all;
  }
}
