/* ============================================================
   tofa docs — elevated layer
   Loaded after theme.css. Styles the search dialog, the
   two-column landing hero, the richer cards, and the guide
   header, and raises the layout/contrast baseline without
   changing the design language: tofa.tv navy/foam world, teal
   accent, glass button grammar, Inter Tight + system mono.
   ============================================================ */

/* ---- token adjustments -------------------------------------
   ink-40/ink-58 keep the elevated redesign's raised AA alphas,
   re-derived on the foam/navy base; teal reads fine on the dark
   paper but not on the light one, so text-teal gets its own
   token that darkens in light mode. --teal-rim/--surface back
   the glass button grammar (hover rim, selected solid fill). */
:root {
  --maxw: 1340px;
  --ink-78: rgba(240, 253, 250, 0.82);
  --ink-58: rgba(240, 253, 250, 0.7);
  --ink-40: rgba(240, 253, 250, 0.56);
  --teal-text: var(--teal);
  --focus: var(--teal-text);
  --teal-rim: rgba(94, 234, 212, 0.75);
  --surface: #0c2a3d;
}
:root[data-theme="light"] {
  --ink-78: rgba(6, 23, 31, 0.82);
  --ink-58: rgba(6, 23, 31, 0.72);
  --ink-40: rgba(6, 23, 31, 0.6);
  --teal-text: #0a6a60;
  --focus: var(--teal-text);
  --teal-rim: #0a6a60;
  --surface: #06171f;
}

/* teal used as text follows the readable variant */
.tlink,
.eyebrow,
.doc h2 .num,
.doc a:not(.tlink):not(.anchor),
.tab-list button.active,
.card .card-idx,
.note .note-label,
pre .k,
.copy-code:hover, .copy-page:hover,
.copy-code.copied, .copy-page.copied {
  color: var(--teal-text);
}
.tab-list button.active { border-bottom-color: var(--teal-text); }
.copy-code:hover, .copy-page:hover,
.copy-code.copied, .copy-page.copied { border-color: var(--teal-text); }

/* guide body links: distinguishable beyond color */
.doc .doc-body a:not(.anchor) {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--teal-text) 55%, transparent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.doc .doc-body a:not(.anchor):hover { text-decoration-color: var(--teal-text); }

/* one strong global focus treatment */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.card:focus-visible, .pager a:focus-visible, .search-result:focus-visible,
.platform-links a:focus-visible, .hero-search:focus-visible {
  outline-offset: -2px;
}

/* ---- keyboard hint chip ---- */
kbd {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-58);
  border: 1px solid var(--line);
  background: var(--tint-2);
  padding: 2px 6px;
  min-width: 1.6em;
  text-align: center;
  border-radius: 10px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   search
   ============================================================ */
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 8px 0 12px; margin-right: 4px;
  border: 1px solid var(--line); background: var(--tint-2); border-radius: 9px;
  color: var(--ink-58); cursor: pointer;
  font-family: var(--sans); font-weight: 500;
  letter-spacing: -0.005em; font-size: 0.85rem;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.search-trigger:hover {
  color: var(--teal-text, var(--teal)); border-color: var(--teal-rim, var(--teal));
  background: rgba(45, 212, 191, 0.17);
}
.search-trigger svg,
.hero-search svg,
.search-head svg {
  width: 14px; height: 14px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: square;
}

