/* Inspired Marketing — Factor LED Proposal */

:root {
  --im-blue: #0055ff;
  --im-blue-dark: #0044cc;
  --im-navy: #102c46;
  --im-orange: #fe621d;
  --im-muted: #547593;
  --im-bg: #f3f9fd;
  --im-bg-white: #ffffff;
  --im-border: #ccd7e1;
  --im-text: #102c46;
  --im-shadow: 0 4px 17px 0 rgb(16 44 70 / 0.08);
  --im-shadow-lg: 0 8px 32px -8px rgb(16 44 70 / 0.14);
  --im-radius: 0.875rem;
  --im-max: 75rem;
  --im-sidebar: 17.5rem;
  --im-header: 4.75rem;
  --im-font: 'DM Sans', system-ui, -apple-system, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--im-header) + 1.5rem);
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--im-font);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--im-text);
  background: var(--im-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

#pdf-root {
  overflow-x: clip;
  width: 100%;
}

a {
  color: var(--im-blue);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--im-orange);
}

img,
svg {
  max-width: 100%;
  height: auto;
}

/* ── Top bar ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--im-header);
  background: var(--im-blue);
  border-bottom: 1px solid rgb(255 255 255 / 0.12);
  box-shadow: 0 6px 28px -12px rgb(0 0 0 / 0.35);
}

.header-inner {
  max-width: var(--im-max);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.header-brand > a,
.header-logo-link {
  display: block;
}

.header-brand img,
.header-logo {
  width: 350px;
  height: 58px;
  max-height: 58px;
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
}

.header-divider {
  width: 1px;
  height: 1.75rem;
  background: rgb(255 255 255 / 0.25);
  flex-shrink: 0;
}

.header-title {
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.btn-pdf {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: var(--im-orange);
  color: #fff;
  border: none;
  border-radius: 9999px;
  font-family: var(--im-font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgb(254 98 29 / 0.35);
  transition: background 0.25s, transform 0.15s;
}

.btn-pdf:hover {
  background: #000;
}

.btn-pdf:active {
  transform: scale(0.98);
}

.btn-pdf svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.btn-pdf-label {
  white-space: nowrap;
}

.btn-pdf.is-loading {
  opacity: 0.75;
  pointer-events: none;
}

/* ── Hero cover ── */
.hero {
  background: linear-gradient(135deg, var(--im-navy) 0%, #0a1f33 50%, var(--im-blue-dark) 100%);
  color: #fff;
  padding: 3.5rem 1.5rem 4rem;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.hero::before {
  content: '';
  position: absolute;
  inset: -20% -30% -20% 30%;
  background: radial-gradient(circle at 70% 40%, rgb(0 85 255 / 0.28) 0%, transparent 65%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgb(10 31 51 / 0.35) 100%);
  pointer-events: none;
}

.hero-inner {
  max-width: var(--im-max);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  background: rgb(254 98 29 / 0.15);
  border: 1px solid rgb(254 98 29 / 0.4);
  border-radius: 9999px;
  color: var(--im-orange);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  max-width: 48rem;
}

.hero-subtitle {
  margin: 0 0 2rem;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: rgb(255 255 255 / 0.8);
  max-width: 40rem;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
}

.meta-card {
  background: rgb(255 255 255 / 0.06);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: var(--im-radius);
  padding: 1rem 1.125rem;
  backdrop-filter: blur(8px);
}

.meta-card-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgb(255 255 255 / 0.55);
  margin-bottom: 0.25rem;
}

.meta-card-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  word-break: break-word;
}

.meta-card-value a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.meta-card-value a:hover {
  color: var(--im-orange);
}

.meta-card.highlight {
  background: rgb(254 98 29 / 0.12);
  border-color: rgb(254 98 29 / 0.35);
}

/* ── Layout ── */
.proposal-layout {
  max-width: var(--im-max);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: var(--im-sidebar) 1fr;
  gap: 2.5rem;
  align-items: start;
}

