/* Demo page layout only. The badge styles come from
   ../Resources/Public/css/ntg-ai-img.css; the :root block below shows how a
   project customises the component through CSS variables. */

:root {
  --page-bg: #ffffff;
  --page-fg: #14181f;
  --muted: #6b7280;
  --card-bg: #f4f4f5;
  --border: #e4e4e7;
  --accent: #4f46e5;
  color-scheme: light;

  /* Height of the sticky header, used for the anchor scroll offset. */
  --header-h: 61px;

  /* --- Project-side customisation of the ntg-ai-img component --- */
  --ntg-ai-img-bg-light: rgba(17, 17, 17, 0.82);
  --ntg-ai-img-color-light: #ffffff;
  --ntg-ai-img-radius: 0.4rem;
  --ntg-ai-img-font-size: 0.75rem;
}

/* Manual dark mode toggle via data-theme. The system dark mode
   (@media prefers-color-scheme) still applies on top of this. */
:root[data-theme='dark'] {
  --page-bg: #0f1216;
  --page-fg: #e8e8ea;
  --muted: #9aa4b2;
  --card-bg: #1a1f27;
  --border: #262c36;
  --accent: #818cf8;
  color-scheme: dark;

  --ntg-ai-img-bg-light: rgba(255, 255, 255, 0.92);
  --ntg-ai-img-color-light: #14181f;
}

* { box-sizing: border-box; }

/* Anchor targets have to clear the sticky header, otherwise it covers the
   heading that was jumped to. scroll-padding-top on the scrollport covers every
   target on the page (sections and e.g. #ignored-region alike); an extra
   scroll-margin-top on the targets would add on top of it and double the gap. */
html { scroll-padding-top: calc(var(--header-h) + 1rem); }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.5;
  background: var(--page-bg);
  color: var(--page-fg);
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1rem; }

/* Sidebar + content. Wider than .wrap so the content column keeps its width
   next to the 220px sidebar. Must stay after .wrap (same specificity). */
.layout {
  max-width: 1280px;
  display: grid; grid-template-columns: 220px minmax(0, 1fr);
  gap: 2rem; align-items: start;
}

/* Sticky on the grid item, not on the nav: the nav is only as tall as its
   links, so sticking inside it would run out after a few hundred pixels. */
.sidebar { position: sticky; top: calc(var(--header-h) + 1rem); }
.sidebar-nav {
  max-height: calc(100vh - var(--header-h) - 2rem); overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 0.5rem 0; font-size: 0.85rem;
}
.sidebar-nav a {
  padding: 0.3rem 0.75rem;
  border-left: 2px solid var(--border);
  color: var(--muted); text-decoration: none;
}
.sidebar-nav a:hover { color: var(--page-fg); border-left-color: var(--muted); }
/* Set by the scroll spy in demo.js — exactly one link at a time. */
.sidebar-nav a.active {
  color: var(--accent); border-left-color: var(--accent); font-weight: 600;
}

/* Backdrop and floating button only exist below the layout breakpoint. */
.sidebar-backdrop { display: none; }
.sidebar-toggle {
  display: none;
  position: fixed; right: 1rem; bottom: 1rem; z-index: 70;
  width: 3rem; height: 3rem; padding: 0;
  align-items: center; justify-content: center;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #fff; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.section { margin: 2.5rem 0; }
.section > h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.section h2 small { color: var(--muted); font-weight: 400; font-size: 0.8rem; }

img { max-width: 100%; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--page-bg);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 1rem; }
.header-inner .logo { width: 32px; height: 32px; border-radius: 6px; }
.header-inner #theme-toggle { margin-left: auto; }

.btn {
  padding: 0.45rem 0.8rem; border: 1px solid var(--border); border-radius: 0.4rem;
  background: var(--card-bg); color: var(--page-fg); cursor: pointer; font: inherit;
}
.btn:hover { border-color: var(--muted); }

/* Hero */
.hero { margin: 0; }
.hero img { width: 100%; height: auto; display: block; border-radius: 0.6rem; }

/* Slider */
.slider {
  display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.75rem;
  scroll-snap-type: x mandatory;
}
.slide { flex: 0 0 300px; scroll-snap-align: start; }
.slide img { width: 100%; height: auto; display: block; border-radius: 0.5rem; }

