/*
  Organization:
    1) Design tokens (:root)
    2) Base / layout
    3) Header / brand
    4) Controls / dropdowns
    5) Boxes / cards
    6) Modal / overlay
    7) UI components (buttons, embeds, footer)

*/

:root {
  /* Core color tokens (terminal / code-like palette) */
  --bg: #051014;
  /* near-black teal */
  --fg: #cfeee0;
  /* pale mint for readable text */
  /* slightly toned-down foreground for headings (midpoint between --fg and the previous dim) */
  --fg-dim: #b7d6c8;
  --muted: #7f9ea6;
  /* desaturated cyan */
  --accent: #7CFC00;
  /* neon green accent (terminal vibe) */
  --card: #071016;
  /* slightly lighter than background for panels */

  /* Layout tokens */
  --radius: 0.75rem; /* 12px */
  --gap: 1.125rem;   /* 18px */

  /* Typography tokens */
  --mono-font: 'Fira Code', 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, monospace;
  --font-family-base: var(--mono-font);
  /* Base font sizes (use rem so scaling follows the root font-size)
    ordered smallest → largest for readability */
  --fs-sm: 0.875rem;      /* 14px */
  --fs-md: 0.9375rem;     /* 15px */
  --fs-base: 1rem;        /* 16px */
  --fs-18: 1.125rem;      /* 18px */
  --fs-lg: 1.25rem;       /* 20px */
  --lh: 1.55;

  /* Shadows */
  --panel-shadow: 0 14px 40px rgba(2, 6, 23, 0.12);
  --soft-shadow: 0 8px 28px rgba(2, 6, 23, 0.08);
}

/* -------------------- Base / Layout -------------------- */
html {
  scrollbar-gutter: stable;
  overflow-y: scroll !important;
  /* avoid layout shift on Chrome/Linux */
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  background: var(--bg);
  font-family: var(--font-family-base);
  font-size: var(--fs-base);
  line-height: var(--lh);
}

.container {
  max-width: 65rem;
  margin: 0 auto;
  padding: calc(var(--gap) * 1.2);
}

main#content {
  display: grid;
  gap: 1rem;
  margin-top: 0.75rem;
}

/* -------------------- Header / Brand -------------------- */
.site-header {
  width: 100%;
}

.site-header .header-band {
  background: linear-gradient(180deg, rgba(124, 252, 0, 0.02), rgba(124, 252, 0, 0.004));
  border-bottom: 1px solid rgba(124, 252, 0, 0.03);
  padding: 0.875rem calc(var(--gap) * 1.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.top-row-inner {
  max-width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.left-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  width: 5rem;
  height: 5rem;
  border-radius: 0.625rem;
  margin-left: 0;
  padding: 0.375rem;
  filter: invert(1) brightness(1.05) contrast(1.02);
  box-shadow: 0 0 8px rgba(124, 252, 0, 0.06), 0 0 12px rgba(124, 252, 0, 0.03);
}

.brand h1 {
  margin: 0;
  font-size: 1.7em;
  font-weight: 650;
  font-family: var(--mono-font);
  letter-spacing: 0.6px;
  color: var(--fg-dim);
}

.brand .tagline {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.tagline-pre {
  white-space: pre-wrap;
  font-family: monospace;
  margin: 0.5rem 0 0 0;
  color: #ca8e63;
  font-size: 0.8em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.icon-btn {
  background: transparent;
  border: 0;
  font-size: var(--fs-18);
  cursor: pointer;
  color: var(--fg);
  padding: 0.5rem;
  border-radius: 0.5rem;
}

.icon-btn:hover {
  background: rgba(11, 113, 255, 0.04);
}

/* -------------------- Boxes / Cards -------------------- */
/* Grid layout and basic box structure are handled by box-common.css */

.box {
  background: linear-gradient(180deg, rgba(36, 68, 71, 0.96), rgba(2, 6, 8, 0.02));
  padding: 1.125rem;
  border-radius: var(--radius);
  /* min-height: 7.5rem;  <-- overridden by box-common.css default, but can be kept if needed */
  min-height: 7.5rem;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-left: 3px solid rgba(124, 252, 0, 0.22);
  transition: transform .12s cubic-bezier(.2, .9, .2, 1), box-shadow .12s;
}

.box h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-md);
  font-weight: 650;
  font-family: var(--mono-font);
  color: var(--fg-dim);
}

.box h3::before {
  content: '▸';
  margin-right: 0.5rem;
  color: rgba(124, 252, 0, 0.9);
  font-size: 0.75rem;
}

.box:hover,
.box:focus-within,
.box:focus-visible {
  transform: translateY(-0.375rem);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.08);
}

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

  .box {
    transform: none !important;
  }
}

.box.selected {
  position: relative;
  z-index: 110;
  transform: translateY(-0.375rem);
  box-shadow: 0 26px 60px rgba(2, 6, 23, 0.16);
  border-left: 3px solid var(--accent);
  pointer-events: none;
}

.more-ellipsis {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: var(--fs-18);
  line-height: 1;
  cursor: pointer;
  margin-left: auto;
}

.muted {
  color: var(--muted);
  font-size: var(--fs-sm);
}

.detail-container {
  display: block;
}

.detail-block {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.5rem;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.12);
  position: relative;
}

.detail-close {
  position: absolute;
  right: 0.625rem;
  top: 0.5rem;
  border: 0;
  background: transparent;
  font-size: 1rem;
}

/* -------------------- Modal / Overlay -------------------- */
.overlay {
  position: fixed;
  inset: 0;
  /* stronger backdrop to improve contrast for modal content */
  background: rgba(0, 0, 0, 0.65);
  z-index: 70;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 120;
}

