/* ==========================================================================
   Transport Tycoon — public legal/guide overlay + admin legal workspace
   No external dependencies.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Public overlay
   -------------------------------------------------------------------------- */
.tt-legal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 3vw, 34px);
}

.tt-legal-overlay[hidden] {
  display: none;
}

.tt-legal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(34, 211, 238, .10), transparent 60%),
    rgba(2, 6, 16, .78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.tt-legal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(900px, 100%);
  max-height: min(90vh, 960px);
  color: #e6eefb;
  background:
    linear-gradient(180deg, rgba(17, 29, 49, .98), rgba(9, 16, 30, .99));
  border: 1px solid rgba(99, 125, 165, .34);
  border-radius: 20px;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, .60),
    0 0 0 1px rgba(255, 255, 255, .03) inset,
    0 1px 0 rgba(255, 255, 255, .05) inset;
  overflow: hidden;
  outline: none;
  animation: tt-legal-in .22s cubic-bezier(.2, .8, .2, 1) both;
}

.tt-legal-panel:focus {
  outline: none;
}

@keyframes tt-legal-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tt-legal-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  padding: clamp(18px, 3vw, 28px) clamp(18px, 3.4vw, 34px) 18px;
  border-bottom: 1px solid rgba(99, 125, 165, .20);
  background:
    radial-gradient(600px 180px at 0% 0%, rgba(34, 211, 238, .10), transparent 70%);
  flex: 0 0 auto;
}

.tt-legal-head-copy {
  min-width: 0;
}

.tt-legal-kicker {
  display: inline-block;
  margin-bottom: 8px;
  color: #67e8f9;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.tt-legal-head h2 {
  margin: 0;
  color: #f4f9ff;
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: clamp(22px, 4vw, 32px);
  line-height: 1.16;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}

.tt-legal-meta {
  max-width: 680px;
  margin: 9px 0 0;
  color: #9db0cb;
  font-size: 13.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.tt-legal-meta[hidden] {
  display: none;
}

.tt-legal-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(99, 125, 165, .35);
  border-radius: 12px;
  color: #c8d6ea;
  background: rgba(15, 27, 46, .75);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .15s;
}

.tt-legal-close:hover {
  color: #fff;
  border-color: rgba(34, 211, 238, .55);
  background: rgba(34, 211, 238, .12);
}

.tt-legal-close:active {
  transform: scale(.96);
}

.tt-legal-body {
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(18px, 3vw, 30px) clamp(18px, 3.4vw, 34px);
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 125, 165, .55) transparent;
}

.tt-legal-body::-webkit-scrollbar {
  width: 10px;
}

.tt-legal-body::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 10px;
  background: rgba(99, 125, 165, .55);
  background-clip: padding-box;
}

.tt-legal-loading,
.tt-legal-empty,
.tt-legal-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 220px;
  padding: 34px 20px;
  text-align: center;
  color: #a9bbd3;
}

.tt-legal-loading {
  flex-direction: row;
  gap: 12px;
  min-height: 180px;
}

.tt-legal-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(99, 125, 165, .30);
  border-top-color: #22d3ee;
  border-radius: 50%;
  animation: tt-legal-spin .75s linear infinite;
}

@keyframes tt-legal-spin {
  to { transform: rotate(360deg); }
}

.tt-legal-empty strong,
.tt-legal-error strong {
  color: #e7f0ff;
  font-size: 15px;
}

.tt-legal-empty p,
.tt-legal-error p {
  max-width: 480px;
  margin: 0;
  color: #9db0cb;
  font-size: 13px;
  line-height: 1.6;
}

.tt-legal-error {
  min-height: 200px;
}

