/* linktome — Giovanni La Cascia
   Stessa identità del sito: di giorno lo Chef (carta, ambra, serif),
   di notte il Dev (scuro, verde, mono). HTML + CSS, zero build step.
*/

:root {
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --radius: 18px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Colori fissi delle due anime, usati in entrambi i temi */
  --amber: #a56b21;
  --green: #34d399;

  /* Giorno · Chef: carta e ambra */
  --bg: #f6efe3;
  --surface: #fbf7f0;
  --surface-hover: #fffdf9;
  --chip: rgba(60, 42, 20, 0.05);
  --border: rgba(60, 42, 20, 0.13);
  --border-strong: rgba(165, 107, 33, 0.5);
  --text: #241c12;
  --muted: #6d5c44;
  --accent: #a56b21;
  --accent-text: #8a5716;
  --on-accent: #fff;
  --tag-chef: #a56b21;
  --tag-dev: #0f7a55;
  --ring: transparent;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 12px 26px -20px rgba(60, 40, 10, 0.5);
  --font-display: var(--font-serif);
}

[data-theme="night"] {
  color-scheme: dark;

  /* Notte · Dev: scuro e verde, come Arborae */
  --bg: #070b0a;
  --surface: #0d1312;
  --surface-hover: #111a18;
  --chip: rgba(255, 255, 255, 0.035);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(52, 211, 153, 0.5);
  --text: #eef4f2;
  --muted: #9db3ad;
  --accent: #34d399;
  --accent-text: #34d399;
  --on-accent: #03140d;
  --tag-chef: #c4903f;
  --tag-dev: #34d399;
  --ring: rgba(255, 255, 255, 0.16);
  --shadow: 0 14px 30px -22px rgba(0, 0, 0, 0.9);
  --font-display: var(--font-mono);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Sfondi dei due temi su due livelli, così il cambio sfuma invece di scattare */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

body::before {
  background:
    radial-gradient(ellipse 90% 55% at 50% -12%, rgba(196, 144, 63, 0.26), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(165, 107, 33, 0.08), transparent 70%);
}

body::after {
  opacity: 0;
  background:
    radial-gradient(ellipse 90% 55% at 50% -12%, rgba(52, 211, 153, 0.14), transparent 70%),
    radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
}

[data-theme="night"] body::before { opacity: 0; }
[data-theme="night"] body::after { opacity: 1; }

/* Durante il cambio tema i colori sfumano (la carta dell'avatar ha la sua transizione) */
.theme-anim *:not(.avatar-flip):not(.face),
.theme-anim body {
  transition: background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease, box-shadow 0.5s ease !important;
}

a { color: inherit; }

img, svg { display: block; }

button { font: inherit; color: inherit; }

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

/* Le icone nascoste dal tema: senza JS vale il tema giorno */
:root:not([data-theme="night"]) .ic-sun,
[data-theme="night"] .ic-moon,
:root:not([data-theme="night"]) .k-night,
[data-theme="night"] .k-day {
  display: none;
}

/* ============ Pagina ============ */
.page {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
  .page { padding-top: 32px; }
}

/* ============ Barra in alto ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}

.icon-btn svg { width: 18px; height: 18px; }

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-btn:active { transform: scale(0.94); }

.lang-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.lang-switch button {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  min-width: 36px;
  padding: 7px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

/* ============ Hero ============ */
.hero {
  text-align: center;
  padding: 10px 0 8px;
}

.avatar {
  position: relative;
  display: block;
  width: 136px;
  height: 136px;
  margin: 0 auto 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  perspective: 900px;
  -webkit-tap-highlight-color: transparent;
}

.avatar-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.9s var(--ease);
}

[data-theme="night"] .avatar-flip { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.face-chef {
  border: 3px solid rgba(165, 107, 33, 0.55);
  box-shadow: 0 18px 40px -14px rgba(60, 40, 10, 0.5);
}

.face-dev {
  transform: rotateY(180deg);
  border: 3px solid rgba(52, 211, 153, 0.5);
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.8), 0 0 70px -14px rgba(0, 181, 133, 0.55);
}

.avatar-badge {
  position: absolute;
  right: 2px;
  bottom: 4px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  transition: transform 0.3s var(--ease);
}

.avatar-badge svg { width: 18px; height: 18px; }

.avatar:hover .avatar-badge { transform: rotate(-18deg) scale(1.08); }

.kicker {
  margin: 0 0 4px;
  font-size: 0.95rem;
  color: var(--accent-text);
}

.k-day {
  font-family: var(--font-serif);
  font-style: italic;
}

.k-night {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 7vw, 2.4rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

[data-theme="night"] .name {
  font-weight: 700;
  letter-spacing: -0.045em;
}

.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.t-chef {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.08em;
  color: var(--tag-chef);
}

.t-dev {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95em;
  color: var(--tag-dev);
}

.tagline .dot { margin: 0 4px; opacity: 0.6; }

/* ============ Gruppi di link ============ */
.group { margin-top: 28px; }

.group-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 4px 10px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.25s var(--ease), border-color 0.2s, background-color 0.2s;
}

.link,
.link-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 10px 14px 10px 10px;
  text-decoration: none;
  color: inherit;
}

a.link:hover,
.has-action:hover,
.gh:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

a.link:hover { transform: translateY(-2px); }

