/* ═══════════════════════════════════════════════════════════════
   TriverseHub · ToolHub — Structure / Layout
   COLORS AND THEMING LIVE IN theme.css — not here.
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & base ───────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  padding-top: var(--header-height);
  transition: background 0.2s, color 0.2s;
  -webkit-font-smoothing: antialiased;
}

body.menu-open {
  overflow: hidden;
}

/* ── Skip link (a11y) ───────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.5rem 1rem;
  background: var(--brand);
  color: var(--brand-text-on);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--brand-soft);
  outline-offset: 2px;
}

/* ── Site header ────────────────────────────────────────────── */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-height);
  z-index: 1000;
  background: linear-gradient(120deg, var(--header-start), var(--header-end));
  color: var(--header-text);
  box-shadow: var(--shadow-header);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 1rem;
}

/* ── Brand ──────────────────────────────────────────────────── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--header-text);
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover,
.brand:focus-visible {
  opacity: 0.9;
  outline: 2px solid rgba(255 255 255 / .6);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.brand-logo {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text-group {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.75;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Header action buttons ──────────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.header-btn {
  border: 0;
  background: var(--header-btn-bg);
  color: var(--header-text);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  touch-action: manipulation;
}

.header-btn:hover,
.header-btn:focus-visible {
  background: var(--header-btn-hover);
  outline: 2px solid rgba(255 255 255 / .5);
  outline-offset: 1px;
}

/* ── Theme toggle ───────────────────────────────────────────── */
.theme-toggle {
  position: relative;
}

.theme-toggle-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  white-space: nowrap;
  color: rgba(255 255 255 / .7);
  pointer-events: none;
  display: none;
}

/* ── Sidebar overlay ────────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--overlay-bg);
  backdrop-filter: blur(2px);
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  max-width: 92vw;
  height: 100dvh;
  z-index: 1001;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  transform: translateX(calc(-1 * var(--sidebar-width)));
  transition: transform 0.25s cubic-bezier(.4, 0, .2, 1);
  padding: 0;
  overflow-y: auto;
  box-shadow: var(--shadow-sidebar);
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(255 255 255 / .07);
  flex-shrink: 0;
}

.sidebar-header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-header-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--sidebar-text);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.75rem 1rem;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-accent);
  padding: 0.65rem 0.35rem 0.3rem;
  margin: 0;
}

.tools-nav-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.tool-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background 0.15s;
  min-height: 44px;
}

.tool-link:hover,
.tool-link:focus-visible {
  background: var(--sidebar-hover);
  outline: none;
}

.tool-link:focus-visible {
  outline: 2px solid var(--sidebar-accent);
  outline-offset: 1px;
}

.tool-link-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.8;
}

.tool-link-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-app-icon {
  color: var(--sidebar-accent);
  font-size: 0.72rem;
  flex-shrink: 0;
}

.tools-empty {
  color: var(--text-muted);
  margin: 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
}

/* ── Main content ───────────────────────────────────────────── */
.content {
  padding: 1.25rem 0 2rem;
  min-height: calc(100dvh - var(--header-height) - 80px);
}

/* ── App card (home wrapper) ────────────────────────────────── */
.app-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ── Sticky toolbar ─────────────────────────────────────────── */
.tools-sticky-bar {
  position: sticky;
  top: calc(var(--header-height) + 0.65rem);
  z-index: 20;
  background: var(--sticky-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.lead-text {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Tools grid ─────────────────────────────────────────────── */
.tools-grid {
  margin-top: 0.8rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ── Tool card ──────────────────────────────────────────────── */
.tool-card {
  display: flex;
  flex-direction: column;
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow 0.18s, transform 0.18s;
}

.tool-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card-app {
  background: linear-gradient(180deg, var(--card-app-bg-start), var(--card-app-bg-end));
  border-color: var(--card-app-border);
}

.tool-card-header {
  padding: 0.9rem 0.9rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.tool-card-body {
  padding: 0.85rem 0.9rem;
  flex: 1;
}

.tool-card-footer {
  padding: 0.75rem 0.9rem 0.9rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.tool-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.25rem;
}

.tool-card h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.tool-meta-label {
  color: var(--text-muted);
  display: inline-block;
  margin-right: 10px;
}

.tool-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-soft);
  line-height: 1.5;
}

/* ── Tool icon ──────────────────────────────────────────────── */
.tool-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 1rem;
  flex-shrink: 0;
}

/* ── Chips & meta ───────────────────────────────────────────── */
.tool-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--chip-text);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
}

.support-meta {
  gap: 0.45rem;
}

.support-label {
  color: var(--text-muted);
  font-weight: 500;
}

.support-icons {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* ── Product badges ─────────────────────────────────────────── */
.product-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  letter-spacing: 0.02em;
}

.product-app {
  background: var(--badge-app-bg);
  color: var(--badge-app-text);
}

.product-tool {
  background: var(--badge-tool-bg);
  color: var(--badge-tool-text);
}

.product-utility {
  background: var(--badge-util-bg);
  color: var(--badge-util-text);
}

/* ── Open button ────────────────────────────────────────────── */
.tool-open-btn {
  font-weight: 600;
  padding: 10px 50px;
  margin: auto;
  border-radius: 15px;
}

/* ── Site footer ────────────────────────────────────────────── */
.site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 1.5rem 0;
  margin-top: 1.5rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--footer-text);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.footer-brand img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #fff;
  padding: 1px;
  object-fit: contain;
}

.footer-copyright {
  margin: 0;
  font-size: 0.82rem;
  opacity: 0.7;
}

.footer-links {
  display: flex;
  gap: 1rem;
  margin-top: 0.15rem;
}

.footer-links a {
  color: var(--footer-text);
  opacity: 0.6;
  font-size: 0.8rem;
  text-decoration: none;
  transition: opacity 0.15s;
}

.footer-links a:hover {
  opacity: 1;
}

/* ── Utility back-bar ───────────────────────────────────────── */
.back-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  min-height: 36px;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--text);
  background: var(--surface-alt);
  outline: none;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .brand-sub {
    display: none;
  }

  .content {
    padding-top: 0.9rem;
    padding-bottom: 1.5rem;
  }

  .tools-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .tool-card {
    min-height: 0;
  }

  .tool-card-footer {
    gap: 0.5rem;
  }

  .tool-open-btn {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

  .tools-sticky-bar {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
  }

  .app-card {
    border-radius: var(--radius-sm);
    padding: 0.75rem;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
  }
}

@media (max-width: 480px) {
  .header-inner {
    padding: 0 0.75rem;
  }

  .brand-name {
    font-size: 0.9rem;
  }
}

/* ── Focus visible global ───────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ── Standalone tool brand bar (for tools without shell) ─────── */
.tool-brand-bar {
  background: linear-gradient(120deg, var(--header-start), var(--header-end));
  color: var(--header-text);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-header);
  position: sticky;
  top: 0;
  z-index: 100;
}

.tool-brand-bar .brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-brand-bar .brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tool-brand-bar .brand-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.tool-brand-bar .tool-page-title {
  font-size: 0.85rem;
  opacity: 0.8;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255 255 255 / .35);
}

.tool-brand-bar .bar-spacer {
  flex: 1;
}

.tool-brand-bar .bar-back {
  font-size: 0.8rem;
  color: rgba(255 255 255 / .85);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: rgba(255 255 255 / .12);
  transition: background 0.15s;
  min-height: 36px;
}

.tool-brand-bar .bar-back:hover {
  background: rgba(255 255 255 / .22);
}

.tool-brand-bar .bar-theme-toggle {
  border: 0;
  background: rgba(255 255 255 / .15);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  touch-action: manipulation;
}

.tool-brand-bar .bar-theme-toggle:hover {
  background: rgba(255 255 255 / .25);
}