/* ============================================================
   OpenEmbedWorks - Main Stylesheet
   File: assets/css/style.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #f6f8fb;
  --color-surface: #ffffff;
  --color-border: #dbe5f0;
  --color-primary: #0f6cbd;
  --color-primary-dark: #0d4f8a;
  --color-accent: #f59e0b;
  --color-text: #10243e;
  --color-muted: #5f7087;
  --color-footer-bg: #10243e;
  --color-footer-text: #d6deea;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 10px 26px rgba(0, 0, 0, .11);

  --radius-sm: 8px;
  --radius-md: 14px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --max-width: 1220px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at 10% -20%, #dbeafe, transparent 45%),
              radial-gradient(circle at 100% 0%, #fef3c7, transparent 32%),
              var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: 1.2rem;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text);
}

.nav-brand:hover { text-decoration: none; }
.nav-brand svg { color: var(--color-primary); }

.nav-logo {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 6px;
}

.nav-links {
  display: flex;
  gap: 1.7rem;
  list-style: none;
}

.nav-links a {
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-muted);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--color-primary);
  text-decoration: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  cursor: pointer;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

/* Show moon in light mode, sun in dark mode */
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.hero {
  background: linear-gradient(132deg, #0b335b 0%, #10243e 55%, #1b3657 100%);
  color: #fff;
  padding: 4.6rem 0 3.8rem;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 999px;
  padding: .33rem .9rem;
  font-size: .80rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  color: #dbeafe;
}

.hero h1 {
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: .85rem;
}

.hero h1 span { color: #93c5fd; }

.hero p {
  font-size: 1.03rem;
  color: #bfdbfe;
  max-width: 700px;
  margin: 0 auto 1.8rem;
}

.hero-actions {
  display: flex;
  gap: .85rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .64rem 1.35rem;
  border-radius: var(--radius-sm);
  font-size: .92rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-accent);
  color: #13233a;
}

.btn-primary:hover {
  text-decoration: none;
  background: #fbbf24;
}

.btn-outline {
  background: transparent;
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, .35);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, .09);
  text-decoration: none;
}

.btn-outline-amber {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, .55);
}

.btn-outline-amber:hover {
  background: rgba(245, 158, 11, .12);
  text-decoration: none;
}

.tools-sections {
  padding: 2rem 0 2.5rem;
  flex: 1;
}

.tools-sections .container {
  max-width: 100%;
  width: 100%;
  padding-inline: .5rem;
}

.catalog-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: .8rem;
  align-items: start;
}

.catalog-sidebar {
  position: sticky;
  top: 78px;
  display: grid;
  gap: .65rem;
}

.sidebar-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: .75rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-card h2 {
  font-size: 1.02rem;
  margin-bottom: .25rem;
}

.sidebar-card h3 {
  font-size: .92rem;
  margin-bottom: .55rem;
}

.sidebar-card p {
  color: var(--color-muted);
  font-size: .85rem;
  margin-bottom: .8rem;
}

.field-label {
  display: block;
  font-size: .8rem;
  color: var(--color-muted);
  margin-bottom: .3rem;
}

.search-input,
.sort-select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: .58rem .7rem;
  font-size: .88rem;
  margin-bottom: .65rem;
  background: #fff;
}

.toolbar-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
  align-items: end;
}

.toolbar-field {
  min-width: 0;
}

.toolbar-action {
  display: flex;
}

.btn-clear {
  width: 100%;
  background: #edf4ff;
  color: var(--color-primary-dark);
  border-color: #b8d4f5;
  font-weight: 700;
}