.search-dialog {
  border: 1px solid var(--border-strong);
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  width: min(620px, calc(100vw - 32px));
  margin: clamp(24px, 12vh, 120px) auto auto;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.search-dialog::backdrop {
  background: rgba(3, 11, 16, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.search-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  color: var(--ink-58);
}
.search-head input[type="search"] {
  flex: 1; min-width: 0;
  font-family: var(--sans); font-size: 1.02rem;
  color: var(--ink); background: transparent; border: 0; padding: 2px 0;
}
.search-head input[type="search"]:focus { outline: none; }
.search-head input::placeholder { color: var(--ink-40); }
.search-head input::-webkit-search-cancel-button { display: none; }
.search-close {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  border: 1px solid var(--line); background: transparent;
  color: var(--ink-58); cursor: pointer; font-size: 1rem; line-height: 1;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.search-close:hover { color: var(--teal-text, var(--teal)); border-color: var(--teal-rim, var(--teal)); }
.search-body { padding: 14px 16px 16px; min-height: 180px; }
.search-status { color: var(--ink-40); margin: 0 0 10px; }
.search-results { display: grid; gap: 6px; }
.search-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "meta arrow" "title arrow" "summary arrow";
  align-items: center; column-gap: 12px;
  border: 1px solid var(--line); padding: 10px 14px;
  border-radius: 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.search-result:hover { border-color: var(--teal-rim); background: rgba(45, 212, 191, 0.1); }
.search-result-meta {
  grid-area: meta;
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.6rem; color: var(--teal-text);
  margin-bottom: 2px;
}
.search-result strong {
  grid-area: title;
  font-weight: 700; letter-spacing: -0.01em; font-size: 0.98rem;
}
.search-result-summary {
  grid-area: summary;
  color: var(--ink-58); font-size: 0.84rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-result-arrow {
  grid-area: arrow;
  color: var(--ink-40); transition: color 0.15s ease, transform 0.15s ease;
}
.search-result:hover .search-result-arrow {
  color: var(--teal-text); transform: translateX(3px);
}
.search-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--line-soft);
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; font-size: 0.58rem; color: var(--ink-40);
}
.search-foot kbd { margin-right: 4px; }

/* ============================================================
   landing: two-column hero + setup panel
   ============================================================ */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(32px, 5vw, 72px);
  align-items: start;
  padding: 64px 0 56px;
}
.hero .hero-copy h1 { margin-bottom: 20px; }
.hero .lede { margin-bottom: 0; }
.hero .cta { margin-top: 28px; }

.hero-search {
  display: flex; align-items: center; gap: 14px;
  width: min(100%, 480px); margin-top: 28px;
  padding: 14px 16px; text-align: left;
  border: 1px solid var(--line); background: var(--tint-2);
  color: var(--ink-58); cursor: pointer; font-family: var(--sans);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.hero-search:hover { border-color: var(--border-strong); color: var(--ink); background: var(--tint); }
.hero-search > span { flex: 1; min-width: 0; display: grid; gap: 1px; }
.hero-search strong { font-weight: 700; font-size: 0.96rem; letter-spacing: -0.01em; color: var(--ink); }
.hero-search small { font-size: 0.82rem; color: var(--ink-58); }

.hero-rail {
  display: grid; gap: 24px; align-content: start; align-items: start;
  grid-template-columns: repeat(2, minmax(280px, 340px));
}

.setup-panel {
  border: 1px solid var(--line);
  background: var(--paper-2);
  padding: 24px 24px 20px;
  border-radius: 16px;
  position: relative;
  transition: border-color 0.2s ease;
}
.setup-panel:hover { border-color: var(--teal-rim); }
.setup-panel > .label { color: var(--teal-text); margin: 0 0 14px; }
.setup-panel h2 {
  font-size: 1.3rem; font-weight: 800; letter-spacing: -0.025em;
  line-height: 1.15; margin: 0 0 8px;
}
.setup-panel > p:not(.label) { color: var(--ink-58); font-size: 0.92rem; margin: 0 0 18px; }
.platform-links { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.platform-links a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  transition: background 0.15s ease;
}
.platform-links a + a { border-top: 1px solid var(--line); }
.platform-links a:hover { background: var(--tint); }
.platform-links a > span:first-child { display: grid; gap: 1px; min-width: 0; }
.platform-links strong { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.01em; }
.platform-links small {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; font-size: 0.58rem; color: var(--ink-40);
}
.platform-links a > span[aria-hidden] { color: var(--ink-40); transition: color 0.15s ease, transform 0.15s ease; }
.platform-links a:hover { background: rgba(45, 212, 191, 0.1); }
.platform-links a:hover > span[aria-hidden] { color: var(--teal-text); transform: translateX(3px); }
.manual-link {
  display: inline-block; margin-top: 14px;
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; font-size: 0.62rem; color: var(--ink-58);
}
.manual-link:hover { color: var(--teal-text); }

/* ---- category headings ---- */
.cat-block { padding: 52px 0; }
.cat-heading {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 26px;
}
.cat-heading h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.75rem); font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.05; margin: 0 0 6px;
}
.cat-heading p { color: var(--ink-58); font-size: 0.95rem; margin: 0; max-width: 52ch; }
.cat-count {
  flex: none; color: var(--ink-40);
  border: 1px solid var(--line); padding: 5px 9px;
  border-radius: 10px;
}

