/* oneM2M theme overlay for standalone HTML (release notes diff).
 * Loaded after customCSS.css and onem2m-palette.css. */

/* Reset html/body rules from customCSS (max-width, padding, offset layout) */
html.theme-onem2m,
html:has(body.theme-onem2m) {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body.theme-onem2m {
  --html-layout-top: 3.2rem;
  --html-layout-bottom: 3.2rem;
  --html-header-height: 3.2rem;
  --html-footer-height: 3.2rem;
  /* Layout: 28ch sidebar, shell shifted left of center */
  --html-layout-max-width: 61rem;
  --html-shell-shift-left: 16ch;
  --html-grid-padding-x: 0.2rem;
  --html-sidebar-width: 28ch;
  --html-shell-columns: var(--html-sidebar-width) minmax(0, 1fr);
  --html-content-inset-x: 1.2rem;
  --html-content-inset-right: 0.8rem;
  --html-pane-top-gap: 0.8rem;
  --html-pane-bottom-gap: 0.8rem;
  --html-content-heading: rgba(0, 0, 0, 0.54);
  --html-nav-text: rgba(0, 0, 0, 0.87);
  --html-nav-text-muted: rgba(0, 0, 0, 0.67);
  --html-nav-chevron-icon: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8.59 16.58 13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.42Z'/%3E%3C/svg%3E");
  /* Diff addition colors — aligned with docx track-changes green */
  --diff-addition-color: #166534;
  --diff-addition-background: #ecfdf0;
  display: grid;
  grid-template-rows: var(--html-header-height) minmax(0, 1fr) var(--html-footer-height);
  grid-template-columns: minmax(0, 1fr);
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  min-height: 100vh;
  height: 100vh;
  margin: 0 !important;
  padding: 0 !important;
  position: static !important;
  left: auto !important;
  right: auto !important;
  overflow: hidden;
  background-color: #fff;
}

/* Shared centered shell — shifted left so TOC starts ~20ch earlier */
body.theme-onem2m .html-shell-grid {
  width: 100%;
  max-width: var(--html-layout-max-width);
  margin-left: max(0.2rem, calc((100% - var(--html-layout-max-width)) / 2 - var(--html-shell-shift-left)));
  margin-right: auto;
  box-sizing: border-box;
}

/* md-header__inner has 0.2rem horizontal padding; md-main__inner does not */
body.theme-onem2m .html-theme-header__inner.html-shell-grid {
  padding-left: var(--html-grid-padding-x);
  padding-right: var(--html-grid-padding-x);
}

body.theme-onem2m flex.html-layout.html-shell-grid {
  padding-left: 0;
  padding-right: 0;
}

body.theme-onem2m .html-theme-footer__text {
  width: 100%;
  max-width: var(--html-layout-max-width);
  margin-left: max(0.2rem, calc((100% - var(--html-layout-max-width)) / 2 - var(--html-shell-shift-left)));
  margin-right: auto;
  padding-left: calc(var(--html-grid-padding-x) + 1.05rem);
  padding-right: var(--html-grid-padding-x);
  box-sizing: border-box;
}

/* Top header — full-width bar; inner grid matches main (sidebar | content) */
body.theme-onem2m .html-theme-header {
  position: relative;
  grid-row: 1;
  grid-column: 1 / -1;
  width: 100%;
  z-index: 2;
  height: var(--html-header-height);
  background-color: var(--onem2m-primary);
  color: #fff;
  box-shadow: 0 0 0.2rem rgba(0, 0, 0, 0.1), 0 0.2rem 0.4rem rgba(0, 0, 0, 0.2);
}

body.theme-onem2m .html-theme-header__inner {
  display: grid;
  grid-template-columns: var(--html-shell-columns);
  align-items: center;
  height: 100%;
  min-width: 0;
}

body.theme-onem2m .html-theme-header__brand {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  margin: 0.2rem;
  padding: 0.4rem;
  color: inherit;
  text-decoration: none;
}

body.theme-onem2m .html-theme-header__brand:hover {
  color: #fff;
  text-decoration: none;
}

body.theme-onem2m .html-theme-header__logo {
  height: 1.2rem;
  width: auto;
  flex-shrink: 0;
  display: block;
}

body.theme-onem2m .html-theme-header__title {
  font-family: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-onem2m .html-theme-header__subtitle {
  grid-column: 2;
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0 var(--html-content-inset-right) 0 var(--html-content-inset-x);
  box-sizing: border-box;
  font-family: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-onem2m #title-block-header {
  display: none;
}

/* Main shell — same 2-column grid as header (md-sidebar | md-content) */
body.theme-onem2m flex.html-layout {
  grid-row: 2;
  grid-column: 1 / -1;
  display: grid !important;
  grid-template-columns: var(--html-shell-columns);
  grid-template-rows: minmax(0, 1fr);
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.theme-onem2m flex > flex-resizer {
  display: none !important;
}

/* Footer — full-width bar, footer text in shared shell */
body.theme-onem2m .html-theme-footer {
  grid-row: 3;
  grid-column: 1 / -1;
  display: block;
  width: 100%;
  padding: 0;
  background-color: #101419;
  color: rgba(255, 255, 255, 0.85);
  font-family: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.72rem;
  z-index: 2;
}

body.theme-onem2m .html-theme-footer__text {
  display: flex;
  align-items: center;
  min-height: var(--html-footer-height);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar — 28ch max (text + chevron) */
body.theme-onem2m flex-item.html-layout__sidebar,
body.theme-onem2m flex-item:has(#TOC) {
  grid-column: 1;
  grid-row: 1;
  flex: none !important;
  width: var(--html-sidebar-width) !important;
  max-width: var(--html-sidebar-width) !important;
  min-width: 0;
  min-height: 0;
  background-color: #fff;
  border-right: none;
  padding: var(--html-pane-top-gap) 0 var(--html-pane-bottom-gap) 0;
  box-sizing: border-box;
  overflow: hidden;
}

body.theme-onem2m flex-item:has(#TOC):after {
  content: none;
  display: none;
}

body.theme-onem2m #TOC {
  background-color: #fff;
  position: relative !important;
  top: auto !important;
  left: auto !important;
  width: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  height: 100% !important;
  padding-top: 0;
  padding-bottom: 0;
  overflow-y: auto;
  box-sizing: border-box;
  scroll-padding-top: 1rem;
}

body.theme-onem2m #TOC:before {
  content: none;
  display: none;
}

body.theme-onem2m #TOC > ul:first-child {
  display: none;
}

body.theme-onem2m #TOC h1,
body.theme-onem2m #TOC h2#toc-title {
  display: none;
}

