/* ----------------------------- */
/* Global Theme & Base Styles    */
/* ----------------------------- */

:root {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* DARK THEME – keep current appearance */
:root[data-theme="dark"] {
  --bg-gradient: radial-gradient(circle at top left, #101124, #050509 60%);
  --accent: #6d7bff;
  --accent-soft: rgba(109, 123, 255, 0.18);
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.1);
  --text: #f4f6ff;
  --text-muted: #9ca4c1;
  --success: #64dbae;
  --warning: #ffd66d;
}

/* LIGHT THEME – similar to reference screenshot */
:root[data-theme="light"] {
  --bg-gradient: #f5f7ff;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --text: #0f172a;
  --text-muted: #6b7280;
  --success: #16a34a;
  --warning: #eab308;
}

:root {
  --sidebar-open-width: clamp(220px, 24vw, 240px);
  --sidebar-closed-width: 72px;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg-gradient);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ----------------------------- */
/* Header, Nav & Top Bar         */
/* ----------------------------- */

header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: 0;
  margin-top: 0;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: var(--text-muted);
  width: 100%;
}

nav.navbar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 24px;
  align-items: center;
}

nav.navbar ul li {
  position: relative;
}

nav.navbar a {
  text-decoration: none;
  color: rgba(244, 246, 255, 0.85);
  font-weight: 600;
  font-size: 15px;
}

nav.navbar a:hover {
  color: #fff;
}

[data-theme="light"] nav.navbar a {
  color: #0f172a;
}

[data-theme="light"] nav.navbar a:hover {
  color: #111827;
}

nav.navbar ul li .dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px 0;
  min-width: 240px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
  z-index: 100;
}

nav.navbar ul li .dropdown a {
  display: block;
  padding: 8px 16px;
  color: #0f172a;
  font-weight: 500;
}

nav.navbar ul li .dropdown a:hover {
  background: #f1f5f9;
  color: #4f46e5;
}

nav.navbar ul li:hover > .dropdown {
  display: block;
}

.caret {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  line-height: 1;
  transition: transform 120ms ease;
}