/* ---- cards ---- */
.card { display: flex; flex-direction: column; }
.card .card-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card .card-idx { margin-bottom: 0; }
.card .card-time {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 0.6rem; color: var(--ink-40);
}
.card .card-sum { flex: 1; }
.card .card-go {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 18px;
}
.card .card-arrow { transition: transform 0.2s ease; }
.card:hover { transform: translateY(-2px); }
.card:hover .card-arrow { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) {
  .card:hover { transform: none; }
  .card:hover .card-arrow, .search-result:hover .search-result-arrow,
  .platform-links a:hover > span[aria-hidden] { transform: none; }
}

/* ============================================================
   guide pages: wider measure, header, tools
   ============================================================ */
.shell { grid-template-columns: 224px minmax(0, 1fr); gap: 48px; }
.shell.with-toc { grid-template-columns: 224px minmax(0, 1fr) 192px; }
main.doc { max-width: 780px; }
.doc p, .doc ul, .doc ol { max-width: 70ch; }
.doc table { max-width: 100%; }
.note, .cb-form { max-width: 70ch; }

.doc-header { border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 8px; }
.doc-header h1 { margin-bottom: 14px; max-width: 22ch; }
.doc-header .lede { margin-bottom: 18px; }
.doc-tools { display: flex; align-items: center; gap: 12px; }
.doc-read-time {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; font-size: 0.62rem; color: var(--ink-58);
}
.doc-tool-sep { width: 1px; height: 14px; background: var(--line); }
.doc-body > h2:first-child { border-top: 0; padding-top: 8px; margin-top: 24px; }

/* ---- download row (::: downloads) ----
   Wider than the 70ch prose measure on purpose: it is the page's errand, not
   part of the reading column. auto-fit collapses 3 up to 1 with no breakpoint. */
.downloads {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 10px;
  margin: 24px 0 30px;
}
/* out-specifies the doc-body prose-link underline, which is (0,3,1) */
.doc .doc-body .downloads .dl, .downloads .dl {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--tint-2);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.downloads .dl-text { display: grid; gap: 3px; min-width: 0; }
.downloads .dl strong {
  font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--ink);
}
.downloads .dl-meta { font-size: 0.78rem; color: var(--ink-58); }
.downloads .dl-arrow {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: var(--ink-40); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
  transition: stroke 0.15s ease, transform 0.2s ease;
}
.downloads .dl:hover {
  background: rgba(45, 212, 191, 0.1);
  border-color: var(--teal-rim);
}
.downloads .dl:hover .dl-arrow { stroke: var(--teal-text); transform: translateY(2px); }
.downloads .dl:focus-visible { outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) {
  .downloads .dl:hover .dl-arrow { transform: none; }
}

/* ============================================================
   responsive: rails, tabs, small screens
   ============================================================ */
