/* ==========================================================================
   Codermax — Design System (ARKKHE-derived, tema escuro)
   Fundo --ink em todo o site (não só na sidebar), texto claro, um único
   accent laranja sólido por composição, curva de easing assinatura.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --accent: #FF8400;
  --accent-2: #FF6B1A;

  --ink: #0A0F14;
  --ink-rgb: 10, 15, 20;
  --bg: #12181F;
  --bg-rgb: 18, 24, 31;
  --surface: #1B232B;
  --surface-2: #232D36;

  --text: #F3F1EC;
  --text-dim: #9AA4AC;

  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --shadow-ink: rgba(0, 0, 0, 0.55);
  --glow-accent: rgba(255, 132, 0, 0.22);

  /* Cadência única, base 4px */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 64px;
  --space-7: 96px;

  /* Família única de raios */
  --radius-xs: 4px;
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 30px;
  --radius-pill: 999px;

  --sidebar-w: 76px;
  --sidebar-w-expanded: 224px;
  --sidebar-mobile-h: 64px;

  --font-display: "Satoshi", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* Única curva de transição do sistema */
  --ease: cubic-bezier(.625, .05, 0, 1);
}

@property --angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Sidebar + content lado a lado; o footer fica FORA daqui, como faixa
   full-width por baixo de tudo (a sidebar "recolhe" ao chegar nele). */
.app-shell {
  display: flex;
  align-items: flex-start;
  flex: 1 1 auto;
  width: 100%;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }

/* Wash radial em laranja translúcido — o mesmo "fundo dinâmico" do sistema,
   fixo atrás do conteúdo, bem sutil (não compete com o accent sólido). */
body::before {
  content: "";
  position: fixed;
  top: -12%;
  right: -12%;
  width: min(56vw, 760px);
  height: min(56vw, 760px);
  background: radial-gradient(circle, var(--glow-accent), transparent 70%);
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Sidebar (o "Hero" escuro recorrente do sistema) ---------- */
#sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  flex: 0 0 auto;
  width: var(--sidebar-w);
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: rgba(255, 255, 255, 0.6);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
  isolation: isolate;
  transition: width 0.3s var(--ease);
}
#sidebar.is-expanded { width: var(--sidebar-w-expanded); }

#sidebar::before {
  content: "";
  position: absolute;
  top: -25%;
  left: -55%;
  width: 180%;
  height: 46%;
  background: radial-gradient(circle, rgba(255, 132, 0, 0.4), transparent 72%);
  filter: blur(48px);
  z-index: -1;
  pointer-events: none;
  animation: sidebarGlowDrift 16s ease-in-out infinite;
}
@keyframes sidebarGlowDrift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(12%, 10%); }
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 78px;
  padding: var(--space-2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
  overflow: hidden;
}

.sidebar-logo {
  display: block;
  height: 40px;
  width: auto;
  object-fit: contain;
  transition: height 0.3s var(--ease);
}
#sidebar.is-expanded .sidebar-logo { height: 54px; }

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: var(--space-3) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0 var(--space-3) calc((var(--sidebar-w) - 1.3rem) / 2);
  color: inherit;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  position: relative;
  transition: color 0.18s ease, background 0.18s ease;
}
#sidebar.is-expanded .sidebar-link { padding-left: var(--space-4); padding-right: var(--space-3); }

.sidebar-link i { font-size: 1.05rem; width: 1.3rem; text-align: center; flex: 0 0 auto; }

.sidebar-label {
  white-space: nowrap;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transition: opacity 0.18s ease, max-width 0.3s var(--ease);
}
#sidebar.is-expanded .sidebar-label { opacity: 1; max-width: 140px; }

.sidebar-link:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.sidebar-link.is-active { color: var(--accent); }
.sidebar-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  box-shadow: 0 0 12px var(--glow-accent);
}

.sidebar-toggle {
  flex: 0 0 auto;
  margin-top: auto;
  border: none;
  background: transparent;
  color: inherit;
  padding: var(--space-4) 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-toggle i { transition: transform 0.3s var(--ease); }
#sidebar.is-expanded .sidebar-toggle i { transform: rotate(180deg); }
.sidebar-toggle:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Layout ---------- */
.content {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
}

.page { max-width: 1400px; margin: 0 auto; padding: 0 clamp(var(--space-3), 4vw, var(--space-5)) var(--space-6); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) clamp(var(--space-3), 4vw, var(--space-5));
  margin: 0 clamp(calc(var(--space-3) * -1), -4vw, calc(var(--space-5) * -1));
  background: rgba(var(--bg-rgb), 0.72);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}

.topbar-tools { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.count { font-size: 0.85rem; color: var(--text-dim); white-space: nowrap; }

.search input {
  width: min(320px, 60vw);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.search input::placeholder { color: var(--text-dim); }
.search input:hover { border-color: var(--border-strong); }
.search input:focus-visible {
  outline: none;
  background: var(--surface-2);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--glow-accent);
}

main { padding-top: var(--space-4); }

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: var(--space-6) var(--space-3);
  font-size: 0.95rem;
}

/* ---------- Card ---------- */
.card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.25s var(--ease);
}
.card::after,
.project-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(280px circle at var(--glare-x, 50%) var(--glare-y, 30%), var(--glow-accent), transparent 62%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.card:hover,
.project-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 20px 46px -24px var(--shadow-ink), 0 0 40px -22px var(--glow-accent);
}
.card:hover::after,
.project-card:hover::after { opacity: 1; }
.card:active { transform: scale(0.99); }
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-media {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  overflow: hidden;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
}