/* ── Sidebar TOC ── */
.sidebar {
  position: sticky;
  top: calc(var(--im-header) + 1.5rem);
  max-height: calc(100vh - var(--im-header) - 3rem);
  overflow-y: auto;
  background: var(--im-bg-white);
  border-radius: var(--im-radius);
  border: 1px solid var(--im-border);
  box-shadow: var(--im-shadow);
  padding: 1.25rem 0;
}

.sidebar-title {
  padding: 0 1.25rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--im-muted);
  border-bottom: 1px solid var(--im-border);
  margin-bottom: 0.5rem;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list a {
  display: block;
  padding: 0.4375rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--im-muted);
  border-left: 3px solid transparent;
  transition: all 0.2s;
  line-height: 1.4;
}

.toc-list a:hover,
.toc-list a.active {
  color: var(--im-blue);
  background: var(--im-bg);
  border-left-color: var(--im-orange);
}

.toc-list a.active {
  font-weight: 600;
}

/* ── Main content ── */
.proposal-content {
  background: var(--im-bg-white);
  border-radius: var(--im-radius);
  border: 1px solid var(--im-border);
  box-shadow: var(--im-shadow);
  padding: 2.5rem 3rem;
  min-width: 0;
}

.proposal-content > hr:first-child {
  display: none;
}

.proposal-content h2 {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.625rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--im-navy);
  border-bottom: 2px solid var(--im-bg);
  scroll-margin-top: calc(var(--im-header) + 1rem);
}

.proposal-content h2:first-child {
  margin-top: 0;
}

.proposal-content h3 {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--im-navy);
}

.proposal-content h4 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--im-muted);
}

.proposal-content p {
  margin: 0 0 1rem;
  color: var(--im-text);
}

.proposal-content ul,
.proposal-content ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.proposal-content li {
  margin-bottom: 0.375rem;
}

.proposal-content li::marker {
  color: var(--im-orange);
}

.proposal-content strong {
  font-weight: 600;
  color: var(--im-navy);
}

.proposal-content blockquote {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  background: var(--im-bg);
  border-left: 4px solid var(--im-blue);
  border-radius: 0 var(--im-radius) var(--im-radius) 0;
  color: var(--im-navy);
  font-weight: 500;
}

.proposal-content blockquote p {
  margin: 0;
}

.proposal-content pre {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  background: var(--im-navy);
  color: #dbe9f6;
  border-radius: var(--im-radius);
  font-size: 0.8125rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.proposal-content code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.875em;
}

.proposal-content p code,
.proposal-content li code {
  background: var(--im-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  color: var(--im-blue-dark);
}

.proposal-content table {
  width: 100%;
  min-width: 36rem;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.875rem;
  box-shadow: var(--im-shadow);
  border-radius: var(--im-radius);
  overflow: hidden;
}

.table-scroll {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 1.25rem 0 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--im-radius);
  border: 1px solid var(--im-border);
  background: var(--im-bg-white);
}

.table-scroll::after {
  content: '';
  position: sticky;
  top: 0;
  right: 0;
  float: right;
  width: 1.5rem;
  height: 100%;
  margin-left: -1.5rem;
  pointer-events: none;
  background: linear-gradient(to left, rgb(255 255 255 / 0.95), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.table-scroll.is-scrollable::after {
  opacity: 1;
}

.table-scroll table {
  border-radius: 0;
  box-shadow: none;
  border: none;
}

.proposal-content thead {
  background: var(--im-navy);
  color: #fff;
}

.proposal-content th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
}

.proposal-content td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--im-border);
  vertical-align: top;
}

.proposal-content tbody tr:nth-child(even) {
  background: var(--im-bg);
}

.proposal-content tbody tr:last-child td {
  border-bottom: none;
}

.proposal-content tbody tr:hover {
  background: #e8f0fe;
}

.proposal-content hr {
  border: none;
  border-top: 1px solid var(--im-border);
  margin: 2rem 0;
}

.proposal-content em {
  font-style: italic;
  color: var(--im-muted);
  font-size: 0.875rem;
}

/* Hide duplicate markdown TOC */
.proposal-content h2#table-of-contents,
.proposal-content h2:first-of-type + ul {
  /* kept for anchor compatibility */
}

