/* Institutional Legal Document Layout for DuckHosts Terms of Service & Privacy Policy.
   Shared navbar and footer styles are untouched. */
#terms-of-service {
  --legal-bg: #12161f;
  --legal-sheet-bg: #151a24;
  --legal-border: #252e3d;
  --legal-divider: rgba(255, 255, 255, 0.08);
  --legal-heading: #f8fafc;
  --legal-text: #dce3ee;
  --legal-muted: #94a3b8;
  --legal-accent: #6378ff;
  padding: 36px 0 88px;
  color: var(--legal-text);
}

#terms-of-service .container {
  width: calc(100% - 48px);
  max-width: 1160px;
}

#terms-of-service :is(a, button):focus-visible {
  outline: 2px solid var(--legal-accent);
  outline-offset: 3px;
}

/* Institutional Document Header */
#terms-of-service .legal-header {
  margin-bottom: 28px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--legal-border);
}

#terms-of-service .legal-header__kicker {
  margin: 0 0 10px !important;
  color: var(--legal-muted) !important;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#terms-of-service .legal-header h1 {
  margin: 0 0 14px !important;
  color: var(--legal-heading) !important;
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 800;
  line-height: 1.24;
  letter-spacing: -0.025em;
}

#terms-of-service .legal-header__lead {
  margin: 0 !important;
  max-width: 820px;
  color: #cbd5e1 !important;
  font-size: 15.5px;
  line-height: 1.75;
}

/* Document Filter / View Tabs */
#terms-of-service .legal-doc-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 30px;
  padding: 6px;
  border: 1px solid var(--legal-border);
  border-radius: 10px;
  background: var(--legal-bg);
}

#terms-of-service .legal-doc-tabs__group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}

#terms-of-service .legal-tab-btn {
  flex: 1;
  min-height: 42px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

#terms-of-service .legal-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.03);
}

#terms-of-service .legal-tab-btn.is-active {
  background: #1d2534;
  border-color: #36445d;
  color: #ffffff;
  font-weight: 700;
}

/* Two-Column Workspace */
#terms-of-service .tos-workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
  gap: 36px;
}

/* Left Institutional Index (Fihrist) */
#terms-of-service .tos-sidebar {
  position: sticky;
  top: 112px;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 140px);
  background: var(--legal-bg);
  border: 1px solid var(--legal-border);
  border-radius: 10px;
  padding: 18px 16px;
}

#terms-of-service .tos-sidebar-head {
  padding: 0 4px 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--legal-border);
  color: var(--legal-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#terms-of-service .tos-nav-toggle {
  display: none;
}

#terms-of-service #tosNav {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
  padding-right: 4px;
}

#terms-of-service .tos-nav-group {
  display: flex;
  flex-direction: column;
}

#terms-of-service .tos-nav-group[hidden] {
  display: none !important;
}

#terms-of-service .tos-nav-group-title {
  padding: 0 4px 8px;
  color: var(--legal-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#terms-of-service .tos-nav-list {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--legal-border);
  margin-left: 4px;
}

#terms-of-service .tos-nav-link {
  position: relative;
  display: block;
  padding: 7px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: #94a3b8 !important;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

#terms-of-service .tos-nav-link:hover {
  color: #e2e8f0 !important;
}

#terms-of-service .tos-nav-link.is-active {
  border-left-color: #f8fafc;
  color: #ffffff !important;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.025);
}

/* Right Formal Document Sheet */
#terms-of-service .tos-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

#terms-of-service .legal-sheet {
  background: var(--legal-sheet-bg);
  border: 1px solid var(--legal-border);
  border-top: 3px solid #64748b;
  border-radius: 8px;
  padding: 44px 52px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  scroll-margin-top: 116px;
}

#terms-of-service .legal-sheet[hidden] {
  display: none !important;
}

#terms-of-service .legal-sheet__header {
  padding-bottom: 26px;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--legal-border);
}

#terms-of-service .legal-sheet__code {
  display: block;
  color: var(--legal-muted) !important;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 8px !important;
}

#terms-of-service .legal-sheet__header h2 {
  margin: 0 0 14px !important;
  color: var(--legal-heading) !important;
  font-size: clamp(22px, 2.4vw, 27px);
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: -0.02em;
}