/* Grid / Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
/* Wide enough for the longest badge label, which does not wrap. */
.grid-wide { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 0.5rem; overflow: hidden; }
.card img { width: 100%; height: auto; display: block; }
.card-body { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.75rem; font-size: 0.9rem; }

/* Product detail */
.detail { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.detail-main { flex: 1 1 340px; }
.detail-main img { width: 100%; height: auto; display: block; border-radius: 0.6rem; }
.detail-side { flex: 1 1 240px; color: var(--muted); font-size: 0.9rem; }
.thumbs { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 0.4rem; }

/* Masonry (CSS columns) */
.masonry { columns: 260px 3; column-gap: 1rem; }
.m-item { break-inside: avoid; margin: 0 0 1rem; }
.m-item img { width: 100%; height: auto; display: block; border-radius: 0.5rem; }

/* Small images */
.icons { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.icons img { display: block; border-radius: 6px; }
.hint { color: var(--muted); font-size: 0.85rem; }

.shrunk { width: 60px; height: auto; }

/* Options panel */
.panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.panel-col {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 0.5rem; padding: 0.9rem 1rem;
}
.panel-col h3 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.panel-col p { margin: 0 0 0.6rem; }
.out {
  margin: 0; padding: 0.6rem 0.75rem; max-height: 20rem; overflow: auto;
  background: var(--page-bg); border: 1px solid var(--border); border-radius: 0.4rem;
  font-size: 0.75rem; line-height: 1.45;
}
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.field { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; font-size: 0.8rem; }
.field-wide { grid-column: 1 / -1; }
.field em { color: var(--muted); font-style: normal; }
.field select, .field input {
  width: 100%; min-width: 0; box-sizing: border-box;
  padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 0.3rem;
  background: var(--page-bg); color: var(--page-fg); font: inherit; font-size: 0.85rem;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn-primary { border-color: var(--page-fg); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Element types */
.types .bg-tile {
  aspect-ratio: 4 / 3; background-size: cover; background-position: center;
}
.types .video-wrap { display: block; line-height: 0; }
.types video { width: 100%; height: auto; display: block; }

/* CSS variable showcase */
.vars-pill {
  --ntg-ai-img-bg-light: #6d28d9;
  --ntg-ai-img-color-light: #ffffff;
  --ntg-ai-img-radius: 999px;
  --ntg-ai-img-padding: 0.3rem 0.7rem;
}
.vars-large {
  --ntg-ai-img-font-size: 0.95rem;
  --ntg-ai-img-gap: 0.6em;
  --ntg-ai-img-offset: 1rem;
}
.vars-inverted {
  --ntg-ai-img-bg-light: rgba(255, 255, 255, 0.92);
  --ntg-ai-img-color-light: #14181f;
  --ntg-ai-img-bg-dark: #be185d;
  --ntg-ai-img-color-dark: #ffffff;
}
.vars-stacking { --ntg-ai-img-z-index: 999; position: relative; }
.vars-stacking .local-overlay {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 0.35rem 0.5rem; z-index: 1;
  background: rgba(220, 38, 38, 0.92); color: #fff;
  font-size: 0.75rem; text-align: right;
}

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.5rem 0; color: var(--muted); }
.site-footer .wrap { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.site-footer .logo { width: 28px; height: 28px; border-radius: 6px; }

/* Responsive */
/* Below this width the 220px sidebar plus content no longer fit, so the
   sidebar becomes an off-canvas drawer. z-index: header 50 < backdrop 55
   < drawer 60 < button 70. */
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    width: min(280px, 85vw); padding: 1rem 0.5rem;
    background: var(--page-bg); border-right: 1px solid var(--border);
    overflow-y: auto;
    transform: translateX(-100%); transition: transform 0.25s ease;
  }
  .sidebar.open { transform: none; }
  .sidebar-nav { max-height: none; font-size: 0.95rem; }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(0, 0, 0, 0.45);
  }
  .sidebar-backdrop[hidden] { display: none; }
  .sidebar-toggle { display: flex; }
}

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .slide { flex-basis: 78%; }
  .fields { grid-template-columns: 1fr; }
}
