/* Shared tools header – dimensions, grid, spacing, and controls match games/shared/header.css. */
.shared-tools-header,
.shared-tools-header * { box-sizing: border-box; }

.shared-tools-header {
  position: relative; /* Tools use normal document flow; the games header uses a spacer. */
  z-index: 120;
  flex: 0 0 auto;
  width: 100%;
  background: #ffffffe6;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 4px solid #38bdf8;
  box-shadow: 0 1px 3px #0f172a1a;
  color: #0f172a;
  font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif;
}
:root[data-theme="dark"] .shared-tools-header {
  background: rgba(15, 23, 42, .9);
  color: #f1f5fc;
}

.shared-tools-header .sth-nav {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,auto) minmax(0,1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 1600px;
  margin-inline: auto;
  padding: 5px 16px;
}
.shared-tools-header a { color: inherit; text-decoration: none; }

/* Identical brand sizing and logo-button treatment to the games header. */
.shared-tools-header .sth-brand,
.shared-tools-header .sth-controls {
  display: flex;
  align-items: center;
}
.shared-tools-header .sth-brand {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  min-width: 0;
  gap: 8px;
}
.shared-tools-header .sth-brand > .sth-brand-link {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 138px;
  width: 138px;
  height: 46px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease, background-color .18s ease;
}
.shared-tools-header .sth-brand picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.shared-tools-header .sth-banner {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
}
.shared-tools-header .sth-brand > .sth-brand-link:hover { filter: brightness(.97); }
@media (hover: hover) and (pointer: fine) {
  .shared-tools-header .sth-brand > .sth-brand-link:hover {
    transform: translateY(-2px);
    filter: brightness(1.025);
    box-shadow: 0 4px 12px rgba(3,105,161,.17);
  }
}
.shared-tools-header .sth-brand > .sth-brand-link:active { transform: translateY(0) scale(.98); }

/* The title is centered in its own grid cell, and only the text is clickable. */
.shared-tools-header .sth-title-link {
  grid-column: 2;
  grid-row: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  justify-self: center;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
  padding: 0 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: center;
  overflow: hidden;
}
.shared-tools-header .sth-tool-title {
  display: block;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: inherit;
  font-family: inherit;
  font-size: clamp(12px, 2.7vh, 23px);
  font-weight: 750;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateY(4px);
}

.shared-tools-header .sth-controls {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  justify-content: flex-end;
  min-width: 0;
  gap: 8px;
}
.shared-tools-header .icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid #bae6fd;
  border-radius: 50%;
  background: #fff;
  color: #0369a1;
  font: 600 18px/1 sans-serif;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}
.shared-tools-header .icon-button:hover { background: #e0f2fe; }
.shared-tools-header .icon-button svg {
  display: block;
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.shared-tools-header a:focus-visible,
.shared-tools-header button:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 3px;
}

/* Match the games header's tablet / desktop logo sizes and spacing. */
@media (max-width: 899px) {
  .shared-tools-header .sth-nav {
    grid-template-columns: max-content minmax(0,1fr) max-content;
  }
}
@media (min-width: 640px) and (max-width: 899px) {
  .shared-tools-header .sth-brand { gap: 6px; }
  .shared-tools-header .sth-brand > .sth-brand-link {
    flex-basis: clamp(100px, 15vw, 134px);
    width: clamp(100px, 15vw, 134px);
    height: 44px;
  }
}
@media (max-width: 639px) {
  .shared-tools-header .sth-nav { gap: 4px; padding: 4px 5px; }
  .shared-tools-header .sth-brand { gap: 3px; }
  .shared-tools-header .sth-brand > .sth-brand-link {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
    border: 1px solid #bae6fd;
    border-radius: 50%;
    background: #fff;
    overflow: hidden;
  }
  .shared-tools-header .sth-banner { width: 32px; height: 32px; }
  .shared-tools-header .sth-title-link { min-height: 36px; padding: 0 2px; }
  .shared-tools-header .sth-tool-title { font-size: clamp(12px, 2.7vh, 21px); }
  .shared-tools-header .sth-controls { gap: 3px; }
  .shared-tools-header .icon-button {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }
  .shared-tools-header .icon-button svg { width: 19px; height: 19px; }
}
@media (max-width: 360px) {
  .shared-tools-header .sth-nav { gap: 2px; padding-inline: 3px; }
  .shared-tools-header .icon-button { flex-basis: 32px; width: 32px; height: 32px; }
}
@media (min-width: 1600px) and (min-height: 850px) {
  .shared-tools-header .sth-nav { max-width: 90vw; }
  .shared-tools-header .sth-brand > .sth-brand-link {
    flex-basis: 156px; width: 156px; height: 52px;
  }
  .shared-tools-header .icon-button { flex-basis: 48px; width: 48px; height: 48px; }
  .shared-tools-header .icon-button svg { width: 25px; height: 25px; }
}

/* Existing centralized fullscreen and lowered exit control are retained. */
:root.tools-is-fullscreen { --shared-header-height: 0px !important; }
:root.tools-is-fullscreen .shared-tools-header { display: none !important; }
.tools-fullscreen-exit {
  position: fixed !important;
  top: max(64px, calc(env(safe-area-inset-top) + 52px)) !important;
  right: max(12px, env(safe-area-inset-right)) !important;
  z-index: 2147483000 !important;
  display: grid !important;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #bae6fd;
  border-radius: 50%;
  background: #fff;
  color: #0369a1;
  box-shadow: 0 5px 18px rgba(15,23,42,.2);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s ease, box-shadow .15s ease;
}
.tools-fullscreen-exit[hidden] { display: none !important; }
.tools-fullscreen-exit:hover { background: #e0f2fe; box-shadow: 0 6px 20px rgba(15,23,42,.25); }
.tools-fullscreen-exit:focus-visible { outline: 3px solid #38bdf8; outline-offset: 3px; }
.tools-fullscreen-exit svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (max-width: 639px) {
  .tools-fullscreen-exit {
    top: max(56px, calc(env(safe-area-inset-top) + 48px)) !important;
    right: max(8px, env(safe-area-inset-right)) !important;
    width: 40px;
    height: 40px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .shared-tools-header .sth-brand > .sth-brand-link { transition: none; }
  .tools-fullscreen-exit { transition: none; }
}

/* Expanded mode must not lock page scrolling; keep the exit target accessible. */
.app-is-expanded .tools-fullscreen-exit { width: 44px; height: 44px; }