/* ── Footer ── */
.site-footer {
  background: var(--im-navy);
  color: #fff;
  padding: 2.5rem 1.5rem;
  margin-top: 0;
}

.footer-inner {
  max-width: var(--im-max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.footer-brand img {
  height: 2rem;
  opacity: 0.95;
}

.footer-contact {
  font-size: 0.875rem;
  color: rgb(255 255 255 / 0.7);
}

.footer-contact a {
  color: #fff;
}

.footer-contact a:hover {
  color: var(--im-orange);
}

.footer-sep {
  margin: 0 0.375rem;
}

.footer-copy {
  width: 100%;
  padding-top: 1.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--im-dark-border, #224767);
  font-size: 0.8125rem;
  color: rgb(255 255 255 / 0.55);
  text-align: center;
}

/* ── Mobile TOC toggle (tablet inline) ── */
.toc-toggle {
  display: none;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--im-bg-white);
  border: 1px solid var(--im-border);
  border-radius: var(--im-radius);
  font-family: var(--im-font);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--im-navy);
  cursor: pointer;
}

/* ── Floating action buttons ── */
.mobile-fab-group {
  display: flex;
  position: fixed;
  right: max(1.5rem, env(safe-area-inset-right, 0px));
  bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  z-index: 90;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 18px rgb(16 44 70 / 0.22);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s, visibility 0.2s;
}

.fab:active {
  transform: scale(0.95);
}

.fab-toc {
  background: var(--im-blue);
  color: #fff;
}

.fab-toc:hover {
  background: var(--im-blue-dark);
}

.fab-toc svg {
  width: 1.375rem;
  height: 1.375rem;
}

@media (min-width: 769px) {
  .fab.fab-toc {
    display: none;
  }
}

.fab-scroll-top {
  background: #fff;
  color: var(--im-blue);
  border: 1px solid var(--im-border);
}

.fab-scroll-top:hover {
  background: var(--im-bg);
}

.fab-scroll-top img {
  width: 1.5rem;
  height: 1.5rem;
  display: block;
}

.fab-scroll-top[hidden] {
  display: none;
}

/* ── Mobile TOC drawer ── */
.toc-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  visibility: hidden;
}

.toc-drawer.is-open {
  pointer-events: auto;
  visibility: visible;
}

.toc-drawer-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  background: rgb(16 44 70 / 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
  cursor: pointer;
}

.toc-drawer.is-open .toc-drawer-backdrop {
  opacity: 1;
}

.toc-drawer-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(78vh, 36rem);
  background: var(--im-bg-white);
  border-radius: var(--im-radius) var(--im-radius) 0 0;
  box-shadow: 0 -8px 32px rgb(16 44 70 / 0.18);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.toc-drawer.is-open .toc-drawer-panel {
  transform: translateY(0);
}

.toc-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--im-border);
  flex-shrink: 0;
}

.toc-drawer-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--im-navy);
}

.toc-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--im-bg);
  color: var(--im-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.toc-drawer-close svg {
  width: 1.125rem;
  height: 1.125rem;
}

.toc-drawer-nav {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0 1rem;
}

.toc-drawer-nav .toc-list a {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
}

body.toc-drawer-open {
  overflow: hidden;
}

/* ── PDF export staging ── */
#pdf-staging {
  position: fixed;
  left: -20000px;
  top: 0;
  width: 794px;
  z-index: -1;
  pointer-events: none;
  opacity: 1;
}

.pdf-export-section {
  width: 794px;
  background: #fff;
}

.pdf-export-section .hero {
  padding: 2rem 2.5rem 2.5rem;
}

.pdf-export-section .proposal-content {
  box-shadow: none;
  border: none;
  border-radius: 0;
  padding: 1.5rem 2.5rem 2rem;
}

.pdf-export-section .site-footer {
  margin-top: 0;
}

body.is-pdf-export .site-header,
body.is-pdf-export .sidebar,
body.is-pdf-export .toc-toggle,
body.is-pdf-export .mobile-fab-group,
body.is-pdf-export .toc-drawer {
  visibility: hidden;
}

/* ── Print / PDF ── */
@media print {
  body {
    background: #fff;
  }

  .site-header,
  .sidebar,
  .toc-toggle,
  .btn-pdf,
  .mobile-fab-group,
  .toc-drawer,
  #pdf-staging {
    display: none !important;
  }

  #pdf-root {
    display: block;
  }

  .hero {
    padding: 2rem 1.5rem;
    break-after: page;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .proposal-layout {
    display: block;
    padding: 0;
  }

  .proposal-content {
    box-shadow: none;
    border: none;
    padding: 1rem 1.5rem;
  }

  .proposal-content h2 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .proposal-content table,
  .proposal-content pre,
  .proposal-content blockquote {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .site-footer {
    break-before: auto;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  a {
    color: var(--im-navy);
    text-decoration: none;
  }
}

@media (min-width: 640px) {
  :root {
    --im-header: 6rem;
  }
}

@media (max-width: 1024px) {
  .proposal-layout {
    grid-template-columns: 1fr;
    padding: 1.75rem 1rem 3rem;
  }

  .sidebar {
    position: static;
    max-height: none;
    display: none;
  }

  .sidebar.is-open {
    display: block;
  }

  .toc-toggle {
    display: block;
  }

  .proposal-content {
    padding: 1.75rem 1.25rem;
  }
}

@media (max-width: 768px) {
  .toc-toggle {
    display: none;
  }

  .mobile-fab-group {
    right: max(1rem, env(safe-area-inset-right, 0px));
    bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  }

  .header-inner {
    padding: 0 1rem;
  }

  .hero {
    padding: 2.5rem 1rem 3rem;
  }

  .hero::before {
    inset: -10% -40% -10% 0;
    background: radial-gradient(circle at 85% 35%, rgb(0 85 255 / 0.32) 0%, transparent 58%);
  }

  .proposal-layout {
    padding: 1.5rem 0.75rem 5.5rem;
    gap: 0;
  }

  .proposal-content {
    padding: 1.25rem 1rem;
    border-radius: calc(var(--im-radius) - 0.125rem);
  }

  .proposal-content h2 {
    font-size: 1.3125rem;
    margin-top: 2rem;
  }

  .proposal-content h3 {
    font-size: 1.0625rem;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .footer-sep--before-address {
    display: none;
  }

  .footer-address {
    display: block;
    margin-top: 0.375rem;
  }

  .footer-copy {
    text-align: left;
  }
}

@media (max-width: 640px) {
  .header-divider,
  .header-title {
    display: none;
  }

  .header-brand > a {
    max-width: min(350px, calc(100vw - 5.5rem));
  }

  .btn-pdf {
    width: 2.125rem;
    height: 2.125rem;
    padding: 0;
    justify-content: center;
    gap: 0;
    border-radius: 50%;
    box-shadow: 0 3px 10px rgb(254 98 29 / 0.3);
  }

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

  .btn-pdf-label {
    display: none;
  }

  .hero-meta {
    grid-template-columns: 1fr;
  }

  .meta-card {
    padding: 0.875rem 1rem;
  }

  .proposal-content {
    padding: 1.125rem 0.875rem;
  }

  .proposal-content table {
    font-size: 0.8125rem;
    min-width: 32rem;
  }

  .proposal-content th,
  .proposal-content td {
    padding: 0.5625rem 0.75rem;
    line-height: 1.45;
  }

  .proposal-content ul,
  .proposal-content ol {
    padding-left: 1.25rem;
  }

  .proposal-content pre {
    font-size: 0.75rem;
    padding: 0.875rem 1rem;
  }

  .table-scroll {
    margin-left: -0.125rem;
    margin-right: -0.125rem;
    width: calc(100% + 0.25rem);
  }
}

@media (max-width: 480px) {
  .header-inner {
    gap: 0.5rem;
  }

  .btn-pdf {
    width: 1.875rem;
    height: 1.875rem;
  }

  .btn-pdf svg {
    width: 0.9375rem;
    height: 0.9375rem;
  }

  .fab {
    width: 2.75rem;
    height: 2.75rem;
  }

  .hero h1 {
    font-size: 1.625rem;
  }

  .hero-subtitle {
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
  }

  .proposal-content table {
    min-width: 28rem;
  }
}