.tt-legal-btn {
  appearance: none;
  border: 1px solid rgba(99, 125, 165, .38);
  border-radius: 10px;
  padding: 9px 15px;
  color: #d8e4f5;
  background: rgba(15, 27, 46, .85);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.tt-legal-btn:hover {
  color: #fff;
  border-color: rgba(34, 211, 238, .55);
}

.tt-legal-btn-primary {
  margin-top: 6px;
  color: #04202a;
  border-color: transparent;
  background: linear-gradient(135deg, #67e8f9, #22d3ee);
}

.tt-legal-btn-primary:hover {
  color: #04202a;
  background: linear-gradient(135deg, #a5f3fc, #67e8f9);
}

.tt-legal-item {
  padding: 0 0 22px;
}

.tt-legal-item + .tt-legal-item {
  border-top: 1px solid rgba(99, 125, 165, .17);
  padding-top: 22px;
}

.tt-legal-item:last-child {
  padding-bottom: 0;
}

.tt-legal-item-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 9px;
}

.tt-legal-number {
  flex: 0 0 auto;
  min-width: 1.9em;
  color: #67e8f9;
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tt-legal-item h3 {
  margin: 0;
  color: #eef6ff;
  font-size: clamp(15px, 2.2vw, 18px);
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.tt-legal-copy {
  margin-left: 0;
  color: #b8c7dc;
  font-size: 13.8px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.tt-legal-number + h3 {
  min-width: 0;
}

.tt-legal-copy p {
  margin: 0 0 11px;
}

.tt-legal-copy p:last-child {
  margin-bottom: 0;
}

.tt-legal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: 0 0 auto;
  padding: 13px clamp(18px, 3.4vw, 34px);
  border-top: 1px solid rgba(99, 125, 165, .20);
  background: rgba(6, 12, 23, .55);
  color: #7f93ae;
  font-size: 11.5px;
}

body.tt-legal-open {
  overflow: hidden;
}

.tt-legal-footer-links {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tt-legal-footer-links a {
  color: #8aa0bd;
  text-decoration: none;
  border-bottom: 1px dotted rgba(138, 160, 189, .42);
  transition: color .15s, border-color .15s;
}

.tt-legal-footer-links a:hover {
  color: #67e8f9;
  border-color: #67e8f9;
}

/* --------------------------------------------------------------------------
   Admin legal workspace
   -------------------------------------------------------------------------- */
.legal-admin-layout {
  display: grid;
  grid-template-columns: minmax(250px, 330px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.legal-pages-card {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.legal-page-list {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.legal-page-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid rgba(99, 125, 165, .14);
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.legal-page-link:last-child {
  border-bottom: 0;
}

.legal-page-link:hover {
  background: rgba(34, 211, 238, .055);
}

.legal-page-link.is-active {
  background: rgba(34, 211, 238, .10);
  box-shadow: inset 3px 0 0 #22d3ee;
}

.legal-page-link-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legal-page-link-main strong {
  color: #edf5ff;
  font-size: 13.5px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.legal-page-slug {
  color: #7f93ae;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

.legal-page-link-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.legal-admin-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.legal-admin-form .check-row {
  margin-top: 16px;
}

.legal-items-card .card-body {
  min-width: 0;
}

.legal-item-list {
  max-height: 440px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.legal-item-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(99, 125, 165, .14);
}

.legal-item-row:last-child {
  border-bottom: 0;
}

.legal-item-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 3px 7px;
  border: 1px solid rgba(99, 125, 165, .28);
  border-radius: 8px;
  color: #67e8f9;
  background: rgba(34, 211, 238, .06);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
}

.legal-item-main {
  min-width: 0;
}

.legal-item-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  color: #edf5ff;
  font-size: 13.5px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.legal-item-snippet {
  margin-top: 4px;
  color: #93a8c4;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.legal-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
  color: #6f849f;
  font-size: 10.5px;
}

.legal-item-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legal-admin-preview-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(99, 125, 165, .20);
}

.legal-admin-preview-head p {
  margin: 0;
  color: #9db0cb;
  font-size: 12.5px;
  line-height: 1.55;
}

.legal-preview-item {
  padding: 0 0 20px;
}

.legal-preview-item + .legal-preview-item {
  border-top: 1px solid rgba(99, 125, 165, .17);
  padding-top: 20px;
}

.legal-preview-heading {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}

.legal-preview-heading h3 {
  margin: 0;
  color: #eef6ff;
  font-size: 16px;
  line-height: 1.35;
}

.legal-preview-number {
  flex: 0 0 auto;
  color: #67e8f9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 700;
}

.legal-preview-content {
  color: #b8c7dc;
  font-size: 13px;
  line-height: 1.7;
}

.legal-preview-content p {
  margin: 0 0 10px;
}

.legal-preview-content p:last-child {
  margin-bottom: 0;
}

@media (max-width: 1080px) {
  .legal-admin-layout {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }
}

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

  .legal-pages-card {
    position: static;
  }

  .legal-page-list {
    max-height: 260px;
  }

  .legal-item-list {
    max-height: 520px;
  }
}

@media (max-width: 640px) {
  .tt-legal-overlay {
    padding: 0;
  }

  .tt-legal-panel {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .tt-legal-head {
    padding: 16px 16px 14px;
  }

  .tt-legal-body {
    padding: 16px;
  }

  .tt-legal-foot {
    padding: 12px 16px;
  }

  .tt-legal-foot > span:first-child {
    display: none;
  }

  .legal-item-row {
    grid-template-columns: 34px minmax(0, 1fr);
    padding: 13px 14px;
  }

  .legal-item-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tt-legal-panel,
  .tt-legal-spinner {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   Public legal page structure polish
   -------------------------------------------------------------------------- */
.tt-legal-panel {
  width: min(920px, 100%);
  max-height: min(86vh, 900px);
}

.tt-legal-body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .012), transparent 120px),
    rgba(5, 11, 21, .24);
}

.tt-legal-body > .tt-legal-item,
.tt-legal-body > .tt-legal-loading,
.tt-legal-body > .tt-legal-empty,
.tt-legal-body > .tt-legal-error {
  width: min(760px, 100%);
  margin-inline: auto;
}

.tt-legal-item {
  padding: 18px 20px;
  border: 1px solid rgba(99, 125, 165, .22);
  border-radius: 14px;
  background: rgba(16, 28, 48, .66);
  box-shadow: 0 10px 26px -22px rgba(0, 0, 0, .9);
}

.tt-legal-item + .tt-legal-item {
  margin-top: 14px;
  padding-top: 18px;
  border-top: 1px solid rgba(99, 125, 165, .22);
}

.tt-legal-item-head {
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.tt-legal-number {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  margin-top: -2px;
  border: 1px solid rgba(34, 211, 238, .30);
  border-radius: 10px;
  color: #a5f3fc;
  background: rgba(34, 211, 238, .09);
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tt-legal-item h3 {
  padding-top: 3px;
  color: #f3f8ff;
  font-size: clamp(15px, 1.8vw, 17px);
  line-height: 1.45;
}

.tt-legal-item h3:focus,
.tt-legal-item h3:focus-visible {
  outline: none;
}

.tt-legal-copy {
  margin-left: 46px;
  color: #b9c8dd;
  font-size: 13.8px;
  line-height: 1.75;
}

.tt-legal-copy p {
  margin-bottom: 10px;
}

.tt-legal-foot {
  background: rgba(4, 9, 18, .72);
}

@media (max-width: 640px) {
  .tt-legal-overlay {
    align-items: center;
    padding: 10px;
  }

  .tt-legal-panel {
    width: 100%;
    height: auto;
    max-height: 94dvh;
    border: 1px solid rgba(99, 125, 165, .34);
    border-radius: 17px;
  }

  .tt-legal-head {
    padding: 17px 17px 14px;
  }

  .tt-legal-head h2 {
    font-size: 23px;
  }

  .tt-legal-meta {
    font-size: 12.5px;
  }

  .tt-legal-close {
    width: 38px;
    height: 38px;
  }

  .tt-legal-body {
    padding: 14px 12px 18px;
  }

  .tt-legal-item {
    padding: 14px 14px;
    border-radius: 12px;
  }

  .tt-legal-item + .tt-legal-item {
    padding-top: 14px;
  }

  .tt-legal-item-head {
    gap: 11px;
  }

  .tt-legal-number {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 8px;
    font-size: 11.5px;
  }

  .tt-legal-copy {
    margin-left: 0;
    font-size: 13.2px;
  }

  .tt-legal-foot {
    padding: 11px 15px;
  }
}