#terms-of-service .legal-sheet__preamble {
  margin: 0 !important;
  padding: 16px 20px;
  border-left: 3px solid #475569;
  background: rgba(255, 255, 255, 0.02);
  color: #dbe4f0 !important;
  font-size: 14.5px;
  line-height: 1.78;
}

#terms-of-service .legal-sheet__preamble p {
  margin: 0 !important;
  color: #dbe4f0 !important;
  font-size: 14.5px;
  line-height: 1.78;
}

#terms-of-service .legal-sheet__preamble p + p {
  margin-top: 8px !important;
  color: #f1f5f9 !important;
  font-weight: 600;
}

/* Editorial Clauses inside Legal Sheet */
#terms-of-service .legal-clauses {
  display: flex;
  flex-direction: column;
}

#terms-of-service .tos-card {
  padding: 26px 0;
  border-bottom: 1px solid var(--legal-divider);
  scroll-margin-top: 120px;
}

#terms-of-service .tos-card:last-child {
  padding-bottom: 4px;
  border-bottom: 0;
}

#terms-of-service .tos-card h3 {
  margin: 0 0 12px !important;
  color: var(--legal-heading) !important;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: -0.01em;
}

#terms-of-service .tos-points {
  list-style: disc;
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#terms-of-service .tos-points li {
  color: var(--legal-text) !important;
  font-size: 15px;
  line-height: 1.82;
  padding-left: 4px;
}

#terms-of-service .tos-points li::marker {
  color: #64748b;
}

#terms-of-service .tos-points li strong {
  color: #f8fafc !important;
  font-weight: 700;
}

#terms-of-service .tos-points a {
  color: #e2e8f0 !important;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

#terms-of-service .tos-points a:hover {
  color: #ffffff !important;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  #terms-of-service .legal-meta-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #terms-of-service .legal-meta-item:nth-child(2) {
    border-right: 0;
  }
  #terms-of-service .legal-meta-item:nth-child(1),
  #terms-of-service .legal-meta-item:nth-child(2) {
    border-bottom: 1px solid var(--legal-border);
  }
  #terms-of-service .tos-workspace {
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 24px;
  }
  #terms-of-service .legal-sheet {
    padding: 32px 34px;
  }
}

@media (max-width: 860px) {
  #terms-of-service {
    padding-top: 20px;
  }
  #terms-of-service .tos-workspace {
    display: block;
  }
  #terms-of-service .tos-sidebar {
    position: static;
    max-height: none;
    padding: 0;
    margin-bottom: 22px;
    overflow: hidden;
  }
  #terms-of-service .tos-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 13px 16px;
    color: #f8fafc;
    background: #181f2c;
    border: 0;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }
  #terms-of-service .tos-nav-toggle i {
    transition: transform 0.18s ease;
  }
  #terms-of-service .tos-sidebar.is-open .tos-nav-toggle i {
    transform: rotate(180deg);
  }
  #terms-of-service .tos-sidebar-head {
    display: none;
  }
  #terms-of-service #tosNav {
    display: none;
    max-height: 360px;
    padding: 14px 16px;
    border-top: 1px solid var(--legal-border);
  }
  #terms-of-service .tos-sidebar.is-open #tosNav {
    display: flex;
  }
}

@media (max-width: 560px) {
  #terms-of-service .container {
    width: calc(100% - 28px);
  }
  #terms-of-service .legal-meta-bar {
    grid-template-columns: 1fr;
  }
  #terms-of-service .legal-meta-item {
    border-right: 0;
    border-bottom: 1px solid var(--legal-border);
  }
  #terms-of-service .legal-meta-item:last-child {
    border-bottom: 0;
  }
  #terms-of-service .legal-doc-tabs__group {
    flex-direction: column;
    align-items: stretch;
  }
  #terms-of-service .legal-sheet {
    padding: 24px 20px;
  }
  #terms-of-service .tos-card {
    padding: 20px 0;
  }
  #terms-of-service .tos-card h3 {
    font-size: 16.5px;
  }
  #terms-of-service .tos-points li {
    font-size: 14.5px;
    line-height: 1.75;
  }
}

@media (prefers-reduced-motion: reduce) {
  #terms-of-service *,
  #terms-of-service *::before,
  #terms-of-service *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
