/*
 * CAN Analyzer — product page, user guide and home-page section.
 * Built on the tokens in ../styles.css (--primary-color, --glass-bg, …) so it
 * follows the site's light/dark theme automatically.
 */

/* Local tokens, flipped by the site's existing body.dark-mode switch */
body {
  --ca-surface: rgba(0, 0, 0, 0.04);
  --ca-rule: rgba(0, 0, 0, 0.12);
  --ca-th-bg: rgba(108, 92, 231, 0.09);
  --ca-danger: #d63031;
}

body.dark-mode {
  --ca-surface: rgba(255, 255, 255, 0.05);
  --ca-rule: rgba(255, 255, 255, 0.09);
  --ca-th-bg: rgba(162, 155, 254, 0.1);
  --ca-danger: #ff7675;
}

/* ===========================================================================
   Downloads — shared by the home page section and the product page
   =========================================================================== */

.dl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.dl-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.75rem;
}

.dl-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dl-icon {
  font-size: 2rem;
  color: var(--secondary-color);
  flex-shrink: 0;
}

.dl-platform {
  font-size: 1.15rem;
  margin-bottom: 2px;
}

.dl-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.dl-file {
  font-family: var(--font-heading);
  opacity: 0.85;
  word-break: break-all;
}

.dl-size {
  color: var(--secondary-color);
  white-space: nowrap;
}

.dl-desc {
  font-size: 0.92rem;
  opacity: 0.85;
  flex-grow: 1;
  margin: 0;
}

.dl-action {
  text-align: center;
  margin-top: auto;
}

/* Unavailable entry: rendered as a <span>, so it is neither clickable nor
   focusable. It must read as "not ready yet", never as "broken". */
.dl-card-unavailable {
  opacity: 0.55;
}

.dl-card-unavailable:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--glass-border);
}

.dl-action-disabled {
  display: inline-block;
  padding: 10px 25px;
  border: 1px dashed var(--ca-rule);
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: not-allowed;
  color: var(--text-color);
  opacity: 0.7;
}

.dl-badge {
  padding: 3px 10px;
  border-radius: 15px;
  background: var(--ca-surface);
  border: 1px solid var(--ca-rule);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Calm note about the unsigned executable */
.ca-note {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 1.5rem;
  padding: 1.1rem 1.4rem;
  background: var(--ca-surface);
  border: 1px solid var(--ca-rule);
  border-left: 3px solid var(--secondary-color);
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0.92;
}

.ca-note i {
  color: var(--secondary-color);
  margin-top: 3px;
}

.ca-note p + p {
  margin-top: 0.5rem;
}

/* ===========================================================================
   Home page section
   =========================================================================== */

.ca-home-intro {
  display: flex;
  gap: 2.5rem;
  align-items: center;
  margin-bottom: 2.5rem;
  padding: 2.5rem;
}

.ca-home-intro:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--glass-border);
}

.ca-logo {
  width: 130px;
  height: 130px;
  flex-shrink: 0;
  object-fit: contain;
}

.ca-home-text h3 {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.ca-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (max-width: 768px) {
  .ca-home-intro {
    flex-direction: column;
    text-align: center;
    padding: 2rem 1.5rem;
  }

  .ca-home-actions {
    justify-content: center;
  }
}

/* ===========================================================================
   Sub-page shell (product page + guide)
   =========================================================================== */

.ca-page {
  padding-top: 120px;
  padding-bottom: 4rem;
  min-height: 80vh;
}

.ca-hero {
  display: flex;
  gap: 2.5rem;
  align-items: center;
  margin-bottom: 4rem;
}

.ca-hero .ca-logo {
  width: 160px;
  height: 160px;
}

.ca-hero h1 {
  font-size: 2.4rem;
  line-height: 1.2;
}

.ca-hero .ca-tagline {
  color: var(--secondary-color);
  font-weight: 600;
  margin-bottom: 1rem;
}

.ca-section {
  margin-bottom: 4rem;
  scroll-margin-top: 100px;
}

.ca-section > h2 {
  font-size: 1.8rem;
  margin-bottom: 1.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--glass-border);
}

@media (max-width: 768px) {
  .ca-page {
    padding-top: 100px;
  }

  .ca-hero {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
    margin-bottom: 3rem;
  }

  .ca-hero h1 {
    font-size: 1.8rem;
  }
}

/* ===========================================================================
   User guide
   =========================================================================== */

.guide-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 3rem;
  align-items: start;
}

.guide-toc {
  position: sticky;
  top: 110px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 1.5rem;
}

.guide-toc:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--glass-border);
}

