/* ============================================================
   daniele-michelin.com — "node status: ONLINE"
   dark ops-dashboard meets editorial. amber signal, mint OK.
   ============================================================ */

:root {
  --bg:      #0a0c10;
  --bg-2:    #0d1015;
  --panel:   #12161d;
  --panel-2: #161b24;
  --line:    #232a36;
  --line-2:  #2e3746;
  --text:    #eae6de;
  --muted:   #a3abb8;
  --dim:     #7a8394;
  --accent:  #ffb454;
  --accent-soft: rgba(255, 180, 84, .12);
  --ok:      #5ce8c8;
  --ok-soft: rgba(92, 232, 200, .12);
  --ink:     #171006;
  --radius:  16px;
  --radius-s: 10px;
  --wrap:    1120px;
  --font-d:  "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-b:  "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --font-m:  "IBM Plex Mono", "SF Mono", Menlo, monospace;
  --ease:    cubic-bezier(.22, 1, .36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--ink); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

/* ---------- atmosphere ---------- */

.bg {
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(255, 180, 84, .07), transparent 60%),
    radial-gradient(1000px 700px at -10% 30%, rgba(92, 232, 200, .05), transparent 55%),
    var(--bg);
}

.bg::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .028) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 55% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 55% at 50% 0%, #000 30%, transparent 75%);
}

.blob {
  position: fixed; z-index: -1; border-radius: 50%;
  filter: blur(90px); opacity: .45; pointer-events: none;
}
.blob-1 {
  width: 44vw; height: 44vw; max-width: 640px; max-height: 640px;
  top: -12%; right: -8%;
  background: radial-gradient(circle, rgba(255, 180, 84, .30), transparent 65%);
  animation: drift-1 26s var(--ease) infinite alternate;
}
.blob-2 {
  width: 38vw; height: 38vw; max-width: 560px; max-height: 560px;
  bottom: -14%; left: -10%;
  background: radial-gradient(circle, rgba(92, 232, 200, .22), transparent 65%);
  animation: drift-2 32s var(--ease) infinite alternate;
}
@keyframes drift-1 { to { transform: translate3d(-6vw, 9vh, 0) scale(1.12); } }
@keyframes drift-2 { to { transform: translate3d(7vw, -8vh, 0) scale(1.08); } }

/* ---------- layout ---------- */

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 28px; }

main { position: relative; }

section { padding: clamp(56px, 9vw, 104px) 0; scroll-margin-top: 84px; }

.k {
  font-family: var(--font-m);
  font-size: 12.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
}
.k::before { content: "// "; color: var(--dim); }

h2.h2 {
  font-family: var(--font-d);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.12;
  letter-spacing: -.01em;
  margin: 14px 0 18px;
  text-wrap: balance;
}

.lead { color: var(--muted); font-size: clamp(16.5px, 1.9vw, 19px); max-width: 62ch; }

/* ---------- header ---------- */

