/* Kodinay Grolex — design system
   Palette: navy-black base, indigo/violet accent, restrained gradient used once in the hero. */

/* Light is the default theme. Dark is opted into via [data-theme="dark"]. */
:root {
  --bg: #F7F8FC;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --border: rgba(15,20,40,0.08);
  --border-strong: rgba(15,20,40,0.14);
  --text: #10152A;
  --text-muted: #565F7C;
  --text-faint: #8A92AC;
  --accent: #4453D8;
  --accent-soft: rgba(68,83,216,0.10);
  --accent-glow: #3548C4;
  --success: #1E9E63;
  --warning: #B4790E;
  --danger: #D23C4B;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.6) inset, 0 12px 24px -16px rgba(20,25,50,0.18);
}

[data-theme="dark"] {
  --bg: #0A0E1A;
  --surface: #12182C;
  --surface-raised: #171E38;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text: #F4F5FA;
  --text-muted: #8C95AC;
  --text-faint: #5C6480;
  --accent: #5B6EF5;
  --accent-soft: rgba(91,110,245,0.15);
  --accent-glow: #7B8CFF;
  --success: #3FCB8C;
  --warning: #E7B24A;
  --danger: #F0616B;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 30px -18px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  color: var(--text);
}

p { color: var(--text-muted); margin: 0 0 1em; max-width: 62ch; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- Navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; max-width: 1240px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 0; }
/* Logo box height is fixed and identical in both themes; width is derived from
   each PNG's own aspect ratio so neither logo looks bigger/smaller than the other. */
.brand-mark {
  height: 46px; width: 170px;
  background: url("/logo.png") left center / contain no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 0; font-weight: 700;
}
[data-theme="dark"] .brand-mark {
  width: 150px;
  background-image: url("/d_logo.png");
}
.home-brand-mark { height: 52px; width: 192px; }
[data-theme="dark"] .home-brand-mark { width: 170px; }
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a { font-size: 0.92rem; color: var(--text-muted); }
.nav-links a:hover { color: var(--text); }
.nav-actions { display: flex; gap: 12px; align-items: center; }
.auth-status { color: var(--success); font-size: 0.82rem; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-sm);
  font-size: 0.92rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; font-family: var(--font-body);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-glow); }
.btn-secondary { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-block { width: 100%; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-glow));
  color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 0.82rem;
  cursor: pointer; flex-shrink: 0; box-shadow: var(--shadow-card);
}
.avatar-menu { position: relative; display: inline-flex; }
.avatar-dropdown {
  display: none; position: absolute; right: 0; top: 46px; min-width: 190px;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); padding: 6px; z-index: 30;
}
.avatar-dropdown.open { display: block; }
.avatar-dropdown a, .avatar-dropdown button {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; font-size: 0.86rem; background: none; border: none; cursor: pointer;
}
.avatar-dropdown a:hover, .avatar-dropdown button:hover { background: var(--accent-soft); color: var(--text); }
.price-tag { font-family: var(--font-display); font-weight: 600; color: var(--accent-glow); font-size: 0.95rem; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-actions .btn { padding: 4px 9px; font-size: 0.76rem; }
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(8,12,28,.5); z-index: 40; align-items: center; justify-content: center; }
.modal-backdrop.open { display: flex; }
.modal-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px; width: 420px; max-width: 92vw; max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-card); }
.modal-card h3 { margin-top: 0; }
.modal-card label { display: block; font-size: 0.82rem; color: var(--text-faint); margin: 12px 0 5px; }
.icon-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; color: var(--text-muted);
}

/* ---------- Hero ---------- */
.hero {
  padding: 88px 0 64px; position: relative; overflow: hidden;
}
.hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 56px; align-items: center; }
.hero h1 { font-size: clamp(2.4rem, 4vw, 3.4rem); line-height: 1.08; max-width: 14ch; }
.hero .lede { font-size: 1.08rem; max-width: 46ch; }
.hero-ctas { display: flex; gap: 14px; margin-top: 28px; }
.hero-visual { position: relative; }