@media (max-width: 1180px) {
  .shell.with-toc { grid-template-columns: 224px minmax(0, 1fr); }
  aside.toc { display: none; }
  .hero-rail { grid-template-columns: minmax(300px, 380px); }
}
@media (max-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 36px; padding: 52px 0 44px; }
  .setup-panel { max-width: 520px; }
  .hero-rail { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); max-width: 1064px; }
}
@media (max-width: 860px) {
  .shell, .shell.with-toc { grid-template-columns: 1fr; gap: 0; }
  main.doc { max-width: none; padding-top: 32px; }
}
@media (max-width: 720px) {
  /* tables scroll inside themselves instead of stretching the page */
  .doc table { display: block; overflow-x: auto; width: 100%; }
  .cat-heading { flex-direction: column; align-items: flex-start; gap: 10px; }
  .cat-count { order: -1; }
}
@media (max-width: 640px) {
  .nav-right .nav-link { display: none; }
  .search-trigger { padding: 0; width: 34px; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .hero-search kbd { display: none; }
  .search-foot span:last-child { display: none; }
}

/* tab strips scroll horizontally when they run out of room */
.tab-list {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-list::-webkit-scrollbar { display: none; }
.tab-list button { white-space: nowrap; flex: none; }

/* 320px: keep everything inside the viewport */
@media (max-width: 380px) {
  .brand .tag { display: none; }
  .nav-in { gap: 12px; }
  .hero { padding-top: 40px; }
  .hero h1 { font-size: 1.9rem; }
  .setup-panel { padding: 18px 16px 16px; }
  .platform-links a { padding: 10px 12px; }
  .btn { padding: 11px 14px; }
  pre { padding: 14px 14px; }
  .cb-form { padding: 16px 14px; }
  .search-body { padding: 12px 12px 14px; }
  .search-head { padding: 12px; }
}
.doc code { overflow-wrap: anywhere; }
.doc td code, pre code { overflow-wrap: normal; }
h1, .card .card-ttl, .pager .ttl { overflow-wrap: break-word; }

/* Shared public-site navigation; guide tools have their own secondary row. */
header.site-nav { position: relative; background: rgba(7,26,38,.94); color: #f0fdfa; border-color: rgba(240,253,250,.14); }
.site-nav .brand, .site-nav a { color: #f0fdfa; text-decoration: none; }
.site-links, .site-actions { display: flex; align-items: center; gap: 2px; }
.site-nav .nav-link { color: rgba(240,253,250,.7); }
.site-nav .nav-link:hover, .site-nav .nav-link.current { color: #f0fdfa; background: rgba(240,253,250,.06); }
.site-actions { gap: 6px; }
.site-signup { font-size: 14px; font-weight: 600; line-height: 1.25; padding: 9px 18px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; background: rgba(255,255,255,.11); box-shadow: 0 8px 32px #0004, inset 0 1px 0 #ffffff0d; }
.site-signup:hover { background: rgba(45,212,191,.17); border-color: #5eead4; }
.site-menu { display: none; position: relative; }
.site-menu summary { list-style: none; padding: 12px; cursor: pointer; font-size: 14px; color: rgba(240,253,250,.7); }
.site-menu summary::-webkit-details-marker { display: none; }
.site-menu nav { position: absolute; right: 0; top: calc(100% + 10px); min-width: 180px; display: grid; padding: 8px; border: 1px solid #ffffff24; border-radius: 12px; background: #071a26; box-shadow: 0 18px 40px #0008; }
.docs-tools { max-width: 1060px; margin: 20px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--ink-58); }
.docs-tools > div { display: flex; align-items: center; gap: 10px; }
.docs-tools a { color: var(--ink-58); }
.docs-tools .search-trigger { margin: 0; }
@media(max-width:1120px) { .docs-tools { margin-inline: 24px; } }
@media(max-width:820px) { .site-links, .site-signin { display: none; } .site-menu { display: block; } }
@media(max-width:480px) { .docs-tools .docs-api { display: none; } .site-nav .nav-in { gap: 8px; } .site-signup { padding: 9px 12px; } }

.site-nav [hidden] { display: none; }
