:root {
  --header-height: 64px;
}

/* HEADER / TOPNAV */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;

  height: var(--header-height, 72px);
  background: var(--surface);
  color: var(--on-surface);

  z-index: 1000;

  display: flex;
  align-items: center;
}

.site-header.header--visible {
  transform: translateY(0);
}

.site-header.header--hidden {
  transform: translateY(-100%);
}

body {
  padding-top: var(--header-height, 72px);
}

.top-app-bar {
  width: 100%;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  padding-inline: var(--space-3, 1rem);
  box-sizing: border-box;
}

/* LOGO */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  margin-right: 0.25rem;
  border-radius: 999px;
  text-decoration: none;

  font-family: var(--logo);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: calc(var(--type-scale-base) * 0.875);

  color: var(--on-surface);
  white-space: nowrap;
}

.logo:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 999px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: calc(var(--type-scale-base) * 0.9);
  font-weight: 600;

  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--on-primary-container);
}

.logo-text {
  line-height: 1;
}

/* DESKTOP TOPNAV */
.topnav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0.75rem 1rem;
  border-radius: 999px;

  font-family: var(--body);
  font-size: calc(var(--type-scale-base) * 0.875);
  font-weight: var(--weight-medium);
  letter-spacing: 0.1px;

  color: var(--on-surface);
  text-decoration: none;

  transition: background .2s ease, color .2s ease;
  white-space: nowrap;
}

.topnav a:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.topnav a.active {
  background: var(--primary);
  color: var(--on-primary);
}

/* THEME BUTTON */
.theme-switch {
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 999px;
  border: none;
  background: transparent;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  color: var(--on-surface-variant);
  transition: background .2s ease, color .2s ease;
}

.theme-switch:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

/* MENU TOGGLE (SIDEBAR) */
.menu-toggle {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--on-surface);
}

.menu-toggle:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

@media (min-width: 900px) {
  .menu-toggle {
    display: none;
  }
}


/* SECTION SWITCHER */
.section-switcher {
  display: none;
}

.section-switcher__btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;

  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--outline-variant) 55%, transparent);

  background: color-mix(in srgb, var(--surface-container) 85%, var(--surface) 15%);
  color: var(--on-surface);

  font-family: var(--body);
  font-size: calc(var(--type-scale-base) * 0.875);
  font-weight: var(--weight-medium);
  letter-spacing: 0.1px;

  cursor: pointer;
}

.section-switcher__btn:hover {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}

.section-switcher__btn .section-switcher__caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.section-switcher__panel {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--header-height, 64px);

  z-index: 90;
  display: none;

  background: var(--surface);
  color: var(--on-surface);

  box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;

  max-height: calc(100vh - var(--header-height, 64px));
  overflow: auto;
}

.section-switcher__panel.is-open {
  display: block;
}

.section-switcher__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0.85rem 1rem 0.5rem 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--outline-variant) 45%, transparent);
}

.section-switcher__panel-title {
  font-size: calc(var(--type-scale-base) * 0.8);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-surface-variant, var(--on-surface));
}

.section-switcher__close {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--on-surface);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.section-switcher__close:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.section-switcher__list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.75rem 1rem 0.75rem;
}

.section-switcher__item {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;

  padding: 0.85rem 1rem;
  border-radius: 14px;
  text-decoration: none;

  background: transparent;
  color: var(--on-surface);
  border: 1px solid transparent;

  font-family: var(--body);
  font-size: calc(var(--type-scale-base) * 0.95);
  font-weight: var(--weight-medium);
}

.section-switcher__item:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.section-switcher__item.is-active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border-color: color-mix(in srgb, var(--primary) 22%, transparent);
}

@media (max-width: 600px) {
  .topnav {
    display: none;
  }

  .section-switcher {
    display: block;
    flex: 1;
    min-width: 0;
  }
}

@media (max-width: 900px) {
  .topnav {
    display: none;
  }

  .section-switcher {
    display: block;
    flex: 1;
    min-width: 0;
  }
}