header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: rgba(10, 12, 16, .55);
  border-bottom: 1px solid transparent;
  transition: background .35s, border-color .35s, box-shadow .35s;
}
header.scrolled {
  background: rgba(10, 12, 16, .82);
  border-color: var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.hrow {
  display: flex; align-items: center; gap: 22px;
  height: 66px;
}
.logo {
  font-family: var(--font-m); font-size: 14.5px; font-weight: 500;
  color: var(--text); letter-spacing: .02em; white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo b { color: var(--accent); font-weight: 500; }
.logo .cursor { animation: blink 1.1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

nav.menu { display: flex; gap: 20px; margin-left: auto; }
nav.menu a {
  color: var(--muted); font-size: 14px; letter-spacing: .01em;
}
nav.menu a:hover { color: var(--text); text-decoration: none; }

/* hamburger (mobile) */
.nav-toggle {
  display: none;
  width: 44px; height: 44px; flex: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 5px;
  background: transparent; border: 1px solid var(--line-2); border-radius: 999px;
  cursor: pointer; margin-left: auto;
  transition: border-color .25s;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle:hover { border-color: var(--accent); }
.nav-toggle span {
  display: block; width: 18px; height: 2px; border-radius: 2px;
  background: var(--text);
  transition: transform .35s var(--ease), opacity .2s;
}
header.menu-open .nav-toggle { border-color: var(--accent); }
header.menu-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
header.menu-open .nav-toggle span:nth-child(2) { opacity: 0; }
header.menu-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.langs { display: flex; gap: 6px; margin-left: 6px; }
.lang {
  font-family: var(--font-m); font-size: 12px; letter-spacing: .06em;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted);
  transition: all .25s;
}
.lang:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.lang.active { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 500; }

/* ---------- hero ---------- */

.hero { padding-top: clamp(48px, 7vw, 88px); }
.hgrid {
  display: grid; grid-template-columns: 1.25fr .9fr;
  gap: clamp(36px, 5vw, 72px); align-items: center;
}

.hero h1 {
  font-family: var(--font-d);
  font-weight: 600;
  font-size: clamp(44px, 7.2vw, 84px);
  line-height: 1.02;
  letter-spacing: -.02em;
  margin: 16px 0 10px;
}
.hero h1 .shimmer {
  background: linear-gradient(100deg, var(--text) 20%, var(--accent) 42%, #ffd9a0 50%, var(--accent) 58%, var(--text) 80%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 7s linear infinite;
}
@keyframes shimmer { to { background-position: -220% 0; } }

.role {
  font-family: var(--font-m); font-size: clamp(14px, 1.8vw, 17px);
  color: var(--ok); min-height: 1.7em;
}
.role .cursor { display: inline-block; width: .6em; background: var(--ok); animation: blink 1s steps(1) infinite; }
.role .prefix { color: var(--dim); }

.hero .lead { margin-top: 16px; }

.cta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 30px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 47px; padding: 0 22px;
  border-radius: 999px; font-size: 15px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s, background .25s, border-color .25s, color .25s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary { background: var(--accent); color: var(--ink); }
.btn-primary:hover { box-shadow: 0 12px 30px rgba(255, 180, 84, .28); }

.btn-ghost { border-color: var(--line-2); color: var(--text); background: transparent; font-family: inherit; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.link-more {
  font-family: var(--font-m); font-size: 13.5px; color: var(--dim);
}
.link-more:hover { color: var(--accent); text-decoration: none; }

/* photo card */

.portrait { position: relative; justify-self: center; width: min(340px, 78vw); }
.portrait .frame {
  position: relative; border-radius: 22px; overflow: hidden;
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .5), 0 0 0 6px rgba(255, 180, 84, .06);
  transition: transform .5s var(--ease), box-shadow .5s;
  animation: float 7s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-9px); } }
.portrait:hover .frame { transform: rotate(-1.4deg) scale(1.02); box-shadow: 0 34px 80px rgba(0, 0, 0, .55), 0 0 0 7px rgba(255, 180, 84, .14); }
.portrait img { display: block; width: 100%; height: auto; filter: saturate(.92) contrast(1.02); }

.badge-status {
  position: absolute; left: 14px; bottom: 14px; z-index: 2;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-m); font-size: 12.5px; letter-spacing: .04em;
  background: rgba(10, 12, 16, .78); backdrop-filter: blur(6px);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 13px;
  color: var(--text);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); position: relative; flex: none; }
.dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 1.5px solid var(--ok); animation: ping 2.2s var(--ease) infinite;
}
@keyframes ping { 0% { transform: scale(.6); opacity: .9; } 80%, 100% { transform: scale(1.7); opacity: 0; } }

/* terminal */