/* ---------- Sections ---------- */
.section { padding: 72px 0; border-top: 1px solid var(--border); }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 36px; gap: 24px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.7rem; margin: 0; }
.section-head p { margin: 6px 0 0; }

/* ---------- Category chips ---------- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.category-chip {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px; background: var(--surface); display: flex; flex-direction: column; gap: 8px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.category-chip:hover { border-color: var(--accent); transform: translateY(-2px); }
.category-chip .count { color: var(--text-faint); font-size: 0.82rem; }

/* ---------- API Cards ---------- */
.api-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.api-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 22px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 14px;
}
.api-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.api-logo {
  width: 44px; height: 44px; border-radius: 10px; background: var(--surface-raised);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; color: var(--accent-glow);
}
.badge {
  font-size: 0.72rem; padding: 3px 9px; border-radius: 100px; border: 1px solid var(--border-strong);
  color: var(--text-muted); white-space: nowrap;
}
.badge-verified { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.badge-free { color: var(--accent-glow); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.api-card h3 { font-size: 1.05rem; margin: 0; }
.api-card .meta-row { display: flex; align-items: center; gap: 14px; font-size: 0.82rem; color: var(--text-faint); }
.api-card-footer { display: flex; align-items: stretch; flex-direction: column; gap: 12px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.api-card-footer > .badge { align-self: flex-start; }
.api-card-footer .card-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }
.api-card-footer .card-actions .btn { flex: 1; min-width: 0; min-height: 42px; white-space: nowrap; line-height: 1.2; text-align: center; }
.price-tag { font-family: var(--font-display); font-weight: 600; }
.price-tag small { font-family: var(--font-body); font-weight: 400; color: var(--text-faint); font-size: 0.78rem; }

/* ---------- Feature list ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
.feature-item { padding-left: 0; }
.feature-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--accent-glow); }

/* ---------- Code panel ---------- */
.code-panel {
  background: #0D1122; border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden;
}
.code-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 8px 8px 0; }
.code-tab { padding: 9px 16px; font-size: 0.82rem; color: var(--text-faint); border-radius: 8px 8px 0 0; cursor: pointer; }
.code-tab.active { color: var(--text); background: rgba(255,255,255,0.04); }
.code-body { padding: 22px 24px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.86rem; color: #C7CDE6; overflow-x: auto; }
.code-body .kw { color: #7B8CFF; } .code-body .str { color: #7FD9A6; } .code-body .com { color: #5C6480; }

/* ---------- Stats ---------- */
.stats-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 24px; }
.stat-block .num { font-family: var(--font-display); font-size: 2.1rem; font-weight: 600; }
.stat-block .label { color: var(--text-faint); font-size: 0.86rem; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 56px 0 32px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 32px; }
.footer h4 { font-size: 0.86rem; color: var(--text-muted); font-weight: 500; margin-bottom: 14px; }
.footer a { display: block; color: var(--text-faint); font-size: 0.88rem; padding: 5px 0; }
.footer a:hover { color: var(--text); }
.footer-bottom { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; color: var(--text-faint); font-size: 0.82rem; flex-wrap: wrap; gap: 12px; }

/* ---------- Forms / inputs ---------- */
.input {
  width: 100%; padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-family: var(--font-body); font-size: 0.95rem;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-bar { display: flex; gap: 10px; align-items: center; padding: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); }
.search-bar input { border: none; background: none; flex: 1; padding: 10px; color: var(--text); font-size: 0.95rem; }
.search-bar input:focus { outline: none; }

.filter-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 32px; }
.filter-pill {
  padding: 8px 14px; border-radius: 100px; border: 1px solid var(--border-strong);
  font-size: 0.84rem; color: var(--text-muted); cursor: pointer; background: var(--surface);
}
.filter-pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-glow); }

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

/* Focus visibility */
a:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; }
}
@media (max-width: 560px) {
  .container { padding: 0 18px; }
  .nav-inner { padding: 14px 18px; }
  .home-brand-mark { width: 150px; height: 43px; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .api-card-footer .card-actions { width: 100%; }
}