.top-app-bar { min-width: 0; }
.logo { min-width: 0; max-width: 100%; }
.logo-text { overflow: hidden; text-overflow: ellipsis; }

/* HEADER CONTROLS */
.header-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* TYPE STEPPER — controles diretos A− / A+ */
.type-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--outline-variant) 58%, transparent);
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-container) 78%, var(--surface) 22%);
}

.type-stepper__button {
  min-width: 42px;
  height: 38px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--on-surface);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-family: var(--body);
  font-size: calc(var(--type-scale-base) * .83);
  font-weight: 700;
  line-height: 1;
  transition: background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.type-stepper__button + .type-stepper__button {
  border-left: 1px solid color-mix(in srgb, var(--outline-variant) 58%, transparent);
}

.type-stepper__button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  color: var(--primary);
}

.type-stepper__button:active:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 15%, var(--surface));
}

.type-stepper__button:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.type-stepper__button:disabled {
  opacity: .36;
  cursor: not-allowed;
}

.type-stepper__button--decrease span { font-size: calc(var(--type-scale-base) * .78); }
.type-stepper__button--increase span { font-size: calc(var(--type-scale-base) * .94); }

/* PALETTE PICKER — indicador editorial + amostras circulares */
.palette-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.palette-picker__trigger {
  position: relative;
  width: 58px;
  height: 38px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--outline-variant) 58%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-container) 78%, var(--surface) 22%);
  color: var(--on-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.palette-picker__trigger:hover {
  border-color: color-mix(in srgb, var(--primary) 44%, var(--outline-variant));
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
}

.palette-picker__trigger:active {
  transform: scale(.97);
}

.palette-picker__trigger:focus-visible,
.palette-picker__option:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.palette-picker__editorial-line {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  height: 1px;
  background: color-mix(in srgb, var(--outline-variant) 78%, transparent);
}

.palette-picker__editorial-line::before {
  content: "";
  display: block;
  width: 17px;
  height: 2px;
  transform: translateY(-.5px);
  background: var(--primary);
}

.palette-picker__preview {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  transform: translateY(-4px);
}

.palette-picker__preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--surface) 72%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--outline-variant) 38%, transparent);
}

.palette-picker__preview-dot--primary { background: var(--primary); }
.palette-picker__preview-dot--secondary { background: var(--secondary); }
.palette-picker__preview-dot--tertiary { background: var(--tertiary); }

.palette-picker__menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 1200;
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 7px;
  border: 1px solid color-mix(in srgb, var(--outline-variant) 58%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-container) 94%, var(--surface) 6%);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .16);
}

.palette-picker__menu[hidden] {
  display: none;
}

.palette-picker__option {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.palette-picker__option > span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: hsl(var(--palette-h) 58% 47%);
  box-shadow:
    inset -6px 0 0 hsl(calc(var(--palette-h) + 34) 45% 58%),
    0 0 0 1px color-mix(in srgb, var(--outline-variant) 48%, transparent);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.palette-picker__option:hover > span {
  transform: scale(1.13);
}

.palette-picker__option[aria-checked="true"] > span {
  box-shadow:
    inset -6px 0 0 hsl(calc(var(--palette-h) + 34) 45% 58%),
    0 0 0 3px var(--surface),
    0 0 0 5px var(--on-surface);
}

@media (max-width: 520px) {
  .palette-picker__trigger,
  .type-stepper__button {
    width: 46px;
    height: 36px;
    padding-inline: 7px;
  }

  .palette-picker__editorial-line {
    left: 8px;
    right: 8px;
  }

  .header-controls { gap: .3rem; }

  .palette-picker__menu {
    position: fixed;
    top: calc(var(--header-height, 64px) + 8px);
    right: 8px;
  }
}

@media (max-width: 390px) {
  .logo-text { display: none; }
  .top-app-bar { padding-inline: .5rem; gap: .25rem; }
  .theme-switch { padding: .4rem; }
}
