/* Permissions explorer — builds on site tokens from styles.css */

.permissions-page {
  --code-bg: #0a0e0c;
  --code-key: #7ee09a;
  --code-string: #c8d4cc;
  --code-punct: #6a7a6e;
  --code-number: #9ec8ff;
  --anno: var(--accent);
  --anno-active: #7ee09a;
  --max: 1200px;
}

.permissions-page .page {
  max-width: var(--max);
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.brand-link:hover {
  color: var(--text);
}

.brand-link .brand {
  font-size: 1.35rem;
}

.brand-link img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--border-strong);
}

.back-link {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
}

.permissions-hero {
  text-align: center;
  padding: 0.5rem 0 2rem;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 1.1rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0e1210;
  background: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
}

.permissions-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4.5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.permissions-hero .lead {
  margin: 0.9rem auto 0;
  max-width: 38rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.how-to {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem 1.25rem;
  margin: 1.5rem auto 0;
  max-width: 36rem;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.how-to li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.how-to-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  color: #0e1210;
  background: var(--accent);
}

/* Explorer layout */
.explorer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
  margin-top: 0.5rem;
}

@media (min-width: 960px) {
  .explorer {
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 1.25rem;
  }
}

.code-panel,
.explain-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.code-panel-header,
.explain-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
}

.code-panel-header h2,
.explain-panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.manifest-source {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.manifest-source a {
  color: var(--accent);
}

.code-scroll {
  max-height: min(70vh, 820px);
  overflow: auto;
  background: var(--code-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.manifest-code {
  margin: 0;
  padding: 1rem 0.75rem 1.5rem 0.5rem;
  font-family: "Cascadia Code", "Fira Code", "Consolas", "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--code-string);
  white-space: pre;
  tab-size: 2;
}

@media (min-width: 600px) {
  .manifest-code {
    font-size: 0.82rem;
    padding-left: 0.75rem;
  }
}

.manifest-code .line {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 1.55em;
  padding: 0 0.5rem 0 0.25rem;
  border-left: 3px solid transparent;
  border-radius: 0 4px 4px 0;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.manifest-code .line.is-active {
  background: rgba(61, 184, 90, 0.12);
  border-left-color: var(--accent);
}

.manifest-code .line.is-related {
  background: rgba(61, 184, 90, 0.06);
}

.line-gutter {
  flex: 0 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.55em;
}

.anno-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  color: #0e1210;
  background: var(--anno);
  box-shadow: 0 0 0 0 transparent;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.anno-btn:hover {
  background: var(--anno-active);
  transform: scale(1.08);
  box-shadow: 0 0 12px var(--accent-glow);
}

.anno-btn[aria-expanded="true"] {
  background: var(--anno-active);
  box-shadow: 0 0 14px var(--accent-glow);
}

.anno-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.line-content {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.tok-key {
  color: var(--code-key);
}

.tok-str {
  color: var(--code-string);
}

.tok-punct {
  color: var(--code-punct);
}

.tok-num {
  color: var(--code-number);
}

.tok-dim {
  color: #5a6a5e;
}

/* Explanation panel */
.explain-panel {
  position: relative;
  min-height: 280px;
}

@media (min-width: 960px) {
  .explain-panel {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
  }

  .explain-body {
    overflow: auto;
    flex: 1;
  }
}

.explain-body {
  padding: 1.25rem 1.35rem 1.5rem;
}

.explain-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 220px;
  text-align: center;
  color: var(--text-muted);
}

.explain-placeholder .plus-demo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: #0e1210;
  background: var(--accent);
  animation: pulse-soft 2.4s ease-in-out infinite;
}

@keyframes pulse-soft {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(61, 184, 90, 0.35);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(61, 184, 90, 0);
    transform: scale(1.04);
  }
}

.explain-placeholder p {
  margin: 0;
  max-width: 16rem;
  font-size: 1rem;
}

.explain-card {
  display: none;
  animation: fade-in 0.28s ease;
}

.explain-card.is-visible {
  display: block;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.explain-card .tag {
  display: inline-block;
  margin: 0 0 0.65rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(61, 184, 90, 0.12);
  border: 1px solid rgba(61, 184, 90, 0.28);
}

.explain-card h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.explain-card p {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-size: 1.02rem;
}

.explain-card p:last-child {
  margin-bottom: 0;
}

.explain-card .why {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
}

.explain-card .why strong {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.explain-card .why p {
  margin: 0;
  font-size: 0.98rem;
}

.explain-card ul {
  margin: 0.5rem 0 0.85rem;
  padding: 0 0 0 1.15rem;
  color: var(--text-muted);
}

.explain-card li {
  margin-bottom: 0.35rem;
}

.explain-card li:last-child {
  margin-bottom: 0;
}

.close-explain {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
}

.close-explain:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.explain-panel.has-selection .close-explain {
  display: inline-flex;
}

.tip-bar {
  margin: 1.5rem 0 0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
}

.tip-bar a {
  font-weight: 600;
}

@media (max-width: 959px) {
  .explain-panel.is-open {
    outline: 1px solid rgba(61, 184, 90, 0.35);
  }

  .explain-panel.is-open .explain-body {
    scroll-margin-top: 1rem;
  }
}