.btn-clear:hover { background: #dcecff; }

.facet-list {
  list-style: none;
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0;
  border: 1px solid #0f6cbd;
  border-radius: 8px;
  overflow: hidden;
}

.facet-btn {
  width: auto;
  text-align: left;
  border: 0;
  border-right: 1px solid #0d4f8a;
  border-radius: 0;
  background: #0f6cbd;
  color: #ffffff;
  padding: .68rem 1.2rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.15;
  cursor: pointer;
}

.facet-list li:last-child .facet-btn {
  border-right: 0;
}

.facet-btn.is-active {
  background: #0d4f8a;
  color: #ffffff;
}

.subcategory-facets {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.subfacet-btn {
  border: 1px solid #bcd6f2;
  background: #f3f8ff;
  color: #0f3f69;
  border-radius: 999px;
  padding: .28rem .62rem;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
}

.subfacet-btn.is-active {
  background: #0f6cbd;
  color: #fff;
  border-color: #0f6cbd;
}

.catalog-results {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: .75rem;
  box-shadow: var(--shadow-sm);
}

.catalog-categories-bar {
  border-bottom: 1px solid var(--color-border);
  margin-bottom: .65rem;
  padding-bottom: .5rem;
}

.catalog-categories-bar h3 {
  font-size: .9rem;
  margin-bottom: .45rem;
  color: #0f3f69;
}

.results-header {
  display: grid;
  grid-template-columns: auto minmax(320px, 460px) auto;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: .7rem;
  padding-bottom: .5rem;
  gap: .6rem;
}

.results-header h2 {
  font-size: 1.25rem;
}

.results-controls {
  display: flex;
  align-items: center;
  gap: .45rem;
  justify-self: center;
  width: 100%;
}

.results-controls .search-input {
  margin-bottom: 0;
  min-width: 220px;
}

.results-controls .btn-clear {
  width: auto;
  white-space: nowrap;
}

.results-meta {
  text-align: right;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: .35rem;
  float: right;
}

.view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #f7fbff;
  color: #33587a;
  width: 2.1rem;
  height: 2rem;
  padding: 0;
  cursor: pointer;
}

.view-btn svg {
  width: 1rem;
  height: 1rem;
}

.view-btn + .view-btn {
  border-left: 1px solid var(--color-border);
}

.view-btn.is-active {
  background: #0f6cbd;
  color: #fff;
}

#results-count {
  font-size: .84rem;
  color: var(--color-muted);
}

.active-path {
  font-size: .8rem;
  color: #0f3f69;
  font-weight: 700;
}

.catalog-status {
  font-size: .8rem;
  color: var(--color-muted);
}

.table-wrap {
  overflow-x: auto;
}

.tools-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.tools-table th,
.tools-table td {
  border-bottom: 1px solid var(--color-border);
  padding: .5rem .42rem;
  text-align: left;
  vertical-align: top;
  font-size: .83rem;
}

.tools-table th {
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-muted);
  position: sticky;
  top: 0;
  background: #f8fbff;
}

.col-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.col-sort-btn.is-active {
  color: #0f6cbd;
}

.sort-indicator {
  width: .9rem;
  text-align: center;
  font-size: .72rem;
  opacity: .85;
}

.tools-table tbody tr:hover {
  background: #f8fbff;
}

.cell-tool {
  font-weight: 700;
}

.cell-tool-inner {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.cell-description {
  color: var(--color-muted);
}

.tool-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.tool-logo-placeholder {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-border);
  flex-shrink: 0;
}

.tool-table-link {
  display: inline-block;
  font-weight: 700;
}

.tool-title-link {
  color: inherit;
  text-decoration: none;
}

.tool-title-link:hover {
  text-decoration: underline;
}

.tool-actions {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.tool-action-muted {
  color: var(--color-muted);
  font-size: .84rem;
  font-weight: 600;
}

.tools-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .55rem;
}