a.link:active { transform: translateY(0) scale(0.99); }

.has-action {
  display: flex;
  align-items: center;
  min-height: 0;
  padding: 0 10px 0 0;
}

.has-action .link-main {
  flex: 1;
  min-width: 0;
  padding-right: 4px;
  border-radius: var(--radius);
}

/* Tasto dentro la card GitHub */
button.link-main {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: none;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 12px;
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--ring);
}

.tile svg { width: 22px; height: 22px; }

.tile-instagram {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
  box-shadow: none;
}

.tile-linkedin { background: #0a66c2; box-shadow: none; }
.tile-x { background: #000; }
.tile-telegram { background: #26a5e4; box-shadow: none; }
.tile-telegram svg { width: 26px; height: 26px; }
.tile-mail { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.tile-github { background: #181717; }
.tile-bmc { background: #ffdd00; color: #000; box-shadow: none; }
.tile-paypal { background: #003087; }
.tile-ha { background: #18bcf2; box-shadow: none; }
.tile-discord { background: #5865f2; box-shadow: none; }
.tile-steam { background: linear-gradient(150deg, #1b2838, #2a475e); }
.tile-epic { background: #313131; }
.tile-img { background: none; box-shadow: none; }
.tile-img img { width: 44px; height: 44px; }
.tile-img img.tile-arborae { width: 50px; height: 50px; max-width: none; }

.link-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.link-title {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
}

.link-sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.link-go {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 0.25s var(--ease), color 0.2s;
}

a.link:hover .link-go {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.link-action {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--chip);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}

.link-action:hover { color: var(--text); border-color: var(--border-strong); }
.link-action:active { transform: scale(0.92); }
.link-action svg { width: 17px; height: 17px; }
.link-action .ic-check { display: none; color: var(--accent); }
.link-action.done .ic-copy { display: none; }
.link-action.done .ic-check { display: block; }

/* ============ GitHub: card che si apre sui repository ============ */
.gh { overflow: hidden; }

.gh .chev { transition: transform 0.4s var(--ease), color 0.2s; }

.gh:hover .chev,
.gh.open .chev { color: var(--accent); }

.gh.open .chev { transform: rotate(180deg); }

.gh-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.45s var(--ease);
}

.gh.open .gh-panel { grid-template-rows: 1fr; }

.gh-inner {
  min-height: 0;
  overflow: hidden;
}

.repos {
  list-style: none;
  margin: 0 10px;
  padding: 10px 0 0;
  border-top: 1px dashed var(--border);
  display: grid;
  gap: 8px;
}

.repo {
  position: relative;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--chip);
  transition: border-color 0.2s, background-color 0.2s;
}

.gh.open .repo {
  animation: rise 0.45s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms + 80ms);
}

.repo:hover,
.repo:focus-within {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.repo-name {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* Tutta la card porta al repository */
.repo-name::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.repo-name:focus-visible { outline: none; }

.repo:has(.repo-name:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[data-theme="night"] .repo-name::before {
  content: './';
  content: './' / '';
  color: var(--muted);
  font-weight: 400;
}

.repo-fork {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 1px 7px 1px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
  vertical-align: 2px;
}

.repo-fork svg { width: 11px; height: 11px; }

.repo-desc {
  margin: 4px 0 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}

.repo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.repo-meta > [hidden] { display: none; }

.repo-lang,
.repo-stars {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.repo-lang i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--ring);
}

.repo-stars { gap: 4px; }
.repo-stars svg { width: 13px; height: 13px; color: #e3b341; }

.repo-extra {
  position: relative;
  z-index: 1;
  margin-left: auto;
  font-weight: 600;
  color: var(--accent-text);
  text-decoration: none;
  text-underline-offset: 3px;
}

.repo-extra::after { content: ' ↗'; }

/* Più link sulla stessa card: restano insieme, a destra */
.repo-links {
  display: inline-flex;
  gap: 12px;
  margin-left: auto;
}

.repo-links .repo-extra { margin-left: 0; }

.repo-extra:hover { text-decoration: underline; }

.gh-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 10px;
  padding: 10px;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-text);
  text-decoration: none;
  transition: background-color 0.2s;
}

.gh-all svg { width: 15px; height: 15px; transition: transform 0.25s var(--ease); }

.gh-all:hover { background: var(--chip); }
.gh-all:hover svg { transform: translate(2px, -2px); }

/* ============ Footer ============ */
.foot {
  margin-top: 40px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.foot p { margin: 0 0 4px; }

.foot a {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

.foot a:hover { color: var(--text); }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.3s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============ Entrata ============ */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.topbar,
.hero,
.group,
.foot {
  animation: rise 0.6s var(--ease) both;
}

.hero { animation-delay: 0.05s; }
.group:nth-of-type(1) { animation-delay: 0.12s; }
.group:nth-of-type(2) { animation-delay: 0.19s; }
.group:nth-of-type(3) { animation-delay: 0.26s; }
.group:nth-of-type(4) { animation-delay: 0.33s; }
.foot { animation-delay: 0.4s; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }

  /* Niente rotazione: le due foto si scambiano e basta */
  .avatar-flip,
  [data-theme="night"] .avatar-flip,
  .face-dev { transform: none; }

  .face-dev,
  [data-theme="night"] .face-chef { opacity: 0; }

  [data-theme="night"] .face-dev { opacity: 1; }
}
