/* ============================================================
   CYRONIX OS — Digital Ecosystem CSS & Architecture Components
   Complements styles.css with multi-page ecosystem utilities,
   interactive phone simulator, live OTA inspector, search modal,
   and responsive WCAG 2.2 AA layouts.
   ============================================================ */

/* Global skip link */
.skip-link {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 9999;
  background: var(--accent);
  color: #04120B;
  padding: 10px 18px;
  font-weight: 700;
  border-radius: 8px;
  transition: top var(--fast);
  text-decoration: none;
}
.skip-link:focus {
  top: 16px;
}

/* Page Hero layout for subpages */
.page-hero {
  padding: 130px 0 50px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.page-hero .eyebrow {
  margin-bottom: 12px;
}
.page-hero h1 {
  font-size: clamp(2.4rem, 5.5vw, 4.2rem);
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}
.page-hero .lead {
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
  color: var(--muted);
  max-width: 72ch;
}
.page-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 20px;
}
.breadcrumbs a {
  color: var(--muted);
  transition: color var(--fast);
}
.breadcrumbs a:hover {
  color: var(--accent);
}
.breadcrumbs .sep {
  opacity: 0.4;
}
.breadcrumbs .current {
  color: var(--text);
  font-weight: 600;
}

/* Subnav & secondary chapter navigation */
.subnav-bar {
  position: sticky;
  top: 70px;
  z-index: 80;
  background: color-mix(in srgb, var(--header) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  overflow-x: auto;
  white-space: nowrap;
}
.subnav-links {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.subnav-links a {
  font-size: 0.86rem;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: all var(--fast);
}
.subnav-links a:hover,
.subnav-links a.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-2);
}

/* Search bar trigger */
.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all var(--fast);
}
.search-btn:hover {
  border-color: var(--border-2);
  color: var(--text);
}
.search-btn kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: var(--f-mono);
}

/* Search Modal Overlay */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 7, 6, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 100px 16px 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.search-modal.open {
  opacity: 1;
  pointer-events: auto;
}
.search-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  box-shadow: 0 25px 80px -15px rgba(0, 0, 0, 0.8);
  width: 100%;
  max-width: 680px;
  border-radius: 16px;
  overflow: hidden;
  transform: translateY(-10px);
  transition: transform 0.2s ease;
}
.search-modal.open .search-card {
  transform: translateY(0);
}
.search-input-wrap {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.search-input-wrap svg {
  color: var(--accent);
  width: 20px;
  height: 20px;
}
.search-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 1.1rem;
  font-family: var(--f-ui);
  color: var(--text);
  width: 100%;
}
.search-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 12px;
}
.search-item {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  transition: background var(--fast);
}
.search-item:hover,
.search-item:focus {
  background: var(--surface-2);
  outline: none;
}
.search-item-cat {
  font-family: var(--f-mono);
  font-size: 0.68rem;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.search-item-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.98rem;
  margin-bottom: 4px;
}
.search-item-desc {
  font-size: 0.84rem;
  color: var(--muted);
}
.search-footer {
  padding: 10px 20px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 0.74rem;
  font-family: var(--f-mono);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

/* Grid & Card extensions */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  position: relative;
  transition: transform var(--fast), border-color var(--fast), box-shadow var(--fast);
}
.card:hover {
  border-color: var(--border-2);
  box-shadow: 0 16px 40px -15px rgba(0, 0, 0, 0.5);
}
.card-highlight {
  border-color: var(--border-2);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

/* Architecture Layer interactive explorer */
.arch-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 32px 0;
}
.arch-layer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--fast);
  display: flex;
  flex-direction: column;
}
.arch-layer:hover,
.arch-layer.active {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateX(6px);
}
.arch-layer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.arch-layer-title {
  font-family: var(--f-display);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}
.arch-layer-title .num {
  font-family: var(--f-mono);
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(30, 224, 122, 0.1);
  padding: 3px 8px;
  border-radius: 6px;
}
.arch-layer-body {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--muted);
  display: none;
}
.arch-layer.active .arch-layer-body {
  display: block;
}

/* Status Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 6px;
}
.badge-status.implemented {
  background: rgba(46, 230, 197, 0.12);
  color: var(--accent);
  border: 1px solid rgba(46, 230, 197, 0.3);
}
.badge-status.partial {
  background: rgba(255, 176, 32, 0.12);
  color: var(--warn);
  border: 1px solid rgba(255, 176, 32, 0.3);
}
.badge-status.experimental {
  background: rgba(150, 120, 255, 0.12);
  color: #9678FF;
  border: 1px solid rgba(150, 120, 255, 0.3);
}
.badge-status.blocked {
  background: rgba(255, 77, 94, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 77, 94, 0.3);
}
.badge-status.device-dep {
  background: rgba(25, 198, 242, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(25, 198, 242, 0.3);
}

/* Feature taxonomy filters */
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}
.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.78rem;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--fast);
}
.filter-btn:hover,
.filter-btn.active {
  background: var(--accent);
  color: #04120B;
  border-color: var(--accent);
  font-weight: 700;
}