.tool-tile {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #fbfdff;
  padding: .6rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.tool-tile-title {
  font-size: .92rem;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

.tool-tile-meta,
.tool-tile-rating {
  font-size: .76rem;
  color: #456788;
}

.tool-tile-desc {
  font-size: .8rem;
  color: var(--color-muted);
  line-height: 1.45;
  flex: 1;
}

.table-empty {
  text-align: center;
  color: var(--color-muted);
  padding: 1.2rem;
}

.tools-loading,
.tools-error {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-muted);
}

.tools-error { color: #b91c1c; }

.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-card {
  height: 150px;
  border-radius: 12px;
}

.table-skeleton-row {
  height: 18px;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.site-footer {
  background: var(--color-footer-bg);
  color: var(--color-footer-text);
  padding: 2.3rem 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-brand {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

.footer-copy {
  font-size: .84rem;
}

.footer-links {
  display: flex;
  gap: 1.3rem;
  list-style: none;
  font-size: .84rem;
}

.footer-links a {
  color: var(--color-footer-text);
}

.footer-links a:hover {
  color: #fff;
  text-decoration: none;
}

@media (max-width: 980px) {
  .catalog-shell {
    grid-template-columns: 1fr;
  }

  .catalog-sidebar {
    position: static;
  }

  .results-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .results-controls {
    justify-self: start;
    max-width: 520px;
  }

  .results-meta {
    text-align: left;
  }

  .toolbar-fields {
    grid-template-columns: 1fr 1fr auto;
  }

  .subcategory-facets { max-height: 220px; overflow: auto; }
}

@media (max-width: 760px) {
  .nav-links { gap: 1rem; }
  .nav-links a { font-size: .82rem; }

  .hero {
    padding: 3.4rem 0 3rem;
  }

  .toolbar-fields {
    grid-template-columns: 1fr;
  }

  .results-header {
    gap: .4rem;
  }

  .results-controls {
    flex-direction: row;
    align-items: center;
    max-width: 100%;
  }

  .results-controls .search-input {
    flex: 1;
    min-width: 0;
  }

  .results-controls .btn-clear {
    width: auto;
  }

  .view-toggle {
    margin-bottom: .2rem;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .nav-brand span { display: none; }
}

/* ============================================================
   Dark theme
   ============================================================ */
[data-theme="dark"] {
  --color-bg: #0d1117;
  --color-surface: #161b22;
  --color-border: #30363d;
  --color-primary: #58a6ff;
  --color-primary-dark: #388bfd;
  --color-text: #e6edf3;
  --color-muted: #8b949e;
  --color-footer-bg: #010409;
  --color-footer-text: #8b949e;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 10px 26px rgba(0,0,0,.5);
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at 10% -20%, #0d2142, transparent 45%),
    radial-gradient(circle at 100% 0%, #1a1200, transparent 32%),
    var(--color-bg);
}

[data-theme="dark"] .site-nav {
  background: rgba(13, 17, 23, .92);
}

[data-theme="dark"] .search-input,
[data-theme="dark"] .sort-select {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  color-scheme: dark;
}

[data-theme="dark"] .btn-clear {
  background: #1c2d40;
  color: var(--color-primary);
  border-color: #2d4a66;
}

[data-theme="dark"] .btn-clear:hover { background: #243a52; }

[data-theme="dark"] .facet-list { border-color: #2d5a8e; }

[data-theme="dark"] .facet-btn {
  background: #1c3a5c;
  color: #c8dfff;
  border-color: #2d5a8e;
}

[data-theme="dark"] .facet-btn.is-active {
  background: #1f5090;
  color: #fff;
}

[data-theme="dark"] .subfacet-btn {
  background: #1c2d40;
  color: #7ec8e3;
  border-color: #2d4a66;
}

[data-theme="dark"] .subfacet-btn.is-active {
  background: var(--color-primary);
  color: #0d1117;
  border-color: var(--color-primary);
}

[data-theme="dark"] .view-btn {
  background: #1c2d40;
  color: var(--color-muted);
}

[data-theme="dark"] .view-btn.is-active {
  background: var(--color-primary);
  color: #0d1117;
}

[data-theme="dark"] .tools-table th { background: #111820; }

[data-theme="dark"] .tools-table tbody tr:hover { background: #1c2d40; }

[data-theme="dark"] .tool-tile { background: var(--color-surface); }

[data-theme="dark"] .tool-tile-meta,
[data-theme="dark"] .tool-tile-rating { color: #7fa5c5; }

[data-theme="dark"] .active-path,
[data-theme="dark"] .catalog-categories-bar h3 { color: #7fa5c5; }

[data-theme="dark"] .col-sort-btn.is-active { color: var(--color-primary); }

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #21262d 25%, #30363d 50%, #21262d 75%);
  background-size: 200% 100%;
}