.modal[hidden],
.overlay[hidden],
.detail-container[hidden] {
  display: none !important;
}

.modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

.modal-inner {
  /* darker modal panel for legibility on the dim overlay */
  background: linear-gradient(180deg, rgba(6, 18, 20, 0.92), var(--bg));
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  max-width: 52.5rem;
  width: 94%;
  box-shadow: 0 18px 60px rgba(2, 6, 23, 0.32);
  border: 1px solid rgba(124, 252, 0, 0.04);
  position: relative;
  z-index: 120;
  /* slightly reduce interior type scale for better fit and readability */
  font-size: 0.95rem;
}

/* Modal-specific typography: slightly smaller headings and body text */
.modal-inner h2 {
  font-size: 1.05rem; /* ~16.8px */
  margin-top: 0;
}

.modal-inner h3 {
  font-size: 0.95rem; /* ~15.2px */
  margin-top: 0;
}

.modal-inner p,
.modal-inner li,
.modal-inner .muted {
  font-size: 0.95rem;
  line-height: 1.45;
}

/* Mobile-friendly modal sizing and content limits */
.modal-inner {
  /* Ensure modal never exceeds the viewport height and becomes scrollable */
  max-width: min(94%, 560px);
  max-height: 90vh;
  overflow: auto;
  box-sizing: border-box;
}

.modal-inner .embed-area iframe,
.modal-inner img {
  max-width: 100%;
  height: auto;
  max-height: 55vh;
}

@media (max-width: 600px) {
  .modal-inner {
    width: 94%;
    padding: 0.625rem 0.75rem;
    font-size: 0.92rem;
  }

  .modal-inner h2 { font-size: 1rem; }
  .modal-inner h3 { font-size: 0.95rem; }

  .modal-inner .embed-area iframe {
    height: 16.25rem;
    max-height: 45vh;
  }
}

.modal-close {
  position: absolute;
  right: 0.75rem;
  top: 0.625rem;
  z-index: 121;
  border: 0;
  background: transparent;
  font-size: var(--fs-18);
  color: #fff; /* make the close X visible on dark modal backgrounds */
  /* make it a circular tap target on touch devices */
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
}

/* -------------------- Buttons / Embeds / Footer -------------------- */
.btn {
  appearance: none;
  border: 1px solid rgba(124, 252, 0, 0.08);
  background: transparent;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  color: var(--fg);
  transition: transform .12s ease, box-shadow .12s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124, 252, 0, 0.04);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(90deg, rgba(124, 252, 0, 0.12), rgba(124, 252, 0, 0.18));
  color: var(--bg);
  border: 0;
}

.embed-area {
  margin-top: 0.75rem;
}

.embed-area iframe {
  width: 100%;
  height: 30rem;
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(2, 6, 23, 0.08);
  border: 0;
}

.site-footer {
  border-top: 1px solid rgba(124, 252, 0, 0.04);
  padding: 1.125rem;
  margin-top: 1.125rem;
  text-align: center;
  color: var(--muted);
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.container a,
.modal-inner a {
  color: var(--accent);
  text-decoration: none;
}
.container a:visited,
.modal-inner a:visited {
  color: rgba(124,252,0,0.65);
}

.site-footer a:hover {
  text-decoration: underline;
}

/* -------------------- Utilities / Misc -------------------- */
.lead {
  padding: 1.25rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(124, 252, 0, 0.02));
  margin-bottom: 0.75rem;
  border-radius: 0.5rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 6px 18px rgba(12, 25, 42, 0.04);
}

.card header h2 {
  margin: 0;
  color: var(--accent);
  font-size: var(--fs-lg);
  font-family: var(--mono-font);
}

/* Tone down heading brightness and heavy boldness site-wide (keep sizes) */
h1,
h2,
h3,
.modal-inner h2,
.modal-inner h3,
.card header h2 {
  color: var(--fg-dim);
  font-weight: 600;
}

.demo-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ghost {
  background: transparent;
  border: 1px dashed rgba(0, 0, 0, 0.08);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
}

.more-btn {
  margin-top: 0.5rem;
}

.detail {
  margin-top: 0.5rem;
  padding: 0.625rem;
  background: #fcfdff;
  border-left: 3px solid var(--accent);
}

.header-band-debug {
  outline: 2px dashed rgba(11, 113, 255, 0.08);
}

/* -------------------- Responsive -------------------- */
@media (max-width: 900px) {
  /* .boxes grid layout handled by box-common.css */

  .embed-area iframe {
    height: 26.25rem;
  }
}

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

  .site-header img {
    width: 2.5rem;
    height: 2.5rem;
  }

  main#content {
    padding: 0;
  }
}

@media (max-width: 560px) {
  /* .boxes grid layout handled by box-common.css */

  .embed-area iframe {
    height: 22.5rem;
  }

  .brand .tagline {
    display: none;
  }
}

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



.btn:active {
  transform: translateY(0)
}

.btn-primary {
  background: linear-gradient(90deg, rgba(124, 252, 0, 0.12), rgba(124, 252, 0, 0.18));
  color: var(--bg);
  border: 0;
}

.demo-controls.below {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 14px
}

.ghost {
  background: transparent;
  border: 1px dashed rgba(0, 0, 0, 0.08);
  padding: 8px 12px;
  border-radius: 8px
}

/* removed legacy .dark class-based theme */

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

  .site-header img {
    width: 40px;
    height: 40px
  }

  main#content {
    padding: 0
  }
}

@media (prefers-reduced-motion:reduce) {
  * {
    transition: none !important
  }
}
.scrollable-content {
  max-height: 400px;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.1);
  margin-top: 0.5rem;
}