body.theme-onem2m #TOC ul {
  background-color: #fff;
  list-style: none !important;
  padding-left: 0;
}

body.theme-onem2m #TOC ul:after {
  content: none;
  display: none;
  background: none;
}

/* Match Material md-nav__link typography */
body.theme-onem2m #TOC a {
  display: block;
  color: var(--html-nav-text-muted);
  font-family: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.375;
  padding: 0.2rem 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

body.theme-onem2m #TOC li {
  list-style: none !important;
  list-style-type: none !important;
  position: relative;
  margin: 0 !important;
  padding: 0 !important;
  padding-inline-start: 0 !important;
}

/* Kill ETSI unicode ▶ / ▼ / • list markers (customCSS.css) */
body.theme-onem2m nav#TOC li::marker,
body.theme-onem2m nav#TOC li:hover::marker,
body.theme-onem2m nav#TOC li.open::marker,
body.theme-onem2m nav#TOC li:not(:has(> ul))::marker {
  content: none !important;
  display: none !important;
  font-size: 0 !important;
}

body.theme-onem2m nav#TOC li:not(:has(> ul)) > a::before {
  content: none !important;
  display: none !important;
}

/* Disable ETSI diff-count tooltip on hover (uses a::before, clashes with chevron) */
body.theme-onem2m nav#TOC a.diff-changes-enable:hover::before {
  content: none !important;
  display: none !important;
}

body.theme-onem2m #TOC li > ul {
  display: none;
  margin-left: 0.5rem;
  border-left: 1px dotted var(--onem2m-line-accent-tr);
  padding-left: 0.35rem;
}

body.theme-onem2m #TOC li.open > ul {
  display: block;
}

/* Material chevron on the link (right), same at every nesting depth */
body.theme-onem2m #TOC li:has(> ul) > a {
  position: relative;
  padding-right: 1.25rem;
}

body.theme-onem2m #TOC li:has(> ul) > a::before {
  content: "";
  position: absolute;
  right: 0.25rem;
  top: 50%;
  width: 0.75rem;
  height: 0.75rem;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.25s ease, background-color 0.25s ease, opacity 0.25s ease;
  background-color: var(--html-nav-text-muted);
  opacity: 0.72;
  pointer-events: none;
  -webkit-mask-image: var(--html-nav-chevron-icon);
  mask-image: var(--html-nav-chevron-icon);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

body.theme-onem2m #TOC a:hover,
body.theme-onem2m #TOC li:hover > a,
body.theme-onem2m #TOC li.active > a:hover {
  color: var(--onem2m-primary);
  background: transparent !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
}

/* Chevron stays static on hover — only link text colour changes */
body.theme-onem2m #TOC li:has(> ul) > a:hover::before {
  background-color: var(--html-nav-text-muted);
  opacity: 0.72;
}