.card-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
}

.card-category {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  color: var(--text-dim);
  line-height: 1.3;
}
.chip-more {
  color: var(--text-dim);
  background: transparent;
  border-style: dashed;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-1);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}
.card-family { display: flex; align-items: center; gap: var(--space-1); }
.card-family::before {
  content: "\25C6";
  color: var(--accent);
  font-size: 0.6rem;
}
.card-index { font-family: var(--font-mono); }

/* ---------- Project card ---------- */
.projects-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }

.project-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.25s var(--ease);
}
.project-card:active { transform: scale(0.99); }
.project-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.project-media {
  display: block;
  background: var(--surface-2);
  overflow: hidden;
  line-height: 0;
}
.project-media img {
  width: 100%;
  height: auto;
  display: block;
}
.project-card-fallback {
  width: 100%;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 2rem;
}

.project-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
}

.project-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
}
.project-link-icon { font-size: 0.7rem; color: var(--accent); }

.project-description {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.55;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: 2px;
}

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.reveal.is-revealed { opacity: 1; transform: translateY(0); }

/* ---------- Overlay / Modal (painel de vidro) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4) var(--space-3);
  background: rgba(var(--ink-rgb), 0.7);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.overlay[hidden] { display: none; }
.overlay.is-open { opacity: 1; }

.modal {
  width: min(640px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: rgba(var(--bg-rgb), 0.82);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 40px 90px -24px rgba(0, 0, 0, 0.6), 0 0 120px -50px var(--glow-accent);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.35s var(--ease);
  overflow: hidden;
}
.overlay.is-open .modal { transform: translateY(0) scale(1); }

.modal-media {
  position: relative;
  background: rgba(255, 255, 255, 0.04);
  flex: 0 0 auto;
}
.modal-media img {
  width: 100%;
  max-height: 34vh;
  object-fit: cover;
  object-position: top;
}

.modal-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
}
.modal-index {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  background: rgba(var(--ink-rgb), 0.7);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  backdrop-filter: blur(4px);
}

.modal-scroll { padding: var(--space-5) clamp(var(--space-4), 4vw, var(--space-5)) var(--space-4); }

.modal-heading { margin-bottom: var(--space-2); }
.modal-heading h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-1);
  line-height: 1.2;
  color: var(--text);
}
.modal-meta {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.modal-description {
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--text);
  max-width: 60ch;
  margin: var(--space-3) 0 var(--space-4);
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.recipe-box {
  background: rgba(255, 132, 0, 0.08);
  border: 1px solid rgba(255, 132, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}
.recipe-label {
  margin: 0 0 var(--space-2);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.recipe-label-dim {
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-dim);
}
.recipe-text {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}

.modal-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) clamp(var(--space-4), 4vw, var(--space-5));
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.75rem 1.3rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), opacity 0.2s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Pill CTA com borda giratória em degradê --accent -> --accent-2 */
.btn-primary {
  position: relative;
  isolation: isolate;
  background: var(--surface);
  color: var(--text);
  z-index: 0;
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: conic-gradient(from var(--angle), var(--accent), var(--accent-2), var(--accent));
  z-index: -1;
  animation: spinRing 3.2s linear infinite;
}
@keyframes spinRing { to { --angle: 360deg; } }
.btn-primary:hover { color: var(--accent); }
.btn-primary.is-copied {
  background: var(--ink);
  color: #fff;
}
.btn-primary.is-copied::before {
  background: var(--ink);
  animation: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  margin-left: auto;
}
.btn-ghost:hover { background: var(--surface); }

/* ---------- Footer (faixa full-width, por baixo da sidebar + conteúdo) ---------- */
.site-footer {
  flex: 0 0 auto;
  width: 100%;
  padding: var(--space-4) clamp(var(--space-3), 4vw, var(--space-5));
  border-top: 1px solid var(--border);
  text-align: center;
}
.site-footer p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

body.no-scroll { overflow: hidden; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .card, .project-card, .overlay, .modal, .btn, .reveal { transition: none !important; }
  #sidebar::before,
  .btn-primary::before { animation: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .search input { width: 100%; }
  .modal-actions { flex-direction: column; }
  .btn-ghost { margin-left: 0; }
}

/* ---------- Sidebar -> bottom tab bar on mobile ---------- */
@media (max-width: 860px) {
  #sidebar {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: var(--sidebar-mobile-h);
    flex-direction: row;
    border-right: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  #sidebar.is-expanded { width: 100%; }
  #sidebar::before { display: none; }

  .sidebar-top,
  .sidebar-toggle { display: none; }

  .sidebar-nav {
    flex-direction: row;
    width: 100%;
    padding: 0;
    gap: 0;
  }
  .sidebar-nav li { flex: 1; display: flex; }

  .sidebar-link {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem 0 !important;
  }
  .sidebar-link i { font-size: 1.15rem; }
  .sidebar-label {
    opacity: 1 !important;
    max-width: none !important;
    font-size: 0.65rem;
  }

  .sidebar-link.is-active::before {
    left: 0.9rem;
    right: 0.9rem;
    top: 0;
    bottom: auto;
    width: auto;
    height: 3px;
  }

  .content,
  .site-footer {
    padding-bottom: var(--sidebar-mobile-h);
  }
}
