/**
 * Icon detail: a dialog with a large preview over the 24px grid, customization
 * (size, color, stroke) and code snippets for eight platforms.
 */

/* ============ Dialog ============ */
.detail {
  width: min(1040px, calc(100vw - var(--s-64)));
  max-width: none;
  max-height: calc(100dvh - var(--s-64));
  margin: auto;
  padding: 0;
  overflow: hidden auto;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg), 0 48px 96px -32px rgba(0, 0, 0, 0.35);
  outline: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.detail[open] { animation: detailIn 0.4s var(--ease-out); }
.detail.is-closing { animation: detailOut 0.22s var(--ease-out) forwards; }
.detail::backdrop {
  background: color-mix(in srgb, var(--bg) 55%, rgba(0, 0, 0, 0.35));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.detail[open]::backdrop { animation: fadeIn 0.3s var(--ease-out); }
.detail.is-closing::backdrop { animation: fadeOut 0.22s var(--ease-out) forwards; }
@keyframes detailIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes detailOut { to { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
html:has(.detail[open]) { overflow: hidden; }

/* ============ Stage: the icon over its grid ============ */
.detail__stage {
  position: relative;
  height: 320px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
  background-color: var(--surface-2);
  background-image: radial-gradient(var(--bg-dot) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: center;
  overflow: hidden;
}
.detail__grid, .detail__glyph {
  grid-area: 1 / 1;
  width: 192px;
  height: 192px; /* 8px per grid unit */
}
.detail__grid { overflow: visible; color: var(--ink); }
.detail__grid * { fill: none; stroke: currentColor; vector-effect: non-scaling-stroke; }
.detail__cells { stroke-width: 1; opacity: 0.08; }
.detail__keys > * { stroke-width: 1; opacity: 0.18; stroke-dasharray: 4 4; }
.detail__frame { stroke-width: 1; opacity: 0.24; }
.detail__glyph { position: relative; color: var(--detail-color, var(--ink)); }
.detail__glyph svg { width: 100%; height: 100%; overflow: visible; }
.detail__glyph.swap svg { animation: glyphIn 0.4s var(--ease-out); }
@keyframes glyphIn { from { opacity: 0; transform: scale(0.94); } }

.detail__nav, .detail__close {
  position: absolute;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  transition: color 0.2s, border-color 0.2s, opacity 0.2s;
}
.detail__nav:hover, .detail__close:hover { color: var(--ink); border-color: var(--line-strong); }
.detail__nav svg, .detail__close svg { width: 20px; height: 20px; }
.detail__nav { top: calc(50% - 20px); }
.detail__nav--prev { left: var(--s-24); }
.detail__nav--next { right: var(--s-24); }
.detail__nav:disabled { opacity: 0; pointer-events: none; }
.detail__close { top: var(--s-16); right: var(--s-16); }

.detail__actual {
  position: absolute;
  left: var(--s-16); bottom: var(--s-16);
  display: flex;
  align-items: center;
  gap: var(--s-12);
  height: 48px;
  padding: 0 var(--s-12) 0 var(--s-8);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.detail__actual-box {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  color: var(--detail-color, var(--ink));
}
.detail__actual-box svg { max-width: 32px; max-height: 32px; }
.detail__actual-label, .detail__spec {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--muted);
}
.detail__spec {
  position: absolute;
  right: var(--s-16); bottom: var(--s-16);
  margin: 0;
  line-height: 48px;
}

/* ============ Body ============ */
.detail__body { padding: var(--s-24) var(--s-32) var(--s-32); }
.detail__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-16);
  flex-wrap: wrap;
}
.detail__title { min-width: 0; }
.detail__eyebrow {
  display: flex;
  gap: var(--s-8);
  margin: 0 0 var(--s-8);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail__name {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-h3);
  font-weight: 500;
  line-height: 32px;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.detail__actions { display: flex; gap: var(--s-8); flex-wrap: wrap; }
.detail__copy { min-width: 112px; }

.detail__tags { display: flex; flex-wrap: wrap; gap: var(--s-8); margin: var(--s-16) 0 0; padding: 0; list-style: none; }
.detail__tags button {
  height: 24px;
  padding: 0 var(--s-8);
  border-radius: 99px;
  border: 1px solid var(--line);
  font-size: var(--fs-micro);
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s;
}
.detail__tags button:hover { color: var(--ink); border-color: var(--line-strong); }

.detail__cols {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: var(--s-32);
  margin-top: var(--s-24);
  padding-top: var(--s-24);
  border-top: 1px solid var(--line);
}
.detail__h {
  margin: 0 0 var(--s-16);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 16px;
}

/* ---------- Customize ---------- */
.dfield { margin-bottom: var(--s-24); }
.dfield__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--s-8);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.dfield__row output { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }
.dfield__note { margin: calc(var(--s-8) * -1) 0 var(--s-24); font-size: var(--fs-xs); color: var(--muted); }
.dfield__foot { display: flex; justify-content: flex-end; margin: calc(var(--s-8) * -1) 0 var(--s-16); }

.sizes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--s-4);
  margin-bottom: var(--s-8);
  padding: var(--s-4);
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.sizes button {
  height: 28px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--muted);
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}
.sizes button:hover { color: var(--ink); }
.sizes button[aria-checked='true'] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }

