/* Repository — plancia dev.cgctrl.app. Palette e card riprese da REPO // GRID (Admin).
   Solo risorse locali: la CSP della pagina ammette stili e font soltanto da 'self'. */
:root {
  color-scheme: dark;
  --bg: #09090b;
  --bg2: #0d0d10;
  --card: #18181b;
  --line: #34343b;
  --line-soft: #52525b59;
  --txt: #fafafa;
  --dim: #b4b4bf;
  --faint: #8e8e99;
  --purple: #a855f7;
  --purple2: #d0a0ff;
  --green: #34d399;
  --red: #fb8585;
  --amber: #fbbf24;
  --sk1: #1f1f24;
  --sk2: #2c2c33;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse 90% 420px at 50% 0, #a855f71a, transparent 70%) no-repeat, var(--bg);
  color: var(--txt);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--purple2); }
button, input { font: inherit; color: inherit; }
button, a, input, summary { touch-action: manipulation; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}
.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;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- navigazione e intestazione ---------- */
.topnav { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; margin-bottom: 10px; }
.navlink {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  color: var(--dim); font-size: 14px; text-decoration: none; border-radius: 6px;
}
.navlink:hover { color: var(--purple2); }

.head { margin: 4px 0 18px; }
.kicker { margin: 0 0 4px; font: 700 11px/1.4 var(--mono); letter-spacing: .22em; color: var(--purple); }
h1 { margin: 0; font-weight: 900; font-size: clamp(26px, 6vw, 34px); line-height: 1.15; letter-spacing: .02em; color: var(--purple2); }
.sub { margin: 6px 0 0; font-size: 12px; letter-spacing: .08em; color: var(--dim); }

/* ---------- barra ---------- */
.toolbar { display: flex; gap: 10px; align-items: stretch; margin-bottom: 10px; }
.search {
  flex: 1 1 auto; min-width: 0; min-height: 46px; padding: 10px 14px;
  background: var(--card); color: var(--txt); border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; /* niente zoom automatico di iOS sul campo */
  -webkit-appearance: none; appearance: none;
}
.search::placeholder { color: var(--faint); opacity: 1; }
.search:hover { border-color: #a855f78c; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  background: var(--card); color: var(--txt); border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: border-color .15s, color .15s, background-color .15s;
}
.btn:hover { border-color: var(--purple); color: var(--purple2); }
.btn-primary { background: var(--purple2); color: #0b0b0d; border-color: var(--purple2); }
.btn-primary:hover { background: #e2c4ff; border-color: #e2c4ff; color: #0b0b0d; }
.btn-ghost { background: transparent; color: var(--dim); }
.btn.is-busy::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--purple2);
  animation: spin .8s linear infinite;
}

/* ---------- stato e avvisi ---------- */
.status { display: flex; align-items: center; gap: 8px; min-height: 24px; margin: 0 0 14px; font-size: 13px; color: var(--dim); }
.status::before { content: ""; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status[data-tone="ok"]::before { background: var(--green); }
.status[data-tone="busy"]::before { background: var(--purple2); animation: pulse 1.2s ease-in-out infinite; }
.status[data-tone="warn"]::before { background: var(--amber); }
.status[data-tone="error"]::before { background: var(--red); }

.notice {
  margin: 0 0 16px; padding: 16px;
  border: 1px solid #fbbf2466; border-radius: 12px; background: #fbbf240d;
}
.notice-title { margin: 0 0 6px; font-size: 16px; line-height: 1.4; color: var(--amber); }
.notice-text { margin: 0; font-size: 14px; line-height: 1.6; color: var(--txt); }
.notice-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- griglia ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.repo {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 14px 14px 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
@media (hover: hover) { .repo:not(.skeleton):hover { border-color: #a855f78c; } }
.repo.is-new { animation: card-in .28s ease-out both; }

.repo-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.repo-name { flex: 1 1 12em; min-width: 0; margin: 0; font: 700 15px/1.45 var(--mono); overflow-wrap: anywhere; }
.repo-link { color: var(--txt); text-decoration: none; }
a.repo-link:hover { color: var(--purple2); text-decoration: underline; text-underline-offset: 3px; }
.owner { color: var(--dim); font-weight: 500; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { padding: 2px 7px; border: 1px solid; border-radius: 6px; font-size: 11px; line-height: 1.5; letter-spacing: .03em; }
.b-priv { color: var(--amber); border-color: #f59e0b66; background: #f59e0b14; }
.b-pub { color: var(--green); border-color: #10b98166; background: #10b98114; }
.b-arch { color: var(--red); border-color: #ef444466; background: #ef444414; }

.facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; line-height: 1.6; color: var(--dim); }
.fact { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.fact .k { color: var(--faint); }
.fact.fresh time { color: var(--green); }
.fact.dormant time { color: var(--red); }
.dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--purple2); }
.dot.lang-amber { background: var(--amber); }
.dot.lang-green { background: var(--green); }
.dot.lang-red { background: var(--red); }

.commits { margin: 0; padding: 0; list-style: none; }
.commit {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; row-gap: 1px;
  padding: 8px 0; border-top: 1px dashed var(--line-soft);
}
.sha { grid-row: 1 / span 2; font: 12px/1.65 var(--mono); color: var(--purple2); text-decoration: none; }
a.sha:hover { text-decoration: underline; text-underline-offset: 3px; }
.cmsg {
  font-size: 13px; line-height: 1.5; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.cmeta { font-size: 11.5px; line-height: 1.6; color: var(--dim); overflow-wrap: anywhere; }
.author { color: var(--amber); font-weight: 600; }
.no-commits { margin: 0; padding: 8px 0 6px; border-top: 1px dashed var(--line-soft); font-size: 12px; color: var(--faint); }

.more { border-top: 1px dashed var(--line-soft); }
.more > summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
  font-size: 12.5px; color: var(--purple2); cursor: pointer; list-style: none;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "▸"; font-size: 11px; transition: transform .15s; }
.more[open] > summary::before { transform: rotate(90deg); }
.more .commit:first-child { border-top: 1px dashed var(--line-soft); }

.empty { margin: 8px 0 0; padding: 28px 16px; text-align: center; font-size: 14px; line-height: 1.7; color: var(--dim); }
.foot { margin-top: 28px; text-align: center; font-size: 11px; line-height: 1.8; color: var(--faint); }

/* ---------- scheletro ---------- */
.skeleton { gap: 12px; padding-bottom: 16px; }
.bar {
  height: 11px; width: 88%; border-radius: 6px;
  background: linear-gradient(90deg, var(--sk1) 0%, var(--sk2) 45%, var(--sk1) 90%);
  background-size: 250% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.bar-title { height: 16px; width: 58%; }
.bar-meta { width: 42%; }
.bar-short { width: 64%; }

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 300px) {
  .toolbar { flex-wrap: wrap; }
  .toolbar .btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
