/* Heading Structure Checker — tool-specific styles (loaded on this tool only). */

.hs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ti-border);
}

.hs-save {
  margin: 0;
}

.hs-jump {
  display: none;
  font-weight: var(--ti-fw-semi);
  text-decoration: none;
}

.hs-import {
  margin-bottom: 24px;
  padding: 20px;
  border: 1px solid rgba(79, 70, 229, 0.25);
  border-radius: var(--ti-radius-lg);
  background: rgba(79, 70, 229, 0.04);
}

.hs-import .ti-actions {
  margin: 12px 0;
}

.hs-form__title {
  margin-bottom: 4px;
}

.hs-form__intro {
  margin: 0 0 16px;
}

/* Sections */
.hs-sec {
  margin-bottom: 12px;
  border: 1px solid var(--ti-border);
  border-radius: var(--ti-radius-lg);
  background: var(--ti-white);
}

.hs-sec[hidden] {
  display: none;
}

.hs-sec > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--ti-radius-lg);
}

.hs-sec > summary::-webkit-details-marker {
  display: none;
}

.hs-sec > summary::before {
  content: "";
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--ti-primary);
  border-bottom: 2px solid var(--ti-primary);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.hs-sec[open] > summary::before {
  transform: rotate(45deg);
}

.hs-sec > summary:hover {
  background: var(--ti-bg);
}

.hs-sec > summary:focus-visible {
  outline: none;
  box-shadow: var(--ti-focus);
}

.hs-sec__title {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: var(--ti-fw-bold);
  letter-spacing: -0.01em;
}

.hs-sec__tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.1);
  font-size: 16px;
  font-weight: var(--ti-fw-semi);
  color: #B91C1C;
}

.hs-sec__tag--rec {
  background: var(--ti-primary-tint);
  color: var(--ti-primary);
}

.hs-sec__tag--opt {
  background: var(--ti-bg);
  color: var(--ti-muted-color);
}

.hs-sec__body {
  padding: 4px 18px 18px;
}

.hs-textarea-sm {
  min-height: 96px;
}

.hs-help-tight {
  margin: -6px 0 16px;
}

.hs-help-top {
  margin: 0 0 14px;
}

.hs-link-btn {
  display: inline-block;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--ti-font);
  font-size: 16px;
  font-weight: var(--ti-fw-semi);
  color: var(--ti-primary);
  cursor: pointer;
}

.hs-link-btn:hover {
  text-decoration: underline;
}

.hs-link-btn[hidden] {
  display: none;
}

/* Output */
.hs-output {
  min-height: 220px;
  max-height: 56vh;
}

.hs-out__actions {
  margin: 14px 0 20px;
}

.hs-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.hs-summary p {
  margin: 0;
  font-size: 16px;
}