/* Spec Tables */
.spec-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.spec-table th,
.spec-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.spec-table th {
  background: var(--surface);
  font-family: var(--f-mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.spec-table tr:last-child td {
  border-bottom: none;
}
.spec-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Terminal Shell Component */
.terminal {
  background: #030504;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  font-family: var(--f-mono);
  font-size: 0.88rem;
  box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.7);
}
.term-top {
  background: #080C0A;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
}
.term-top .tl {
  display: flex;
  gap: 6px;
}
.term-top .tl i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--faint);
}
.term-top .tl i:nth-child(1) { background: #FF5F56; }
.term-top .tl i:nth-child(2) { background: #FFBD2E; }
.term-top .tl i:nth-child(3) { background: #27C93F; }
.term-body {
  padding: 20px;
  line-height: 1.7;
  color: #DCF2E6;
  max-height: 380px;
  overflow-y: auto;
}
.term-line {
  margin-bottom: 4px;
  word-break: break-all;
}
.term-line .g { color: var(--accent); }
.term-line .c { color: var(--cyan); }
.term-line .m { color: var(--muted); }
.term-line .w { color: var(--warn); }
.term-line .d { color: var(--danger); }

/* Interactive Phone Visualizer */
.phone-visualizer {
  position: relative;
  width: 320px;
  height: 640px;
  background: #080A09;
  border-radius: 44px;
  border: 4px solid #1C2420;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08);
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.phone-visualizer .phone-screen {
  flex: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.phone-visualizer .status-bar {
  height: 28px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  color: var(--muted);
  z-index: 10;
}
.phone-visualizer .screen-content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.phone-app-drawer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 10px;
  text-align: center;
  margin-top: auto;
  padding-bottom: 12px;
}
.phone-app-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 6px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform var(--fast);
}
.phone-app-icon:hover {
  transform: scale(1.08);
}
.phone-app-name {
  font-size: 0.68rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.phone-nav-bar {
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 6px;
}
.phone-nav-bar::after {
  content: "";
  width: 90px;
  height: 4px;
  background: var(--muted);
  border-radius: 999px;
  opacity: 0.4;
}

/* Documentation Layout */
.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 48px;
  padding: 40px 0 80px;
}
.docs-sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.docs-sidebar-section {
  margin-bottom: 24px;
}
.docs-sidebar-title {
  font-family: var(--f-mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  padding-left: 10px;
}
.docs-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.docs-nav-list a {
  display: block;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  transition: all var(--fast);
}
.docs-nav-list a:hover,
.docs-nav-list a.active {
  color: var(--accent);
  background: var(--surface);
  font-weight: 600;
}
.docs-content {
  min-width: 0;
}
.docs-content h2 {
  font-size: 2rem;
  margin: 40px 0 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.docs-content h3 {
  font-size: 1.4rem;
  margin: 28px 0 12px;
}
.docs-content p,
.docs-content li {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
}
.docs-content code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--f-mono);
  font-size: 0.88em;
  color: var(--accent);
}
.docs-content pre {
  background: #030504;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  overflow-x: auto;
  font-family: var(--f-mono);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* Callout Boxes */
.callout {
  padding: 18px 22px;
  border-radius: 12px;
  margin: 24px 0;
  border-left: 4px solid var(--accent);
  background: var(--surface);
}
.callout-title {
  font-family: var(--f-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--accent);
}
.callout.warning {
  border-left-color: var(--warn);
  background: rgba(255, 176, 32, 0.05);
}
.callout.warning .callout-title {
  color: var(--warn);
}
.callout.danger {
  border-left-color: var(--danger);
  background: rgba(255, 77, 94, 0.05);
}
.callout.danger .callout-title {
  color: var(--danger);
}

/* Live OTA Status Indicator */
.ota-checker-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  padding: 32px;
  position: relative;
}
.ota-status-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: none;
}
.ota-status-ring.checking {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .docs-sidebar {
    position: static;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
  }
}

@media (max-width: 640px) {
  .page-hero {
    padding: 100px 0 36px;
  }
  .page-hero h1 {
    font-size: 2.2rem;
  }
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .search-modal {
    padding: 60px 12px;
  }
  .phone-visualizer {
    width: 290px;
    height: 580px;
  }
}