.detail__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-12) var(--s-16);
  margin: 0;
  padding-top: var(--s-16);
  border-top: 1px solid var(--line);
}
.detail__meta div { min-width: 0; }
.detail__meta dt { font-size: var(--fs-micro); color: var(--muted); }
.detail__meta dd { margin: var(--s-4) 0 0; font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Code ---------- */
.detail__code { min-width: 0; display: flex; flex-direction: column; }
.detail__code-head { display: flex; flex-direction: column; }
.fw {
  display: flex;
  gap: var(--s-4);
  margin-bottom: var(--s-12);
  overflow-x: auto;
  scrollbar-width: none;
}
.fw::-webkit-scrollbar { display: none; }
.fw button {
  flex-shrink: 0;
  height: 32px;
  padding: 0 var(--s-12);
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.fw button:hover { color: var(--ink); background: var(--surface-2); }
.fw button[aria-selected='true'] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

.codebox {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  overflow: hidden;
}
.codebox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-8);
  height: 48px;
  padding: 0 var(--s-8) 0 var(--s-16);
  border-bottom: 1px solid var(--line);
}
.codebox__file { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }
.codebox__copy {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  height: 32px;
  padding: 0 var(--s-12);
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.codebox__copy:hover { border-color: var(--line-strong); }
.codebox__copy svg, .detail__copy svg { width: 16px; height: 16px; }
.codebox__copy.is-copied, .detail__copy.is-copied { color: #fff; background: var(--success); border-color: var(--success); }
[data-theme='dark'] .codebox__copy.is-copied, [data-theme='dark'] .detail__copy.is-copied { color: #0a0a0a; }
.codebox__pre {
  height: 336px;
  margin: 0;
  padding: var(--s-16);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: 20px;
  tab-size: 2;
  color: var(--ink-2);
  outline: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.codebox__pre:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.codebox__pre .c { color: var(--faint); font-style: italic; }
.codebox__pre .s { color: var(--muted); }
.codebox__pre .t { color: var(--ink); font-weight: 500; }
.codebox__pre .a { color: var(--ink-2); opacity: 0.75; }
.codebox__pre .k { color: var(--ink); font-weight: 600; }
.detail__hint { margin: var(--s-12) 0 0; font-size: var(--fs-xs); color: var(--muted); }
.detail__hint code { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--ink); }

/* ============ Small screens: a bottom sheet ============ */
@media (max-width: 860px) {
  .detail__cols { grid-template-columns: 1fr; }
  .codebox__pre { height: 288px; }
}
@media (max-width: 600px) {
  .detail {
    width: 100vw;
    max-height: calc(100dvh - var(--s-32));
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
  }
  .detail[open] { animation-name: sheetUp; }
  .detail.is-closing { animation-name: sheetDown; }
  @keyframes sheetUp { from { transform: translateY(48px); opacity: 0; } }
  @keyframes sheetDown { to { transform: translateY(48px); opacity: 0; } }
  .detail__stage { height: 256px; }
  .detail__grid, .detail__glyph { width: 144px; height: 144px; }
  .detail__nav--prev { left: var(--s-12); }
  .detail__nav--next { right: var(--s-12); }
  .detail__spec { display: none; }
  .detail__body { padding: var(--s-24) var(--s-16) var(--s-32); }
  .detail__actions { width: 100%; }
  .detail__actions .btn { flex: 1; }
}

/* Pro styles: a chip in the eyebrow until the visitor has Pro */
.detail__pro { display: none; }
:root:not([data-pro]) .detail[data-tier='pro'] .detail__pro {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  font-weight: 500;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
}

/* Framework code comes with Max: a lock on the tab, the code blurred behind a short explanation */
.fw__lock { display: none; }
:root:not([data-max]) .fw__lock { display: inline-block; width: 12px; height: 12px; margin-left: 6px; vertical-align: -1px; opacity: 0.7; }
.codebox { position: relative; }
.codebox[data-locked] .codebox__pre { filter: blur(5px); opacity: 0.55; user-select: none; pointer-events: none; overflow: hidden; }
.codebox[data-locked] .codebox__copy { opacity: 0.5; }
.codebox__lock {
  position: absolute;
  inset: 48px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-16);
  padding: var(--s-24);
  text-align: center;
  animation: fadeIn 0.3s var(--ease-out);
}
.codebox__lock p { display: grid; gap: var(--s-4); max-width: 320px; margin: 0; }
.codebox__lock b { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }
.codebox__lock span { font-size: var(--fs-sm); color: var(--muted); text-wrap: pretty; }