.ti-issue--error { border-left: 4px solid #DC2626; }
.ti-issue--warn  { border-left: 4px solid #D97706; }
.ti-issue--ok    { border-left: 4px solid #16A34A; }
.ti-issue--info  { border-left: 4px solid var(--ti-primary); }

.hs-issue-link {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--ti-font);
  font-size: 16px;
  font-weight: var(--ti-fw-semi);
  color: var(--ti-text-color);
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--ti-border-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}

.hs-issue-link:hover {
  color: var(--ti-primary);
}

.hs-note {
  margin-top: 14px;
}

@media (max-width: 980px) {
  .hs-jump {
    display: inline-block;
  }
}

@media (max-width: 640px) {
  .hs-output {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .hs-sec__body {
    padding: 4px 14px 16px;
  }

  .hs-sec > summary {
    padding: 14px;
  }
}

.hs-empty {
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--ti-border-strong);
  border-radius: var(--ti-radius-md);
  color: var(--ti-muted-color);
}

/* Heading checker-specific */
.hs-in__tools { gap: 8px; }
.hs-file-btn { position: relative; cursor: pointer; }
.hs-file-btn:focus-within { box-shadow: var(--ti-focus); }
.hs-input { min-height: 320px; }
.hs-input.is-drop { border-color: var(--ti-primary); background: var(--ti-primary-tint); }
.hs-source { margin: 8px 0 16px; }
.hs-opts { margin-top: 4px; }
.hs-scope-help { margin: -4px 0 0; }
.hs-sub { margin: 20px 0 12px; font-size: 18px; font-weight: var(--ti-fw-bold); }
.hs-empty p { margin: 0; padding: 14px 16px; border: 1px dashed var(--ti-border-strong); border-radius: var(--ti-radius-md); color: var(--ti-muted-color); }

/* Counts per level */
.hs-counts {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.hs-count {
  display: grid;
  justify-items: center;
  gap: 2px;
  margin: 0;
  padding: 10px 4px;
  border: 1px solid var(--ti-border);
  border-radius: var(--ti-radius-md);
  background: var(--ti-white);
}

.hs-count__lvl { font-weight: var(--ti-fw-semi); color: var(--ti-muted-color); }
.hs-count__n { font-size: 22px; font-weight: var(--ti-fw-bold); color: var(--ti-text-color); }
.hs-count--zero .hs-count__n { color: var(--ti-muted-color); }

.hs-facts { display: grid; gap: 6px; margin: 0; }
.hs-facts div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; }
.hs-facts dt { font-weight: var(--ti-fw-semi); }
.hs-facts dd { margin: 0; overflow-wrap: anywhere; color: var(--ti-muted-color); }

/* Outline tree */
.hs-outline {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--ti-border);
  border-radius: var(--ti-radius-lg);
  background: var(--ti-white);
}

.hs-outline[hidden] { display: none; }
.hs-outline__head { flex-wrap: wrap; gap: 10px 16px; }
.hs-outline__help { margin: 0 0 14px; }

.hs-tree { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }

.hs-node {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 0 0 0 calc(var(--lvl, 0) * 28px);
  padding: 10px 14px;
  border: 1px solid var(--ti-border);
  border-left: 4px solid var(--ti-border-strong);
  border-radius: var(--ti-radius-sm);
  background: var(--ti-bg);
}

.hs-node:focus-visible { outline: none; box-shadow: var(--ti-focus); }
.hs-node--hidden { opacity: 0.7; border-style: dashed; }
.hs-node--flash { animation: hs-flash 1.2s ease; }
@keyframes hs-flash { 0%, 40% { background: var(--ti-primary-tint); border-color: var(--ti-primary); } 100% { background: var(--ti-bg); } }
@media (prefers-reduced-motion: reduce) { .hs-node--flash { animation: none; outline: 3px solid var(--ti-primary); } }

.hs-node__lvl {
  display: grid;
  place-items: center;
  min-width: 40px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: var(--ti-fw-bold);
  color: #FFFFFF;
  background: #4F46E5;
}

.hs-node__lvl--1 { background: #312E81; }
.hs-node__lvl--2 { background: #4F46E5; }
.hs-node__lvl--3 { background: #0F766E; }
.hs-node__lvl--4 { background: #9A3412; }
.hs-node__lvl--5 { background: #6B21A8; }
.hs-node__lvl--6 { background: #374151; }

.hs-node__body { display: grid; gap: 4px; min-width: 0; }
.hs-node__text { font-weight: var(--ti-fw-semi); overflow-wrap: anywhere; }
.hs-node__text em { font-weight: 400; color: #991B1B; }
.hs-node__meta { color: var(--ti-muted-color); }
.hs-node__chips { display: flex; flex-wrap: wrap; gap: 6px; }

.hs-chip { padding: 0 10px; border-radius: 999px; background: var(--ti-primary-tint); color: var(--ti-primary); }
.hs-chip--bad { background: rgba(220, 38, 38, 0.1); color: #991B1B; }
.hs-chip--warn { background: rgba(217, 119, 6, 0.12); color: #92400E; }
.hs-chip--ok { background: rgba(22, 163, 74, 0.12); color: #166534; }

@media (max-width: 760px) {
  .hs-node { margin-left: calc(var(--lvl, 0) * 14px); padding: 10px; }
  .hs-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hs-facts div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .hs-outline { padding: 14px; }
}