.term {
  margin-top: clamp(38px, 5vw, 56px);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  overflow: hidden;
}
.term-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .015);
}
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: var(--line-2); }
.term-bar i:nth-child(1) { background: #ff6159; }
.term-bar i:nth-child(2) { background: #ffbd2e; }
.term-bar i:nth-child(3) { background: #28c840; }
.term-bar span {
  font-family: var(--font-m); font-size: 12.5px; color: var(--dim);
  margin-left: 8px; letter-spacing: .03em;
}
.term-body { padding: 22px 22px 26px; font-family: var(--font-m); font-size: clamp(12.5px, 1.6vw, 14px); line-height: 1.85; overflow-x: auto; }
.term-body .cmd { color: var(--accent); }
.term-body .dim { color: var(--dim); }
.term-body .ok { color: var(--ok); }
.term-body .warn { color: var(--text); }
.term-line { white-space: nowrap; }

/* ---------- stats ---------- */

.stats {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.stat { background: var(--bg-2); padding: 26px 20px 24px; }
.stat .num {
  font-family: var(--font-m); font-weight: 500;
  font-size: clamp(26px, 3.4vw, 40px); color: var(--accent);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.stat .lbl { font-size: 13.5px; color: var(--muted); margin-top: 11px; line-height: 1.45; }

/* ---------- about ---------- */

.about-grid { display: grid; grid-template-columns: 1.35fr .95fr; gap: clamp(32px, 5vw, 64px); align-items: start; }
.about-grid p + p { margin-top: 1.05em; }
.about-grid p { color: var(--muted); }
.about-grid p strong { color: var(--text); font-weight: 500; }

.facts {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 22px;
}
.facts dl { display: grid; }
.facts .row { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.facts .row:last-child { border-bottom: 0; }
.facts dt { font-family: var(--font-m); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); padding-top: 4px; }
.facts dd { font-size: 14.5px; color: var(--text); }

/* ---------- services (skills) ---------- */

.svc { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-2); }
.svc-row {
  display: grid; grid-template-columns: minmax(190px, 300px) auto 1fr; gap: 20px;
  align-items: center; padding: 19px 24px;
  border-bottom: 1px solid var(--line);
  transition: background .3s;
}
.svc-row:last-child { border-bottom: 0; }
.svc-row:hover { background: var(--panel); }
.svc-name { font-family: var(--font-m); font-size: 14.5px; color: var(--text); white-space: nowrap; }
.svc-name .p { color: var(--dim); }
.svc-state { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-m); font-size: 12.5px; letter-spacing: .08em; color: var(--ok); text-transform: uppercase; }
.svc-desc { color: var(--muted); font-size: 14.5px; }
.svc-desc b { color: var(--text); font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.chip {
  font-family: var(--font-m); font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 13px;
  transition: all .25s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ---------- projects ---------- */

.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.pcard {
  display: flex; flex-direction: column; min-height: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 24px 20px;
  transition: transform .4s var(--ease), border-color .35s, box-shadow .4s, background .35s;
}
.pcard:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 180, 84, .5);
  box-shadow: 0 22px 44px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 180, 84, .18);
  background: var(--panel-2);
}
.phead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.pname { font-family: var(--font-m); font-size: 15px; font-weight: 500; color: var(--text); }
.plang {
  font-family: var(--font-m); font-size: 11px; letter-spacing: .06em;
  color: var(--ok); background: var(--ok-soft);
  border-radius: 999px; padding: 3.5px 10px; white-space: nowrap;
}
.pcard p { color: var(--muted); font-size: 14.5px; flex: 1; }
.plink {
  margin-top: 18px; font-family: var(--font-m); font-size: 13px;
  color: var(--accent); display: inline-flex; align-items: center; gap: 7px;
}
.plink svg { width: 14px; height: 14px; transition: transform .3s var(--ease); }
.plink:hover { text-decoration: none; }
.pcard:hover .plink svg { transform: translate(3px, -3px); }

/* ---------- lab ---------- */

.labgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.lcard {
  position: relative;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 26px 24px;
  transition: transform .4s var(--ease), border-color .35s;
}
.lcard:hover { transform: translateY(-4px); border-color: rgba(92, 232, 200, .45); }
.lcard::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px 180px at 85% -20%, rgba(92, 232, 200, .08), transparent 70%);
}
.lhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lname { font-family: var(--font-d); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.lock {
  font-family: var(--font-m); font-size: 10.5px; letter-spacing: .12em;
  color: var(--dim); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 4px 10px; text-transform: uppercase; white-space: nowrap;
}
.lcard p { color: var(--muted); font-size: 14.5px; margin-top: 12px; }
.ltag { font-family: var(--font-m); font-size: 12px; color: var(--ok); margin-bottom: 8px; display: block; }
.labnote {
  margin-top: 24px; font-family: var(--font-m); font-size: 13.5px; color: var(--dim);
}
.labnote b { color: var(--accent); font-weight: 500; }

/* ---------- timeline ---------- */

.tl { position: relative; padding-left: 34px; }
.tl::before {
  content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(180deg, var(--accent), rgba(92, 232, 200, .6), transparent);
  transform: scaleY(0); transform-origin: top;
  transition: transform 1.4s var(--ease);
}
.tl.in::before { transform: scaleY(1); }
.tli { position: relative; padding: 0 0 38px 0; }
.tli:last-child { padding-bottom: 0; }
.tli::before {
  content: ""; position: absolute; left: -34px; top: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
  transition: box-shadow .5s;
}
.tli.now::before { border-color: var(--ok); box-shadow: 0 0 0 5px var(--ok-soft); }
.tli .yr { font-family: var(--font-m); font-size: 13px; color: var(--accent); letter-spacing: .05em; }
.tli.now .yr { color: var(--ok); }
.tli h3 { font-family: var(--font-b); font-weight: 600; font-size: 18.5px; margin: 5px 0 7px; }
.tli p { color: var(--muted); font-size: 15px; max-width: 68ch; }

/* ---------- contact ---------- */

.contact {
  background:
    radial-gradient(700px 320px at 15% -30%, rgba(255, 180, 84, .10), transparent 65%),
    linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-2); border-radius: 22px;
  padding: clamp(36px, 5.5vw, 64px);
  text-align: center;
}
.contact h2.h2 { margin-inline: auto; }
.contact .lead { margin: 0 auto; }
.contact .cta { justify-content: center; }
.avail {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 30px; font-family: var(--font-m); font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 9px 18px;
}