nav.navbar ul li:hover > a .caret {
  transform: rotate(180deg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.8rem;
  margin-right: auto;
}

.cta-link {
  padding: 0.35rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: #0c0c1a;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 12px 32px -18px rgba(109, 123, 255, 0.8);
  margin-left: 0.8rem;
  cursor: pointer;
}

/* Mobile home logo (hidden by default) */
.mobile-logo-button {
  display: none;
  text-decoration: none;
}

.mobile-logo-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 14px;
  background: linear-gradient(135deg, #8c94ff, #6de3ff);
  color: #0b0b17;
  font-weight: 700;
  font-size: 1rem;
}

/* ----------------------------- */
/* Layout: Sidebar & Page        */
/* ----------------------------- */

.layout {
  display: block;
}

.content {
  display: grid;
  gap: 3rem;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-open-width);
  padding: clamp(0.9rem, 2vh, 1.5rem) clamp(0.7rem, 1.2vw, 1rem) clamp(1rem, 2vh, 1.8rem);
  background: rgba(12, 13, 28, 0.92);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: clamp(0.6rem, 1.2vh, 0.9rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.page {
  width: calc(100vw - var(--sidebar-open-width));
  max-width: 100vw;
  margin-left: var(--sidebar-open-width);
  padding: clamp(0.5rem, 2.5vw, 1.5rem) clamp(1.4rem, 4vw, 2.4rem) clamp(3rem, 6vw, 3.8rem);
  display: flex;
  flex-direction: column;
  gap: clamp(2.2rem, 4vw, 3rem);
  box-sizing: border-box;
}

/* ----------------------------- */
/* Sidebar Branding & Items      */
/* ----------------------------- */

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: clamp(0.45rem, 1vh, 0.7rem);
  outline: none;
  border: none;
}

.sidebar-logo:focus-visible {
  outline: none;
  box-shadow: none;
}

.sidebar-logo-mark {
  display: grid;
  place-items: center;
  width: clamp(32px, 3.6vh, 40px);
  height: clamp(32px, 3.6vh, 40px);
  border-radius: 12px;
  background: linear-gradient(135deg, #8c94ff, #6de3ff);
  color: #0b0b17;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sidebar-logo-title {
  margin: 0;
  font-size: clamp(0.88rem, 1.9vh, 1rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sidebar-section-top-links {
  display: none;
}

.sidebar-top-links {
  list-style: none;
  margin: 0 0 0.5rem 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}

.sidebar-top-links a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.sidebar-top-links a:hover,
.sidebar-top-links a:focus-visible {
  background: var(--surface-strong);
  outline: none;
}

.sidebar-section + .sidebar-section {
  margin-top: clamp(0.35rem, 1.1vh, 0.6rem);
}

.sidebar-title {
  margin: 0 0 clamp(0.28rem, 0.8vh, 0.45rem) 0;
  font-size: clamp(0.72rem, 1.6vh, 0.82rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-list {
  display: grid;
  gap: clamp(0.15rem, 0.6vh, 0.28rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-list li {
  margin: 0;
  padding: 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: clamp(0.3rem, 0.8vh, 0.5rem);
  padding: clamp(0.3rem, 1vh, 0.45rem) clamp(0.4rem, 1vh, 0.55rem);
  border-radius: 11px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-item:hover,
.sidebar-item:focus-visible {
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}

.sidebar-item.active {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid rgba(109, 123, 255, 0.4);
}

body:not(.sidebar-open) .sidebar {
  width: var(--sidebar-closed-width);
  padding-inline: 0.6rem;
}

body:not(.sidebar-open) .sidebar-title,
body:not(.sidebar-open) .sidebar-label {
  display: none;
}

body:not(.sidebar-open) .sidebar-item {
  justify-content: center;
  padding-inline: 0.5rem;
}

body:not(.sidebar-open) .sidebar-item .sidebar-icon {
  margin-right: 0;
}

body:not(.sidebar-open) .sidebar-logo {
  justify-content: center;
  gap: 0;
  padding-inline: 0;
}

body:not(.sidebar-open) .sidebar-logo-title {
  display: none;
}

/* optional if you re-add .sidebar-logo-text wrapper */
body:not(.sidebar-open) .sidebar-logo-text {
  display: none;
}

body.sidebar-open .sidebar {
  width: var(--sidebar-open-width);
}

body.sidebar-open .page {
  margin-left: var(--sidebar-open-width);
  width: calc(100vw - var(--sidebar-open-width));
}

body:not(.sidebar-open) .page {
  margin-left: var(--sidebar-closed-width);
  width: calc(100vw - var(--sidebar-closed-width));
}

/* On smaller screens, make the page full-width and remove left offset */
@media (max-width: 1024px) {
  body.sidebar-open .page,
  body:not(.sidebar-open) .page,
  .page {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

.sidebar-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.sidebar-item.active .sidebar-icon {
  background: rgba(109, 123, 255, 0.35);
  border-color: rgba(109, 123, 255, 0.5);
  color: #ffffff;
}

[data-theme="light"] .sidebar-icon {
  background: #eef2ff;
  border: 1px solid #d5daf0;
  color: #0f172a;
}

[data-theme="light"] .sidebar-item.active .sidebar-icon {
  background: #dce4ff;
  border-color: #cdd7ff;
  color: #0f172a;
}

.sidebar-label {
  flex: 1;
  font-size: clamp(0.7rem, 1.6vh, 0.85rem);
  letter-spacing: 0.01em;
}

.sidebar-icon svg {
  width: clamp(12px, 1.8vh, 16px);
  height: clamp(12px, 1.8vh, 16px);
}

.sidebar-icon svg path,
.sidebar-icon svg polygon,
.sidebar-icon svg rect,
.sidebar-icon svg circle,
.sidebar-icon svg polyline {
  fill: currentColor;
}

.sidebar-icon svg .stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-chevron {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sidebar-toggle {
  display: none; /* hidden by default */
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  background: transparent;
  cursor: pointer;
  margin-right: 0.75rem;
  padding: 0;
}

.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.sidebar-toggle span + span {
  margin-top: 4px;
}

body.sidebar-open .sidebar-toggle span:nth-child(1) {
  transform: translateY(0);
  width: 14px;
  opacity: 1;
}

body.sidebar-open .sidebar-toggle span:nth-child(2) {
  opacity: 1;
  transform: translateY(0);
  width: 18px;
}

body.sidebar-open .sidebar-toggle span:nth-child(3) {
  transform: translateY(0);
  width: 14px;
  opacity: 1;
}

@media (min-width: 1025px) {
  .sidebar-toggle {
    display: inline-flex;
  }
}

.desktop-sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  margin-right: 1rem;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.desktop-sidebar-toggle span {
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  margin: 3px 0;
}

@media (min-width: 769px) {
  .desktop-sidebar-toggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  .desktop-sidebar-toggle {
    display: none;
  }
}

/* ----------------------------- */
/* Hero & Search Bar             */
/* ----------------------------- */

.hero {
  display: grid;
  gap: 2.3rem;
}

.hero-title {
  font-size: clamp(1.8rem, 3vw + 0.8rem, 2.8rem);
  line-height: 1.05;
  max-width: 32ch;
}

.hero-title span {
  background: linear-gradient(120deg, #7b83ff, #55f3ff);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  max-width: 70ch;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.search-bar {
  display: flex;
  gap: 0;
  padding: 0;
  border-radius: 14px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 260px;
  width: clamp(260px, 48vw, 420px);
  margin-left: auto;
  margin-right: 1rem;
  overflow: hidden;
}

.search-bar input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.6rem 0.8rem;
}

.search-bar button {
  padding: 0.35rem 0.7rem 0.35rem 0.5rem;
  border-radius: 0;
  border: none;
  font-weight: 700;
  color: #0b0b17;
  background: linear-gradient(135deg, #7f89ff, #69e9ff);
  cursor: pointer;
  transition: transform 0.22s ease;
  font-size: 1rem;
}

.search-bar button:hover {
  transform: translateY(-1px);
}

/* ----------------------------- */
/* Section Headings & Filters    */
/* ----------------------------- */

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: -0.01em;
}

.section-heading a {
  font-size: 0.9rem;
  color: var(--accent);
}

.tools-section {
  margin-block: clamp(2rem, 5vw, 3rem);
  display: grid;
  gap: 1.2rem;
}

.filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters select {
  min-width: 170px;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.filters select option {
  background: #0d0f1d;
  color: #f4f6ff;
}

.filters select:focus-visible {
  outline: 2px solid var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ----------------------------- */
/* Tools Grid & Cards            */
/* ----------------------------- */

.tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

/* Base card layout */
.tool-card {
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tool-card.horizontal {
  width: 259px;
  height: 70px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 10px;
  gap: 10px;
  box-sizing: border-box;
}

.tool-card.horizontal::after {
  content: none;
}

.tool-card.horizontal:hover,
.tool-card.horizontal:focus-visible {
  background: rgba(255, 255, 255, 0.10);
  outline: none;
}

.tool-card.horizontal img.tool-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.tool-card.horizontal .tool-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.tool-card.horizontal .tool-info p {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: #555;
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- Light theme overrides ---------- */

[data-theme="light"] body {
  background: var(--bg-gradient);
  color: var(--text);
}

/* Sidebar: white card style with subtle border */
[data-theme="light"] .sidebar {
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
}

/* Main page background */
[data-theme="light"] .page {
  background: #f5f7ff;
}

/* Cards and surfaces */
[data-theme="light"] .tool-card,
[data-theme="light"] .directory-card,
[data-theme="light"] .featured-card {
  background: #ffffff;
  border-color: #e5e7eb;
}

[data-theme="light"] .tool-card:hover,
[data-theme="light"] .directory-card:hover,
[data-theme="light"] .featured-card:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

/* Search bar */
[data-theme="light"] .search-bar {
  background: #ffffff;
  border-color: #e5e7eb;
}

[data-theme="light"] .filters select {
  border: 1px solid #d1d5db;
  box-shadow: 0 0 0 1px #e5e7eb;
  background: #ffffff;
  color: #0f172a;
}

[data-theme="light"] .filters select option {
  background: #ffffff;
  color: #0f172a;
}

/* CTA block */
[data-theme="light"] .cta {
  background: linear-gradient(120deg, #e0e7ff, #cffafe);
  border-color: #c7d2fe;
}

/* Footer */
[data-theme="light"] footer {
  border-top-color: #e5e7eb;
  color: var(--text-muted);
}

/* Theme toggle button */
.theme-toggle {
  margin-left: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

[data-theme="light"] .theme-toggle {
  border-color: #e5e7eb;
  background: #ffffff;
  color: #0f172a;
}

.tool-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* When card is open, show full content */
.tool-card.open .tool-desc,
.tool-card.open .tool-link {
  display: block;
}

/* Keep link at the bottom of the card */
.tool-link {
  color: var(--accent);
  font-weight: 600;
  margin-top: auto;
}

/* Optional tag chips on cards */
.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tool-tags span {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ----------------------------- */
/* Featured Tiles & Directory    */
/* ----------------------------- */

.featured-section {
  margin-top: 1.5rem;
}

.featured-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.featured-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 259px;
  height: 70px;
  padding: 10px;
  box-sizing: border-box;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.section-anchor {
  display: block;
  position: relative;
  top: -80px;
  height: 0;
}

.featured-card .featured-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 700;
  overflow: hidden;
}

.featured-card .featured-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.featured-card .featured-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.featured-card .featured-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 12px;
  opacity: 0.8;
}

.tools-title {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 1.8rem);
}

.directory-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.home-widget-group {
  margin-top: 2.5rem;
  display: grid;
  gap: 1.2rem;
}

.home-widget-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.home-widget-card {
  flex: 0 0 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-decoration: none;
  color: inherit;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.home-widget-card:hover,
.home-widget-card:focus-visible {
  background: var(--surface-strong);
  border-color: rgba(109, 123, 255, 0.45);
  transform: translateY(-1px);
  outline: none;
}

.home-widget-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, #8c94ff, #6de3ff);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #050509;
  flex-shrink: 0;
}

.home-widget-banner {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-strong);
  flex-shrink: 0;
}

.home-widget-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-widget-text h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.home-widget-text p {
  margin: 2px 0 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.home-widget-card {
  flex: 0 0 100%;
  max-width: 100%;
}

@media (min-width: 640px) {
  .home-widget-card {
    flex: 0 0 calc(50% - 0.5rem);
    max-width: calc(50% - 0.5rem);
  }
}

.directory-card {
  padding: 0;
  border: none;
  background: transparent;
  min-height: unset;
}

.directory-desc {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-muted);
  line-clamp: 3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.directory-meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.directory-actions {
  margin-top: 0.6rem;
  display: flex;
  justify-content: flex-end;
}

.directory-card .directory-cta {
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  background: var(--accent);
  border: none;
  color: #050509;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
  transition: transform 0.15s ease;
}

.directory-card .directory-cta:hover,
.directory-card .directory-cta:focus-visible {
  transform: translateY(-1px);
}

.directory-taglist {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.directory-tag {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.tools-error {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ----------------------------- */
/* Badges & CTA Blocks           */
/* ----------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(100, 219, 174, 0.18);
  color: var(--success);
}

.cta {
  padding: clamp(2rem, 6vw, 3.4rem);
  border-radius: 28px;
  background: linear-gradient(120deg, rgba(125, 138, 255, 0.18), rgba(74, 197, 255, 0.22));
  border: 1px solid rgba(145, 164, 255, 0.32);
  display: grid;
  gap: 1.2rem;
}

.cta h3 {
  margin: 0;
  font-size: clamp(1.8rem, 1.2rem + 1vw, 2.2rem);
}

.cta p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.cta button {
  justify-self: start;
  padding: 0.85rem 1.7rem;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  color: #050509;
  background: #f7f9ff;
}

/* ----------------------------- */
/* Footer                        */
/* ----------------------------- */

footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 0.85rem;
}

footer nav {
  display: flex;
  gap: 1.2rem;
  font-size: 0.85rem;
}

/* ----------------------------- */
/* Responsive Layout Tweaks      */
/* ----------------------------- */

@media (max-width: 1024px) {
  .layout {
    display: block;
  }

  .sidebar-logo-title {
    white-space: normal;
  }

  .page {
    margin-left: 0;
    width: 100vw;
    max-width: 100vw;
    padding: 1.8rem clamp(1rem, 6vw, 1.6rem) 3.2rem clamp(1rem, 6vw, 1.6rem);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    max-width: 92vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 50;
  }

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

  .sidebar::after {
    content: "";
    position: fixed;
    inset: 0;
    left: min(86vw, 320px);
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

.sidebar.open::after {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 780px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  nav {
    flex-wrap: wrap;
    gap: 1.1rem;
  }

  .hero {
    gap: 1.6rem;
  }

  .stats {
    gap: 1rem;
  }
}

/* ----------------------------- */
/* Accessibility & Motion        */
/* ----------------------------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

nav[aria-label="Primary"] a:focus-visible,
.cta-link:focus-visible,
.search-bar button:focus-visible {
  outline: 2px solid var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Mobile perf: avoid fixed backgrounds on iOS */
@media (max-width: 780px) {
  body {
    background-attachment: scroll;
  }
}

/* Slightly stronger tag chips for contrast */
.tool-tags span {
  background: rgba(255, 255, 255, 0.1);
}

/* Category pill pressed state */
.category-pill[aria-pressed="true"] {
  border-color: rgba(109, 123, 255, 0.6);
  color: var(--text);
}

/* ----------------------------- */
/* Modals & Submit Tool Form     */
/* ----------------------------- */

/* Tool quick-view modal */
.tool-modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 2rem;
  z-index: 200;
}

.tool-modal[aria-hidden="false"] {
  display: grid;
}

.tool-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

/* Submit tool modal */
.submit-modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: clamp(1rem, 4vw, 2rem);
  z-index: 220;
}

.submit-modal[aria-hidden="false"] {
  display: grid;
}

.submit-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.submit-modal-dialog {
  position: relative;
  width: min(560px, 95vw);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 13, 28, 0.97);
  padding: clamp(1.5rem, 4vw, 2.2rem);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.75);
}

.submit-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.submit-modal-body {
  display: grid;
  gap: 1rem;
}

.submit-modal-body h3 {
  margin: 0;
  font-size: 1.6rem;
}

.submit-modal-body p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.submit-form {
  display: grid;
  gap: 1rem;
  margin-top: 0.5rem;
}

.submit-field {
  display: grid;
  gap: 0.35rem;
}

.submit-field label {
  font-size: 0.9rem;
  font-weight: 600;
}

.submit-field input,
.submit-field textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  resize: vertical;
  min-height: 48px;
}

.submit-field textarea {
  min-height: 120px;
}

.submit-field input:focus,
.submit-field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.submit-btn {
  justify-self: start;
  min-width: 160px;
}

.submit-status {
  min-height: 1.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.submit-status.success {
  color: var(--success);
}

.submit-status.error {
  color: #ff8f8f;
}

/* Tool modal content */

.tool-modal-dialog {
  position: relative;
  max-width: min(840px, 92vw);
  width: 100%;
  background: rgba(16, 17, 36, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: clamp(1.2rem, 2vw, 2rem);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.7);
  display: grid;
  gap: 1rem;
}

.tool-modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}

.modal-hero {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.modal-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  overflow: hidden;
}

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

.modal-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.modal-sub {
  margin: 0.15rem 0 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.modal-section h4 {
  margin: 0.8rem 0 0.4rem 0;
}

.modal-section p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip {
  font-size: 0.75rem;
  padding: 0.18rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.btn {
  padding: 0.55rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #050509;
}

@media (max-width: 640px) {
  .tool-modal {
    padding: 1rem;
  }

  .tool-modal-dialog {
    border-radius: 18px;
  }
}


    .tool-logo {
      width: 60px;
      height: 60px;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      border-radius: 12px;
    }

.tool-logo img {
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
      object-position: center;
      display: block;
    }

/* Hide mobile nav by default on desktop */
.mobile-nav-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  background: transparent;
  cursor: pointer;
  margin-right: 0.75rem;
  padding: 0;
}

.mobile-nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.mobile-nav-toggle span + span {
  margin-top: 4px;
}

/* X animation when open */
body.mobile-nav-open .mobile-nav-toggle span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
body.mobile-nav-open .mobile-nav-toggle span:nth-child(2) {
  opacity: 0;
}
body.mobile-nav-open .mobile-nav-toggle span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile nav overlay & panel */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 80;
}

body.mobile-nav-open .mobile-nav-overlay {
  display: block;
}

.mobile-nav-panel {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(320px, 82vw);
  background: rgba(12, 13, 28, 0.98);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  padding: 1.2rem 1.3rem;
  display: grid;
  gap: 1.2rem;
  overflow-y: auto;
}

/* Sections inside mobile nav */
.mobile-nav-section {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.9rem;
}

.mobile-nav-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.mobile-nav-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.mobile-nav-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-nav-section li + li {
  margin-top: 0.35rem;
}

.mobile-nav-section a,
.mobile-nav-section button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.mobile-nav-section button.sidebar-item {
  display: flex;
  align-items: center;
  gap: clamp(0.3rem, 0.8vh, 0.5rem);
  padding: clamp(0.3rem, 1vh, 0.45rem) clamp(0.4rem, 1vh, 0.55rem);
}

.mobile-nav-section button.sidebar-item.active {
  border-radius: 11px;
}

.mobile-nav-section a:hover,
.mobile-nav-section a:focus-visible,
.mobile-nav-section button:hover,
.mobile-nav-section button:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

/* 2 cards per row on small screens */
@media (max-width: 800px) {
  .featured-grid .featured-card,
  .directory-grid .directory-card,
  .tool-grid .tool-card {
    flex: 0 0 calc(50% - 0.5rem);
    max-width: calc(50% - 0.5rem);
  }
}

/* Light theme tweaks for mobile nav */
[data-theme="light"] .mobile-nav-panel {
  background: #ffffff;
  border-right-color: #e5e7eb;
}

[data-theme="light"] .mobile-nav-section h3 {
  color: #6b7280;
}

[data-theme="light"] .mobile-nav-section a,
[data-theme="light"] .mobile-nav-section button {
  color: #0f172a;
}

[data-theme="light"] .mobile-nav-section a:hover,
[data-theme="light"] .mobile-nav-section button:hover {
  background: #f3f4f6;
}

/* MOBILE: layout behavior */
@media (max-width: 768px) {
  /* header uses rows + wrap; children decide rows via flex-basis + order */
  header {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
  }

  /* Row 1: logo on left, burger on right */
  nav.navbar {
    order: 1;
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  nav.navbar ul {
    display: none; /* hide desktop links */
  }

  .mobile-logo-button {
    display: inline-flex;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }

  /* Row 2: full-width search bar */
  .search-bar {
    order: 2;
    flex: 0 0 100%;
    width: 100%;
    margin: 0;
  }

  /* Row 3: Submit Tool + theme toggle on same row */
  .cta-link {
    order: 3;
    flex: 1 1 auto;
    display: inline-flex;
    justify-content: center;
    margin-left: 0;
  }

  .theme-toggle {
    order: 4;
    flex: 0 0 auto;
    margin-left: 0.75rem;
    position: static;
  }

  /* hide sidebar on mobile, page full-width */
  .sidebar {
    display: none !important;
  }

  .page {
    margin-left: 0;
    width: 100vw;
    max-width: 100vw;
    padding: 1.4rem clamp(1rem, 6vw, 1.6rem) 3.2rem clamp(1rem, 6vw, 1.6rem);
  }

  .hero {
    gap: 1.6rem;
  }

  .stats {
    gap: 1rem;
  }
}

/* DESKTOP / TABLET: show normal nav & sidebar, hide mobile overlay */
@media (min-width: 769px) {
  nav.navbar ul {
    display: flex;
  }

  .mobile-nav-toggle {
    display: none;
  }

  .mobile-nav-overlay {
    display: none !important;
  }

  .sidebar {
    display: flex;
  }
}