body.theme-onem2m #TOC li.active > a {
  background: transparent !important;
  color: var(--onem2m-primary);
  border-radius: 0 !important;
  padding: 0.2rem 0.35rem;
  padding-right: 1.25rem;
  margin-right: 0 !important;
  font-weight: 500;
}

body.theme-onem2m #TOC li.open:has(> ul) > a::before {
  transform: translateY(-50%) rotate(90deg);
  background-color: var(--onem2m-primary);
  opacity: 1;
}

/* Green diff dot — all depths; chevron stays on ::before */
body.theme-onem2m #TOC a.diff-changes-enable::after {
  content: " ●";
  color: #4caf50;
}

body.theme-onem2m #TOC ul ul > li > a {
  padding-left: 0.15rem;
}

body.theme-onem2m #TOC > ul > li:has(a[href*="intellectual-property-rights.html"]),
body.theme-onem2m #TOC > ul > li:has(a[href*="clause-1.html"]),
body.theme-onem2m #TOC > ul > li:has(a[href*="annex-a.html"]),
body.theme-onem2m #TOC > ul > li:has(a[href*="history.html"]) {
  margin-top: 0.15rem !important;
  padding-top: 0.15rem !important;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

/* Content — md-content column; inset matches md-content__inner */
body.theme-onem2m flex-item.html-layout__content,
body.theme-onem2m flex-item:has(#editor) {
  grid-column: 2;
  grid-row: 1;
  flex: none !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0;
  min-height: 0;
  background-color: #fff;
  padding: var(--html-pane-top-gap) 0 var(--html-pane-bottom-gap) 0;
  box-sizing: border-box;
  overflow: auto;
}

body.theme-onem2m #editor {
  background-color: #fff;
  color: rgba(0, 0, 0, 0.87);
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  /* md-content__inner: margin 0 .8rem 1.2rem; padding-top .6rem; margin-left 1.2rem */
  padding: 0.6rem var(--html-content-inset-right) 2rem var(--html-content-inset-x) !important;
  min-height: 100% !important;
  box-sizing: border-box;
}

body.theme-onem2m #editor h1,
body.theme-onem2m #editor h2,
body.theme-onem2m #editor h3,
body.theme-onem2m #editor h4,
body.theme-onem2m #editor h5,
body.theme-onem2m #editor h6 {
  color: var(--html-content-heading);
  font-family: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
  border-bottom: none;
}

body.theme-onem2m #editor h1 {
  font-size: 1.75rem;
  margin-top: 0.5em;
  padding-top: 0;
  padding-bottom: 0;
}

body.theme-onem2m #editor h2 {
  font-size: 1.25rem;
  margin-top: 1.25em;
  padding-bottom: 0;
}

body.theme-onem2m #editor a {
  color: var(--onem2m-primary);
}

body.theme-onem2m #editor a:hover {
  color: var(--onem2m-primary-dark);
}

body.theme-onem2m table th,
body.theme-onem2m th:has(.TAH),
body.theme-onem2m td:has(.TAH) {
  background-color: var(--onem2m-primary);
}

body.theme-onem2m .TAC strong {
  color: var(--onem2m-primary);
}

/* Diff controls — right edge of md-grid content column */
body.theme-onem2m .diff-visualizer-btn {
  top: calc(var(--html-header-height) + 0.75rem);
  right: max(
    0.8rem,
    calc((100% - var(--html-layout-max-width)) / 2 + var(--html-content-inset-right))
  );
  z-index: 10001;
}

body.theme-onem2m .diff-nav-btn:hover {
  background-color: var(--html-brand-accent);
  color: #fff;
  border-color: var(--html-brand-accent);
}

@media (prefers-color-scheme: dark) {
  body.theme-onem2m {
    --html-content-heading: rgba(255, 255, 255, 0.7);
    --html-nav-text: rgba(255, 255, 255, 0.87);
    --html-nav-text-muted: rgba(255, 255, 255, 0.67);
  }

  body.theme-onem2m flex-item.html-layout__sidebar,
  body.theme-onem2m flex-item:has(#TOC),
  body.theme-onem2m #TOC,
  body.theme-onem2m #TOC ul {
    background: #1e1e1e !important;
  }

  body.theme-onem2m #TOC a {
    color: var(--html-nav-text-muted);
  }

  body.theme-onem2m nav#TOC li::marker,
  body.theme-onem2m nav#TOC li.open::marker {
    content: none !important;
    display: none !important;
  }

  body.theme-onem2m #TOC li.active > a {
    color: var(--onem2m-primary-light);
    background: transparent;
  }

  body.theme-onem2m #editor {
    background-color: #1e1e1e;
    color: var(--html-nav-text);
  }

  body.theme-onem2m .html-theme-footer {
    background-color: #0b0f14;
  }
}