/* ---------- footer ---------- */

footer { border-top: 1px solid var(--line); padding: 34px 0 44px; margin-top: 40px; }
.frow { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; justify-content: space-between; }
footer p { font-family: var(--font-m); font-size: 12.5px; color: var(--dim); line-height: 1.9; }
footer .langs { margin-left: 0; }

/* ---------- reveal animations ---------- */

.reveal { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }

.load-in { opacity: 0; transform: translateY(22px); animation: load-in .9s var(--ease) forwards; animation-delay: var(--d, 0s); }
@keyframes load-in { to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .hgrid { grid-template-columns: 1fr; }
  .portrait { order: -1; width: min(300px, 72vw); }
  .about-grid { grid-template-columns: 1fr; }
  .pgrid { grid-template-columns: repeat(2, 1fr); }
  .svc-row { grid-template-columns: 1fr; gap: 8px; }
  .svc-row .svc-state { justify-self: start; }
  .nav-toggle { display: inline-flex; }
  nav.menu {
    display: none; flex-direction: column; gap: 0;
    position: absolute; left: 0; right: 0; top: 100%;
    background: rgba(10, 12, 16, .97);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line-2);
    box-shadow: 0 24px 40px rgba(0, 0, 0, .45);
    padding: 8px 20px 14px;
  }
  header.menu-open nav.menu { display: flex; }
  nav.menu a { padding: 13px 4px; font-size: 16px; border-bottom: 1px solid var(--line); }
  nav.menu a:last-child { border-bottom: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:last-child { grid-column: span 2; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
  .pgrid, .labgrid { grid-template-columns: 1fr; }
  .hero h1 { font-size: clamp(38px, 12vw, 56px); }
  .term-line { white-space: normal; }
  .facts .row { grid-template-columns: 1fr; gap: 4px; }
  .avail { flex-wrap: wrap; justify-content: center; text-align: center; border-radius: 16px; font-size: 12.5px; padding: 9px 14px; }
}

@media (max-width: 520px) {
  .logo-rest { display: none; }
  .hrow { gap: 10px; }
  .logo { font-size: 13px; }
  .langs { gap: 4px; margin-left: 0; }
  .lang { padding: 4px 7px; font-size: 11px; }
  .cta .btn, .cta .link-more { width: 100%; justify-content: center; text-align: center; }
  .stats { grid-template-columns: 1fr; }
  .stat:last-child { grid-column: auto; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
  .reveal, .load-in { opacity: 1; transform: none; }
  .tl::before { transform: scaleY(1); }
  .blob { animation: none; }
}

@media print {
  .bg, .blob, header, .cta, .term { display: none; }
  body { background: #fff; color: #111; }
  .cm { display: none !important; }
}

/* ---------- contact modal ---------- */

.cm {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
}
.cm[hidden] { display: none; }
.cm-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 6, 9, .74);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .35s var(--ease);
}
.cm-panel {
  position: relative; width: min(560px, 100%);
  max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #13181f, #0d1116);
  border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, .55);
  overflow: hidden; outline: none;
  opacity: 0; transform: translateY(18px) scale(.97);
  transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.cm.open .cm-backdrop { opacity: 1; }
.cm.open .cm-panel { opacity: 1; transform: none; }

.cm-bar {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 16, .6);
}
.cm-bar i {
  width: 11px; height: 11px; border-radius: 50%;
  background: #ff6159;
}
.cm-bar i:nth-child(2) { background: #ffbd2e; }
.cm-bar i:nth-child(3) { background: #28c840; }
.cm-bar span {
  margin-left: 6px;
  font-family: var(--font-m); font-size: 12px; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cm-x {
  margin-left: auto; flex: none;
  width: 30px; height: 30px; border-radius: 8px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font-size: 20px; line-height: 1;
  transition: color .2s, background .2s;
}
.cm-x:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

.cm-form { padding: 22px 24px 24px; overflow-y: auto; }
.cm-k { margin: 0 0 6px; }
.cm-h {
  font-family: var(--font-d); font-size: clamp(21px, 4vw, 25px); font-weight: 600;
  color: var(--text); margin: 0 0 18px;
}
.cm-field { margin-bottom: 14px; }
.cm-field label {
  display: block; margin-bottom: 6px;
  font-family: var(--font-m); font-size: 11.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--dim);
}
.cm-field input, .cm-field textarea {
  width: 100%; box-sizing: border-box;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line-2); border-radius: 10px;
  color: var(--text); font-family: var(--font-m); font-size: 14px;
  padding: 11px 13px; outline: none; resize: vertical;
  transition: border-color .25s, background .25s;
}
.cm-field input:focus, .cm-field textarea:focus {
  border-color: var(--accent); background: rgba(255, 255, 255, .05);
}
.cm-field input::placeholder, .cm-field textarea::placeholder { color: var(--dim); opacity: .7; }
.cm-field input.cm-bad, .cm-field textarea.cm-bad { border-color: #ff6159; }
.cm-hp {
  position: absolute !important; left: -9999px !important;
  width: 1px !important; height: 1px !important; opacity: 0 !important;
}
.cm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 18px; }
.cm-direct {
  font-family: var(--font-m); font-size: 12.5px; color: var(--dim);
  text-decoration: none;
  transition: color .2s;
}
.cm-direct:hover { color: var(--accent); }
.cm-status {
  min-height: 20px; margin: 12px 0 0;
  font-family: var(--font-m); font-size: 13px; color: var(--dim);
}
.cm-status.ok { color: #28c840; }
.cm-status.err { color: #ff6159; }
.cm-status .mcursor { color: var(--accent); animation: blink 1s steps(1) infinite; }

.cm-done { padding: 34px 24px 30px; text-align: center; }
.cm-check {
  width: 58px; height: 58px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid #28c840; color: #28c840;
  animation: cm-pop .5s var(--ease);
}
.cm-check svg { width: 28px; height: 28px; stroke: currentColor; }
@keyframes cm-pop {
  0% { transform: scale(.6); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
.cm-done .cm-h { margin-bottom: 8px; }
.cm-done p {
  margin: 0 0 20px;
  font-size: 14.5px; color: var(--muted); line-height: 1.65;
}
.cm-done .cm-h { margin-top: 0; }

body.cm-lock { overflow: hidden; }

@media (max-width: 640px) {
  .cm { padding: 12px; }
  .cm-form { padding: 18px 16px 20px; }
  .cm-actions { gap: 10px; }
  .cm-actions .btn { width: 100%; justify-content: center; }
  .cm-direct { width: 100%; text-align: center; }
}

/* ---------- interactive terminal ---------- */

[data-term] .term-body { max-height: min(70vh, 640px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
[data-term] .term-line.warn { color: #ff9b8f; }
.term-input { display: flex; align-items: center; gap: .6ch; white-space: normal; }
.term-input label { cursor: text; }
.term-cmd {
  flex: 1; min-width: 0; padding: 0; margin: 0; border: 0; outline: 0;
  background: transparent; color: var(--accent); caret-color: var(--accent);
  font: inherit; line-height: inherit;
}
.term-cmd::placeholder { color: var(--dim); opacity: .55; }
[data-term]:focus-within { border-color: rgba(255, 180, 84, .35); box-shadow: 0 24px 60px rgba(0, 0, 0, .45), 0 0 0 3px rgba(255, 180, 84, .08); }
.term-hint {
  margin: 0; padding: 10px 22px; border-top: 1px solid var(--line);
  font-family: var(--font-m); font-size: 12px; color: var(--dim); background: rgba(255, 255, 255, .012);
}
kbd {
  display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; font-family: var(--font-m); font-size: .92em; color: var(--text); background: var(--panel);
}
footer p a { color: var(--muted); border-bottom: 1px dotted var(--line); }
footer p a:hover { color: var(--accent); }

/* ---------- legal pages ---------- */

.legal-sec { padding-top: clamp(110px, 14vw, 150px); }
.legal-sec h1.h2 { margin-bottom: 0; }
.legal-term { margin-top: 28px; }
.legal-body { font-family: var(--font-b); font-size: 15.5px; line-height: 1.75; color: var(--muted); max-width: 78ch; }
.legal-body h2 { font-family: var(--font-m); font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--accent); margin: 26px 0 8px; }
.legal-body h2::before { content: "## "; color: var(--dim); }
.legal-body h2:first-child { margin-top: 0; }
.legal-body p, .legal-body ul { margin: 0 0 12px; }
.legal-body ul { padding-left: 1.2em; }
.legal-body li { margin-bottom: 4px; }
.legal-body a { border-bottom: 1px dotted rgba(255, 180, 84, .4); }
.legal-body .dim { font-family: var(--font-m); font-size: 12.5px; margin-top: 20px; }
.legal-back { margin-top: 26px; font-family: var(--font-m); font-size: 13px; }
.legal .langs { margin-left: auto; }
.legal-lead { font-family: var(--font-m); font-size: 12px; color: var(--dim); margin: -4px 0 12px !important; }
.legal-kv {
  display: grid; grid-template-columns: minmax(90px, 130px) 1fr; gap: 0; margin: 0 0 14px;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(255, 255, 255, .012);
}
.legal-kv dt, .legal-kv dd { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.legal-kv dt { font-family: var(--font-m); font-size: 12px; letter-spacing: .04em; color: var(--dim); text-transform: lowercase; }
.legal-kv dt::after { content: ":"; }
.legal-kv dd { color: var(--text); }
.legal-kv dt:nth-last-of-type(1), .legal-kv dd:last-of-type { border-bottom: 0; }
@media (max-width: 520px) {
  .legal-kv { grid-template-columns: 1fr; }
  .legal-kv dt { border-bottom: 0; padding-bottom: 0; }
}

/* ---------- headings in cards ---------- */
h3.pname, h3.lname { margin: 0; line-height: inherit; }

/* ---------- FAQ (man page) ---------- */
.faq { margin-top: 30px; }
.faq-body { padding: 8px 0 10px; line-height: 1.6; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item:last-child { border-bottom: 0; }
.faq-item summary {
  list-style: none; cursor: pointer; padding: 14px 22px; display: flex; gap: .6ch; align-items: baseline;
  white-space: normal; transition: background .2s var(--ease);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; margin-left: auto; color: var(--dim); transition: transform .25s var(--ease); }
.faq-item[open] summary::after { content: "−"; color: var(--accent); }
.faq-item summary:hover { background: rgba(255, 255, 255, .02); }
.faq-item summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.faq-item p {
  margin: 0; padding: 0 22px 16px calc(22px + 2ch);
  font-family: var(--font-b); font-size: 15px; line-height: 1.7; color: var(--muted); max-width: 80ch;
}
.faq-item p a { border-bottom: 1px dotted rgba(255, 180, 84, .4); }

/* ---------- legal pages v2 ---------- */
.legal-meta { font-family: var(--font-m); font-size: 12.5px; color: var(--dim); margin: 14px 0 0; }
.legal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.legal-actions .btn { font-size: 13px; padding: 9px 16px; cursor: pointer; }
.legal-toc { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 6px; margin: 0 0 26px; background: rgba(255, 255, 255, .012); }
.legal-toc .dim { margin: 0 0 6px !important; font-size: 12px; }
.legal-toc ol { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 28px; font-family: var(--font-m); font-size: 13px; }
.legal-toc li { margin: 0 0 6px; break-inside: avoid; counter-increment: toc; }
.legal-toc li::before { content: counter(toc, decimal-leading-zero) "  "; color: var(--dim); white-space: pre; }
.legal-toc a { color: var(--muted); border-bottom: 0 !important; }
.legal-toc a:hover { color: var(--accent); }
.legal-body h2 { scroll-margin-top: 96px; }
.legal-body h2::before { content: none; }
.legal-n { color: var(--dim); font-weight: 400; margin-right: 6px; }
.legal-n::before { content: "## "; }
@media (max-width: 620px) { .legal-toc ol { columns: 1; } }
@media print {
  body.legal { background: #fff; color: #111; }
  body.legal .term { display: block; box-shadow: none; border: 0; background: none; }
  body.legal .term-bar, body.legal .legal-actions, body.legal .legal-back, body.legal footer, body.legal .bg, body.legal header { display: none; }
  body.legal .legal-body, body.legal .legal-kv dd { color: #111; }
  body.legal .legal-body h2 { color: #000; }
  body.legal .legal-kv { border-color: #ccc; }
  body.legal .legal-kv dt, body.legal .legal-kv dd { border-color: #ddd; }
  body.legal a { color: #111; }
}

/* ---------- blog ---------- */
.blog-nav { display: flex; gap: 18px; margin-left: auto; font-size: 14px; }
.blog-nav a { color: var(--muted); }
.blog-nav a:hover { color: var(--accent); }
.post .k a { color: inherit; }
.post-lead { margin-top: 18px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.post-tag { font-family: var(--font-m); font-size: 12px; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.post-body { max-width: 76ch; }
.post-body p, .post-body li { color: var(--muted); }
.post-body b { color: var(--text); font-weight: 600; }
.post-body code { font-family: var(--font-m); font-size: .88em; color: var(--accent); background: rgba(255, 180, 84, .07); border: 1px solid rgba(255, 180, 84, .14); border-radius: 6px; padding: 1px 6px; word-break: break-word; }
.post-body h2 { font-size: 14px; }
.post-body h2::before { content: "## "; color: var(--dim); }
.post-body ul { list-style: none; padding-left: 0; }
.post-body ul li::before { content: "[ ] "; font-family: var(--font-m); color: var(--ok); }
.post-author { display: flex; gap: 16px; align-items: center; margin-top: 28px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.post-author img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.post-author p { margin: 0; font-size: 14.5px; color: var(--muted); line-height: 1.6; }
.post-author b { color: var(--text); }
.post-list { padding: 6px 0; }
.post-row { display: grid; grid-template-columns: 110px 1fr; gap: 4px 18px; padding: 18px 22px; border-bottom: 1px solid var(--line); color: var(--text); transition: background .2s var(--ease); }
.post-row:last-child { border-bottom: 0; }
.post-row:hover { background: rgba(255, 255, 255, .02); }
.post-date { grid-row: span 3; font-family: var(--font-m); font-size: 12.5px; color: var(--dim); padding-top: 3px; }
.post-title { font-family: var(--font-d); font-size: 21px; line-height: 1.3; color: var(--text); }
.post-row:hover .post-title { color: var(--accent); }
.post-desc { font-size: 14.5px; color: var(--muted); line-height: 1.6; }
.post-meta { font-family: var(--font-m); font-size: 12px; color: var(--dim); }
@media (max-width: 620px) {
  .post-row { grid-template-columns: 1fr; }
  .post-date { grid-row: auto; }
  .blog-nav { gap: 12px; font-size: 13px; }
}
.portrait picture { display: block; }
.post-author a, .legal-body a, .faq-item p a, footer p a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; border-bottom: 0 !important; }
.legal-toc a { text-decoration: none; }
.cm-privacy { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--dim); }
.cm-privacy a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

/* ============================================================
   optional light theme — dark stays the default and the site
   does NOT follow the OS setting; only an explicit click on the
   toggle sets html[data-theme="light"]. Terminal windows stay dark.
   ============================================================ */

html[data-theme="light"] {
  --bg:      #f6f4ef;
  --bg-2:    #efece5;
  --panel:   #ffffff;
  --panel-2: #f3f1ec;
  --line:    #e2ddd3;
  --line-2:  #d3ccbf;
  --text:    #1b1d22;
  --muted:   #4a5260;
  --dim:     #5f6776;
  --accent:  #9a4a0a;
  --accent-soft: rgba(154, 74, 10, .10);
  --ok:      #0f766e;
  --ok-soft: rgba(15, 118, 110, .10);
  --ink:     #ffffff;
  color-scheme: light;
}
/* keep the "Mac terminal" windows dark inside the light page */
html[data-theme="light"] .term,
html[data-theme="light"] .cm-panel,
html[data-theme="light"] .badge-status {
  --bg:      #0a0c10;
  --bg-2:    #0d1015;
  --panel:   #12161d;
  --panel-2: #161b24;
  --line:    #232a36;
  --line-2:  #2e3746;
  --text:    #eae6de;
  --muted:   #a3abb8;
  --dim:     #7a8394;
  --accent:  #ffb454;
  --accent-soft: rgba(255, 180, 84, .12);
  --ok:      #5ce8c8;
  --ok-soft: rgba(92, 232, 200, .12);
  --ink:     #171006;
  color: var(--text);
}
html[data-theme="light"] .bg {
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(154, 74, 10, .07), transparent 60%),
    radial-gradient(1000px 700px at -10% 30%, rgba(15, 118, 110, .05), transparent 55%),
    var(--bg);
}
html[data-theme="light"] .bg::before {
  background-image:
    linear-gradient(rgba(0, 0, 0, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, .035) 1px, transparent 1px);
}
html[data-theme="light"] .blob { opacity: .45; }
html[data-theme="light"] header { background: rgba(246, 244, 239, .72); }
html[data-theme="light"] header.scrolled { background: rgba(246, 244, 239, .92); box-shadow: 0 10px 30px rgba(0, 0, 0, .08); }
html[data-theme="light"] .pcard, html[data-theme="light"] .lcard, html[data-theme="light"] .stat,
html[data-theme="light"] .post-author { box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
html[data-theme="light"] .pcard:hover { box-shadow: 0 18px 36px rgba(0, 0, 0, .10), 0 0 0 1px rgba(154, 74, 10, .18); border-color: rgba(154, 74, 10, .45); }
html[data-theme="light"] .lcard:hover { border-color: rgba(15, 118, 110, .45); }
html[data-theme="light"] .portrait .frame { box-shadow: 0 24px 50px rgba(0, 0, 0, .16), 0 0 0 6px rgba(154, 74, 10, .08); }
html[data-theme="light"] .term { box-shadow: 0 24px 50px rgba(0, 0, 0, .18); }
html[data-theme="light"] .btn-primary:hover { box-shadow: 0 12px 30px rgba(154, 74, 10, .25); }
@media (max-width: 980px) {
  html[data-theme="light"] nav.menu { background: rgba(246, 244, 239, .98); box-shadow: 0 24px 40px rgba(0, 0, 0, .12); }
}

/* theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: 10px; flex: none;
  border: 1px solid var(--line-2); border-radius: 999px; background: transparent;
  color: var(--muted); cursor: pointer; transition: color .2s, border-color .2s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .i-moon { display: none; }
html[data-theme="light"] .theme-toggle .i-sun { display: none; }
html[data-theme="light"] .theme-toggle .i-moon { display: block; }
