/* devices.css: device cards (rendered at build time by devices_render.py), the device search
   (devices.js), the address table and the 192.168 network map. Self-contained: build.py adds it to
   every page that has a data-devices block, so it must not rely on other page CSS. */

[hidden] { display: none !important; }

.devices { margin: 1rem 0 1.5rem; }
.device-list { display: grid; gap: 0.85rem; }
.device-list > .device-card { margin: 0; }

/* Card = router label sticker (.label in site.css) */
.device-card .label-title { flex-direction: column; align-items: flex-start; gap: 0.15rem; font-size: 1.0625rem; line-height: 1.3; margin-top: 0; }
.device-card .label-title small { font-size: 0.875rem; }
.device-card dl { grid-template-columns: minmax(4.75rem, max-content) minmax(0, 1fr); align-items: baseline; }
.device-card dd { font-weight: 600; }
.device-where { margin-bottom: 0.15rem !important; }
.device-where dd { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; }
.device-where a { display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0.2rem 0.6rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); font-weight: 700; text-decoration: none; white-space: nowrap; }
.device-where a::after { content: "↗"; margin-left: 0.3rem; font-weight: 400; color: var(--muted); }
.device-where a:hover { border-color: var(--wan); }

.device-block { border-top: 1px dashed #c4ccd4; margin-top: 0.7rem; padding-top: 0.65rem; }
.device-block > p { margin: 0.35rem 0 0; }
.device-block > dl { margin-top: 0.35rem; }
.device-block-title { font-weight: 700; margin: 0 !important; }

.device-type { display: inline-block; margin: 0 !important; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.01em; background: #e8f0fd; color: var(--wan-dark); }
.device-type[data-type="on-label"] { background: var(--lan-wash); color: #7a5306; }
.device-type[data-type="set-at-setup"] { background: #e8f5ee; color: #0e5c37; }
.device-type[data-type="app-only"], .device-type[data-type="none"] { background: var(--paper); color: var(--muted); }

.device-cred { display: inline-block; padding: 0.05rem 0.4rem; border: 1px solid #c4ccd4; border-radius: 4px; background: var(--paper); font: 700 1rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); word-break: break-all; }
.device-card .copy { min-height: 2rem; vertical-align: middle; }
.device-card .copy.is-done { color: var(--led); border-color: var(--led); }

.label-field { display: inline-block; margin: 0.15rem 0.2rem 0.15rem 0; padding: 0.05rem 0.45rem; border: 1px dashed #9aa6b2; border-radius: 4px; background: #fff; font-weight: 700; font-size: 0.9375rem; }

.device-path { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; list-style: none; padding: 0; margin: 0.4rem 0 0; font-size: 0.9375rem; }
.device-path li + li { margin-top: 0; }
.device-path li { display: inline-flex; align-items: center; gap: 0.3rem; }
.device-path li > span, .device-path li { font-weight: 600; }
.device-path li { padding: 0.15rem 0.5rem; border: 1px solid var(--rule); border-radius: var(--radius-label); background: var(--paper); }
.device-path li:last-child { background: var(--led); border-color: var(--led); color: #fff; }

.device-notes { margin: 0.7rem 0 0; font-size: 0.9375rem; color: var(--muted); }
.device-flag { margin: 0 0 0.5rem; font-size: 0.875rem; font-weight: 700; color: #7a5306; }
.device-source { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; margin: 0.7rem 0 0; padding-top: 0.5rem; border-top: 1px solid #e6eaee; font-size: 0.8125rem; color: var(--muted); }
.device-source a { color: var(--muted); }

/* Search (built by devices.js) */
.device-search { margin: 0 0 1rem; }
.device-search label { margin-bottom: 0.4rem; }
.device-search input[type="search"] { font-size: 1.125rem; border: 2px solid var(--ink); }
.device-search input[type="search"]:focus { outline: none; box-shadow: 0 0 0 3px rgba(29, 95, 209, 0.25); }
.device-suggest, .device-filter { margin-top: 0.6rem; }
.device-suggest .chip, .device-filter .chip { min-height: 2.5rem; padding: 0.4rem 0.8rem; }
.device-more-row { margin: 0.85rem 0 0; }
.device-more { width: 100%; white-space: normal; text-align: center; }
.device-status { margin: 0.6rem 0 0; font-size: 0.9375rem; color: var(--muted); }
.device-status:empty { display: none; }
.device-results { display: grid; gap: 0.85rem; }
.device-results > .device-card { margin: 0; }
.device-empty { border: 1px solid var(--rule); border-radius: var(--radius-label); background: var(--surface); padding: 0.8rem 0.95rem; }
.device-empty > :last-child { margin-bottom: 0; }

/* Address meaning (router-ip-addresses lookup) */
.address-meaning { border: 1px solid var(--rule); border-left: 4px solid var(--muted); border-radius: 0 var(--radius-label) var(--radius-label) 0; background: var(--surface); padding: 0.75rem 0.9rem; margin: 0.25rem 0 0.9rem; }
.address-meaning[data-kind="private"] { border-left-color: var(--led); }
.address-meaning[data-kind="cgnat"], .address-meaning[data-kind="link-local"], .address-meaning[data-kind="public"] { border-left-color: var(--lan); }
.address-meaning > :last-child { margin-bottom: 0; }
.address-meaning .ip { font-size: 1.25rem; }
.address-meaning .kind { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--paper); font-size: 0.8125rem; font-weight: 700; vertical-align: middle; }

/* Address table */
.devices-table td:first-child { white-space: nowrap; }
.devices-table tr:target td { background: var(--lan-wash); }

/* 192.168.N.x map: 16 x 16 squares, N = 16 * row + column */
.net-map { margin: 0.75rem 0 0.5rem; max-width: 22rem; }
.net-grid { position: relative; aspect-ratio: 1; border: 1px solid #c4ccd4; border-radius: var(--radius-label); background-color: #fff;
  background-image: linear-gradient(to right, #e6eaee 1px, transparent 1px), linear-gradient(to bottom, #e6eaee 1px, transparent 1px);
  background-size: 6.25% 6.25%; }
.net-cell, .net-you { position: absolute; left: calc(var(--x) * 6.25%); top: calc(var(--y) * 6.25%); width: 6.25%; height: 6.25%; }
.net-cell { display: grid; place-items: center; background: var(--wan); color: #fff; text-decoration: none; font-size: clamp(0.5rem, 2.2vw, 0.6875rem); font-weight: 700; font-variant-numeric: tabular-nums; border-radius: 2px; animation: net-cell-in 0.5s ease-out both; animation-delay: calc((var(--y) * 16 + var(--x)) * 4ms); }
.net-cell:hover, .net-cell:focus-visible { background: var(--wan-dark); color: #fff; z-index: 1; }
.net-you { border: 3px solid var(--lan); border-radius: 3px; box-shadow: 0 0 0 3px rgba(201, 138, 11, 0.3); z-index: 2; pointer-events: none; animation: net-you-pulse 1.6s ease-in-out infinite; }
.net-axis { display: flex; justify-content: space-between; max-width: 22rem; font-size: 0.8125rem; color: var(--muted); }
@keyframes net-cell-in { from { transform: scale(0.2); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes net-you-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(201, 138, 11, 0.3); } 50% { box-shadow: 0 0 0 7px rgba(201, 138, 11, 0.12); } }

/* Long lists: one row per device, tap to open its card (data-rows="true") */
.device-row { border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); padding: 0; margin: 0 0 0.45rem; }
.device-list > .device-row { margin: 0; }
.device-list:has(> .device-row) { gap: 0.45rem; }
.device-row:last-of-type { border-bottom: 1px solid var(--rule); }
.device-row > summary { list-style: none; display: flex; align-items: center; min-height: 3.25rem; padding: 0.55rem 2.4rem 0.55rem 0.85rem; position: relative; cursor: pointer; }
.device-row > summary::-webkit-details-marker { display: none; }
.device-row > summary::after { content: "+"; position: absolute; right: 0.9rem; top: 50%; transform: translateY(-50%); font-size: 1.35rem; font-weight: 400; color: var(--muted); }
.device-row[open] > summary::after { content: "−"; }
.device-row > summary .label-title { display: flex; flex-direction: column; gap: 0.1rem; border: 0; margin: 0; padding: 0; font-size: 1rem; }
.device-row[open] > summary { border-bottom: 1px dashed var(--rule); }
.device-row > .device-card { margin: 0; border: 0; box-shadow: none; border-radius: 0 0 10px 10px; }
