/* ============================================================
   KRIKSPORTFOLIO — v11.0 · "LINEN & OBSIDIAN"
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;600;700&family=Geist:wght@300;400;500&family=Geist+Mono:wght@400&display=swap');

/* 1. TOKEN • LIGHT (Linen & Terracotta) */
:root {
  color-scheme: light;
  --surface: #FAF9F6; --surface-2: #F3F1EC; --surface-3: #EAE7DF; --surface-4: #DCD8CC;
  --ink: #1A1A1A; --ink-2: #3D3D3D; --ink-3: #6B6B6B; --ink-4: #9E9E9E;
  --line: #E0DDD5; --line-2: #CFCBC0;
  --accent: #D2503A; --accent-2: #B8432F; --accent-ink: #FFFFFF;
  --accent-soft: rgba(210, 80, 58, 0.08); --accent-line: rgba(210, 80, 58, 0.3);
  --bg-overlay: rgba(26, 26, 26, 0.55); --bg-blur: 4px; --gif-size: 420px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-full: 999px;
  --font-display: 'Instrument Sans', system-ui, sans-serif;
  --font-sans: 'Geist', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.32, 0.72, 0, 1); --dur: 220ms;
  --icon-filter: none;
  --shadow-sm: 0 2px 4px rgba(26,26,26,0.04);
  --shadow-md: 0 8px 24px rgba(26,26,26,0.08);
  --shadow-lg: 0 24px 48px -12px rgba(26,26,26,0.15);
}

/* 2. TOKEN • NIGHT (Obsidian & Electric Violet) */
[data-theme="night"] {
  color-scheme: dark;
  --surface: #0D0D11; --surface-2: #15151B; --surface-3: #1E1E26; --surface-4: #282832;
  --ink: #F4F4F5; --ink-2: #C4C4C8; --ink-3: #8E8E93; --ink-4: #5A5A60;
  --line: #232329; --line-2: #303038;
  --accent: #A78BFA; --accent-2: #8B5CF6; --accent-ink: #0D0D11;
  --accent-soft: rgba(167, 139, 250, 0.1); --accent-line: rgba(167, 139, 250, 0.4);
  --bg-overlay: rgba(0, 0, 0, 0.75);
  --icon-filter: invert(1) brightness(1.2);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 24px 48px -12px rgba(0,0,0,0.6);
}

/* 3. RESET & GLOBAL */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; min-height: 100%; }
body {
  background: #08080A url('./media/sfondo.gif') repeat top left / var(--gif-size) auto fixed;
  min-height: 100vh; position: relative;
  font-family: var(--font-sans); font-size: 15px; line-height: 1.65; color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: var(--bg-overlay); backdrop-filter: blur(var(--bg-blur)); -webkit-backdrop-filter: blur(var(--bg-blur));
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* Transizione universale tema */
html.theme-transition .container, html.theme-transition .container *, 
html.theme-transition .container *::before, html.theme-transition .container *::after {
  transition: background-color 320ms var(--ease), border-color 320ms var(--ease), color 320ms var(--ease), box-shadow 320ms var(--ease) !important;
}

/* 4. LAYOUT (Grid Container) */
.container {
  position: relative; z-index: 1;
  display: grid;
  grid-template-areas: "header header" "menu content" "footer footer";
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 48px); max-width: 1200px; margin: 24px auto;
  background-color: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-lg);
}

/* 5. HEADER & FOOTER */
.header, footer {
  display: flex; align-items: center; padding: 18px 28px;
  background-color: var(--surface-2); border-color: var(--line);
}
.header { grid-area: header; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
footer { grid-area: footer; justify-content: center; border-top: 1px solid var(--line); }

.header-brand { display: flex; align-items: center; gap: 16px; }
#blog-title h2 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
footer p { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }

/* 6. THEME TOGGLE */
.theme-toggle {
  display: inline-flex; justify-content: center; align-items: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: var(--r-full); cursor: pointer;
  background: var(--surface-3); border: 1px solid var(--line);
  transition: all var(--dur) var(--ease);
}
.theme-toggle:hover { background-color: var(--surface-4); border-color: var(--line-2); transform: scale(1.05); }
.theme-toggle__icon { width: 16px; height: 16px; display: block; filter: var(--icon-filter); }
.theme-toggle__icon--moon { display: none; }
[data-theme="night"] .theme-toggle__icon--sun { display: none; }
[data-theme="night"] .theme-toggle__icon--moon { display: block; }

/* 7. MENU */
.menu { grid-area: menu; display: flex; flex-direction: column; padding: 28px 16px; background-color: var(--surface-2); border-right: 1px solid var(--line); }
.menu ul { list-style: none; display: flex; flex-direction: column; gap: 4px; counter-reset: menu; }
.menu li { counter-increment: menu; }
.menu a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm);
  text-decoration: none; color: var(--ink-3); font-weight: 500; font-size: 0.9rem;
  border: 1px solid transparent;
  transition: all var(--dur) var(--ease);
}
.menu a::before { content: counter(menu, decimal-leading-zero); font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-4); }
.menu a:hover { color: var(--ink); background-color: var(--surface); border-color: var(--line); }
.menu a:hover::before { color: var(--accent); }
.menu a.active { color: var(--accent); background-color: var(--accent-soft); border-color: var(--accent-line); font-weight: 600; }
.menu a.active::before { color: var(--accent); }