.guide-toc > summary {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.guide-toc > summary::-webkit-details-marker {
  display: none;
}

.guide-toc > summary::after {
  content: '\f078'; /* chevron-down */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 0.75rem;
  margin-left: auto;
  opacity: 0.6;
  transition: transform 0.3s ease;
}

.guide-toc[open] > summary::after {
  transform: rotate(180deg);
}

.guide-toc ol {
  list-style: none;
  margin-top: 1.25rem;
  counter-reset: toc;
}

.guide-toc li {
  counter-increment: toc;
  margin-bottom: 2px;
}

.guide-toc a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-color);
  opacity: 0.8;
  border-left: 2px solid transparent;
}

.guide-toc a::before {
  content: counter(toc) '.';
  display: inline-block;
  width: 1.6em;
  opacity: 0.5;
  font-family: var(--font-heading);
}

.guide-toc a:hover,
.guide-toc a:focus-visible {
  background: var(--ca-surface);
  border-left-color: var(--primary-color);
  color: var(--primary-color);
  opacity: 1;
}

/* --- Guide body --------------------------------------------------------- */

.guide-body {
  min-width: 0; /* lets wide children scroll instead of stretching the grid */
  max-width: 78ch;
}

.guide-body h2 {
  font-size: 1.75rem;
  margin: 3.5rem 0 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--glass-border);
  scroll-margin-top: 100px;
}

.guide-body h2:first-child {
  margin-top: 0;
}

.guide-body h3 {
  font-size: 1.25rem;
  color: var(--primary-color);
  margin: 2.25rem 0 0.9rem;
  scroll-margin-top: 100px;
}

.guide-body p {
  margin-bottom: 1.1rem;
}

.guide-body ul,
.guide-body ol {
  margin: 0 0 1.1rem 1.4rem;
  padding-left: 0.5rem;
}

.guide-body li {
  margin-bottom: 0.55rem;
}

.guide-body li > ul,
.guide-body li > ol {
  margin-top: 0.55rem;
}

.guide-body strong {
  color: var(--text-color);
  font-weight: 600;
}

.guide-body hr {
  border: 0;
  border-top: 1px solid var(--glass-border);
  margin: 3rem 0;
}

.guide-body a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.guide-body a:hover {
  color: var(--secondary-color);
}

/* Inline code and fenced blocks */
.guide-body code,
.ca-section code {
  font-family: 'Consolas', 'SF Mono', 'Menlo', monospace;
  font-size: 0.875em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--ca-surface);
  border: 1px solid var(--ca-rule);
  word-break: break-word;
}

.guide-body pre {
  margin-bottom: 1.4rem;
  padding: 1.1rem 1.3rem;
  background: var(--ca-surface);
  border: 1px solid var(--ca-rule);
  border-radius: 10px;
  overflow-x: auto; /* long lines scroll inside the block */
}

.guide-body pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.86rem;
  line-height: 1.65;
  white-space: pre;
  word-break: normal;
  display: block;
}

/* Tables scroll inside their own container so the page never moves sideways */
.guide-table-wrap {
  overflow-x: auto;
  margin-bottom: 1.4rem;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
}

.guide-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  /* Narrow enough that short tables fit a phone without scrolling, wide enough
     that dense ones stay readable and scroll inside the wrapper instead. */
  min-width: 320px;
}

.guide-table-wrap th,
.guide-table-wrap td {
  padding: 11px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--ca-rule);
}

.guide-table-wrap th {
  background: var(--ca-th-bg);
  font-family: var(--font-heading);
  font-weight: 700;
  white-space: nowrap;
}

.guide-table-wrap tr:last-child td {
  border-bottom: 0;
}

.guide-table-wrap td:first-child {
  white-space: nowrap;
}

/* A two-column table whose first column is a label, with no header row */
.guide-table-wrap.no-head td:first-child {
  font-weight: 600;
  color: var(--primary-color);
}

/* Blockquote callouts (the guide's "Note:" / "Important:" asides) */
.guide-note {
  margin: 0 0 1.4rem;
  padding: 1.1rem 1.4rem;
  background: var(--ca-surface);
  border: 1px solid var(--ca-rule);
  border-left: 3px solid var(--primary-color);
  border-radius: 10px;
}

.guide-note > :last-child {
  margin-bottom: 0;
}

.guide-note.is-quote {
  border-left-color: var(--secondary-color);
  font-family: var(--font-heading);
  font-size: 1.05rem;
}

@media (max-width: 992px) {
  .guide-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .guide-toc {
    position: static;
    max-height: none;
  }

  .guide-body {
    max-width: none;
  }
}

@media (max-width: 768px) {
  .guide-body h2 {
    font-size: 1.4rem;
  }

  .guide-body h3 {
    font-size: 1.1rem;
  }

  .guide-body ul,
  .guide-body ol {
    margin-left: 1.1rem;
  }

  .guide-body pre {
    padding: 0.9rem 1rem;
  }
}

/* ===========================================================================
   Hardware enquiry
   =========================================================================== */

.enquiry-card {
  max-width: 640px;
  margin: 0 auto;
}

.enquiry-card:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--glass-border);
}

.enquiry-submit {
  display: inline-block;
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
}