/* 8. PROFILO */
.profile-link { display: block; border-radius: 50%; }
.profile-link::before { display: none; } 
.profile-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); background: var(--surface-3); transition: all var(--dur) var(--ease); box-shadow: var(--shadow-sm); }
.profile-link:hover .profile-img { border-color: var(--accent); transform: scale(1.05); }

/* 9. CONTENT (Tipografia per AJAX) */
.content {
  grid-area: content; display: flex; flex-direction: column; gap: 18px;
  padding: clamp(36px, 4.5vw, 60px) clamp(30px, 5vw, 64px);
  font-size: 0.98rem; line-height: 1.75; color: var(--ink-2); min-width: 0;
}

/* Titoli */
.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
  font-family: var(--font-display); font-weight: 700; color: var(--ink);
  line-height: 1.2; letter-spacing: -0.025em; text-wrap: balance; margin-top: 1.5em;
}
.content h1:first-child, .content h2:first-child, .content h3:first-child { margin-top: 0; }
.content h1 { font-size: clamp(2rem, 1.4rem + 1.8vw, 2.75rem); letter-spacing: -0.03em; padding-bottom: 22px; border-bottom: 2px solid var(--line); }
.content h2 { font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.1rem); }
.content h3 { font-size: clamp(1.4rem, 1.15rem + 0.8vw, 1.7rem); padding-bottom: 16px; }
.content h3::after { content: ""; display: block; width: 40px; height: 3px; background: var(--accent); margin-top: 16px; border-radius: var(--r-full); }
.content h4 { font-size: 1.2rem; }
.content h5 { font-size: 1.05rem; }
.content h6 { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; color: var(--ink-3); letter-spacing: 0.1em; }

/* Testo & Link */
.content p { max-width: 68ch; text-wrap: pretty; }
.content p:first-of-type { font-size: 1.08rem; color: var(--ink); line-height: 1.7; }
.content a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-line); padding-bottom: 1px; transition: all var(--dur) var(--ease); }
.content a:hover { color: var(--accent-2); border-bottom-color: var(--accent-2); }
.content strong { color: var(--ink); font-weight: 600; }
.content em { font-style: normal; color: var(--ink); background: var(--accent-soft); padding: 0 6px; border-radius: 4px; }

/* Liste */
.content ul, .content ol { padding-left: 1.5em; display: flex; flex-direction: column; gap: 8px; }
.content ul { list-style: none; }
.content ul li { position: relative; padding-left: 1.2em; }
.content ul li::before { content: ""; position: absolute; left: 0; top: 0.7em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.content ol { list-style: decimal-leading-zero; }
.content ol li::marker { font-family: var(--font-mono); color: var(--accent); font-size: 0.8em; }

/* Code & Pre */
.content code, .content kbd, .content samp {
  font-family: var(--font-mono); font-size: 0.85em; color: var(--accent);
  background: var(--accent-soft); padding: 0.15em 0.4em; border-radius: 4px; border: 1px solid var(--line);
}
.content pre {
  font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.6; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px 20px; overflow-x: auto; box-shadow: var(--shadow-sm);
}
.content pre code { background: none; border: none; padding: 0; color: var(--ink-2); font-size: inherit; }

/* Blockquote, HR, Immagini, Figure */
.content blockquote {
  padding: 1rem 1.5rem; margin: 1.5rem 0; border-left: 4px solid var(--accent);
  background: var(--surface-2); border-radius: 0 var(--r-md) var(--r-md) 0; color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.content blockquote p { color: var(--ink); }
.content hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }
.content img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.content figure { margin: 1.5em 0; }
.content figcaption { font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-3); text-transform: uppercase; margin-top: 8px; text-align: center; }

/* Tabelle */
.content table { width: 100%; border-collapse: collapse; font-size: 0.92rem; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.content th, .content td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.content th { background: var(--surface-2); font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.content tr:last-child td { border-bottom: none; }

/* Bottoni */
.content button, .content .btn {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-sans); font-size: 0.85rem; font-weight: 600;
  color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--r-sm);
  padding: 10px 18px; cursor: pointer; text-decoration: none; box-shadow: var(--shadow-sm);
  transition: all var(--dur) var(--ease);
}
.content button:hover, .content .btn:hover { background: var(--accent-2); border-color: var(--accent-2); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* 10. RESPONSIVE */
@media (max-width: 900px) { .container { grid-template-columns: 220px 1fr; } }
@media (max-width: 768px) {
  body { --gif-size: 260px; }
  .container { display: flex; flex-direction: column; min-height: 100vh; margin: 0; border-radius: 0; border: none; box-shadow: none; }
  .header { flex-wrap: wrap; gap: 12px; padding: 14px 18px; }
  .menu { border-right: none; border-bottom: 1px solid var(--line); padding: 0; }
  .menu ul { flex-direction: row; overflow-x: auto; scrollbar-width: none; padding: 10px 12px; }
  .menu ul::-webkit-scrollbar { display: none; }
  .menu li { flex-shrink: 0; }
  .menu a { padding: 8px 14px; white-space: nowrap; }
  .content { flex-grow: 1; padding: 32px 22px 44px; }
  footer { padding: 16px; text-align: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }