/* A.GIUGLIETTI · Malavisione
   Minimal industrial, after Teenage Engineering: light grey ground, hairline
   rules, small uppercase labels, flat modules, one orange used sparingly
   (indicators, frames, wires, the active state). No shadows, no fades.
   Structure from the work: the blob-tracking floor of Gesture 2.0 and the
   TouchDesigner network (operators, parameter panels, table DATs).

   Roles (same names in every palette, chosen in content.js):
   --paper ground   --panel module surface   --panel-2 module header
   --ink text       --muted secondary text   --rule hairlines
   --blue the one accent. Small text is never orange. */
:root {
  /* palette "coolgray1": Pantone Cool Gray 1 U (approx.) */
  --paper: #e2e2df;
  --panel: #ebebe8;
  --panel-2: #d8d8d5;
  --ink: #111111;
  --muted: #5c5c59;
  --rule: rgba(0, 0, 0, 0.14);
  --blue: #e04600;
  --blue-rgb: 224, 70, 0;

  --mono: "Azeret Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --s-xs: 10.5px;
  --s-sm: 12px;
  --s-base: 14px;
  --s-md: 15px;
  --s-lg: clamp(22px, 2.4vw, 30px);
  --s-xl: clamp(40px, 7vw, 104px);
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
:root[data-palette="orange"] { --paper: #d5d6d2; --panel: #dfe0dc; --panel-2: #cacbc7; }
:root[data-palette="paper"] { --paper: #fefdf4; --panel: #f7f6ec; --panel-2: #ecebe0; --blue: #3126fe; --blue-rgb: 49, 38, 254; }
:root[data-palette="blue"] {
  --paper: #3126fe; --panel: #3a30ff; --panel-2: #2a1fe8; --ink: #fefdf4; --muted: rgba(254, 253, 244, 0.72);
  --rule: rgba(254, 253, 244, 0.26); --blue: #fefdf4; --blue-rgb: 254, 253, 244; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--s-base)/1.6 var(--mono);
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
::selection { background: var(--blue); color: var(--ink); }
a { color: inherit; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 600; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
img, video { max-width: 100%; display: block; }
.label { font-size: var(--s-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* the orange indicator square, used for "active" and "live" */
.dot::before, .op-bar .live::before, .bar-nav a[aria-current="page"]::before, #hudCount::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  background: var(--blue);
  vertical-align: 1px;
}

/* module header: small uppercase label on a slightly darker strip */
.op-bar, .params-head, .dat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: var(--s-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.op-bar b, .params-head b, .dat-head b { font-weight: 600; }
.op-bar span, .params-head span:last-child, .dat-head span:last-child { color: var(--muted); }

/* ================= ENTRY: TRACKER ================= */
.tracker {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--paper);
  overflow: hidden;
  touch-action: none;
}
.tracker[hidden] { display: none; }
.tracker canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
html.own-cursor, html.own-cursor * { cursor: none !important; }

.t-id {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: var(--gutter-l);
  z-index: 2;
  pointer-events: none;
  display: grid;
  gap: 6px;
  justify-items: start;
}
.t-name { font-size: clamp(22px, 2.4vw, 30px); font-weight: 600; line-height: 1; letter-spacing: -0.01em; color: var(--blue); }
.t-role { font-size: var(--s-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.t-role b { color: var(--blue); font-weight: 600; }
.t-meta {
  position: absolute;
  top: calc(24px + env(safe-area-inset-top, 0px));
  right: var(--gutter-r);
  z-index: 2;
  margin: 0;
  pointer-events: none;
  font-size: var(--s-xs);
  letter-spacing: 0.06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) { .t-meta { display: none; } }

.t-nav { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.t-nav a {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  font-size: clamp(40px, 6.5vw, 100px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--blue);
  padding: 0.1em 0.16em 0.06em;
  white-space: nowrap;
  will-change: transform;
}
.t-nav a.near, .t-nav a:hover, .t-nav a:focus-visible { color: var(--ink); background: var(--blue); outline: none; }

/* crosshair cursor with x / y */
.t-cursor { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 100; pointer-events: none; display: none; }
.t-cursor.on { display: block; }
/* cursor: orange cross with orange centre, like the favicon */
.t-cursor::before { content: ""; position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23e04600'%3E%3Crect x='11' y='1' width='2' height='7'/%3E%3Crect x='11' y='16' width='2' height='7'/%3E%3Crect x='1' y='11' width='7' height='2'/%3E%3Crect x='16' y='11' width='7' height='2'/%3E%3C/g%3E%3Crect x='9.5' y='9.5' width='5' height='5' fill='%23e04600'/%3E%3C/svg%3E") no-repeat center / 24px 24px; }
.t-cursor span {
  position: absolute;
  left: 16px;
  top: 12px;
  font-size: 10px;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.t-hud {
  position: absolute;
  left: var(--gutter-l);
  right: var(--gutter-r);
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  font-size: var(--s-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.t-hud > * { background: var(--paper); }
#hudCount { color: var(--ink); }
.t-hud .skip { margin-left: auto; color: var(--ink); text-decoration: none; padding: 5px 10px; border: 1px solid var(--rule); background: var(--panel); }
.t-hud .skip:hover { background: var(--blue); border-color: var(--blue); }
.hint-touch { display: none; }
@media (hover: none) { .hint-desk { display: none; } .hint-touch { display: inline; } }

/* ================= SITE ================= */
.site[hidden] { display: none; }
.bar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px var(--gutter-r) 12px var(--gutter-l);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 11;
  background: var(--paper);
}
.bar-name { justify-self: start; font-weight: 600; text-decoration: none; }
.bar-name:hover { color: var(--blue); }
.bar-nav { display: flex; gap: 22px; }
.bar-nav a {
  text-decoration: none;
  font-size: var(--s-xs);
  letter-spacing: 0.12em;
  color: var(--muted);
}
.bar-nav a:hover { color: var(--ink); }
.bar-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.bar-meta { justify-self: end; font-size: var(--s-xs); letter-spacing: 0.06em; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

#view { outline: none; padding: 0 var(--gutter-r) 96px var(--gutter-l); max-width: 1680px; margin: 0 auto; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 32px; padding: 40px 0 24px; }
.view-title { font-size: var(--s-xl); line-height: 0.88; letter-spacing: -0.04em; color: var(--blue); }
.view-title small { font-size: var(--s-xs); letter-spacing: 0.1em; color: var(--muted); font-weight: 400; vertical-align: top; margin-left: 10px; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  font: inherit;
  font-size: var(--s-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 6px 10px;
  cursor: pointer;
}
.filters button:hover { border-color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); }
.filters .n { margin-left: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.filters button[aria-pressed="true"] .n { color: var(--ink); }

/* ---------- works: operators ---------- */
.ops {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 36px 20px;
}
.op { min-width: 0; text-decoration: none; display: grid; position: relative; background: var(--panel); border: 1px solid var(--rule); }
.op[hidden] { display: none; }
.op-bar b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-bar .live { color: var(--ink); }
.op-view {
  position: relative;
  aspect-ratio: 4 / 5;
  max-width: 100%;
  overflow: hidden;
  background: var(--panel-2);
}
.op-view img, .op-view video, .op-view canvas.ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.op:hover .op-view img, .op:hover .op-view video,
.op:focus-visible .op-view img, .op:focus-visible .op-view video { filter: grayscale(1) contrast(1.1); }
.op-view canvas.hud { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.op-cap { padding: 12px 10px 14px; display: grid; gap: 3px; }
.op-cap h3 { font-size: var(--s-md); line-height: 1.3; color: var(--blue); text-wrap: balance; text-transform: uppercase; }
.op-cap p { font-size: var(--s-sm); }
.op-cap p + p { color: var(--muted); }

/* ---------- project: viewer + parameters ---------- */
.project { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; padding-top: 28px; align-items: start; }
.p-media { display: grid; gap: 16px; min-width: 0; }
.p-frame { position: relative; background: var(--panel-2); overflow: hidden; }
.p-frame img, .p-frame video { width: 100%; height: auto; display: block; position: static; }
.p-frame canvas.ph { width: 100%; aspect-ratio: 4 / 5; max-height: 80vh; object-fit: contain; display: block; background: var(--panel); }
.p-frame canvas.hud { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.params { position: sticky; top: 72px; border: 1px solid var(--rule); background: var(--panel); min-width: 0; }
.params h1 { font-size: var(--s-lg); line-height: 1.1; padding: 18px 12px 16px; color: var(--blue); letter-spacing: -0.01em; text-wrap: balance; }
.params dl { margin: 0; }
.prow { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 8px 12px; border-top: 1px solid var(--rule); font-size: var(--s-sm); }
.prow dt { text-transform: uppercase; font-size: var(--s-xs); letter-spacing: 0.1em; color: var(--muted); padding-top: 1px; }
.prow dd { margin: 0; min-width: 0; }
.p-text { padding: 16px 12px; border-top: 1px solid var(--rule); line-height: 1.7; }
.p-text a, .about-text a, .about-lead a, .kv .prow a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.p-text a:hover, .about-text a:hover, .kv .prow a:hover { background: var(--blue); text-decoration: none; }
.kv .prow a { color: var(--blue); text-decoration: none; }
.kv .prow a:hover { background: none; text-decoration: underline; text-decoration-color: var(--blue); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.p-links { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-top: 1px solid var(--rule); }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: var(--s-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; border-color: var(--rule); }
.btn.ghost:hover { background: transparent; border-color: var(--ink); color: var(--ink); }
.p-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-top: 1px solid var(--rule); }
.p-nav .btn { min-width: 0; overflow: hidden; text-transform: none; letter-spacing: 0; font-size: var(--s-sm); }
.p-nav .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-nav .btn:last-child { justify-content: flex-end; }

/* ---------- about ---------- */
.about { display: grid; gap: 28px; }
.about-lead { font-size: var(--s-lg); font-weight: 600; line-height: 1.3; max-width: 48ch; text-wrap: pretty; }
.about-lead em { font-style: normal; color: var(--blue); }
.about-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.about-text { display: grid; gap: 1.1em; line-height: 1.75; max-width: 66ch; }
.kv { border: 1px solid var(--rule); background: var(--panel); min-width: 0; }
.copy { font: inherit; font-size: var(--s-xs); letter-spacing: 0.08em; text-transform: uppercase; background: transparent; border: 1px solid var(--rule); color: var(--muted); padding: 1px 6px; margin-left: 8px; cursor: pointer; }
.copy:hover { color: var(--ink); border-color: var(--ink); }

/* ---------- cv: table DATs ---------- */
.cv { display: grid; gap: 32px; }
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.dat { border: 1px solid var(--rule); background: var(--panel); min-width: 0; }
.dat-row {
  display: grid;
  grid-template-columns: 34px 120px minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 16px;
  padding: 9px 12px;
  border-top: 1px solid var(--rule);
  font-size: var(--s-sm);
  align-items: baseline;
}
.dat-head + .dat-row { border-top: 0; }
.dat-row:hover { background: var(--blue); }
.dat-row:hover, .dat-row:hover .i, .dat-row:hover .pl, .dat-row:hover .no { color: var(--ink); }
.dat-row .i { color: var(--muted); font-variant-numeric: tabular-nums; }
.dat-row .w { font-variant-numeric: tabular-nums; }
.dat-row .t { font-weight: 600; }
.dat-row .pl, .dat-row .no { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; }
.chips span { background: var(--blue); color: var(--ink); padding: 4px 8px; font-size: var(--s-sm); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .project { grid-template-columns: minmax(0, 1fr); }
  .params { position: static; }
  .dat-row { grid-template-columns: 110px minmax(0, 1fr); gap: 2px 14px; }
  .dat-row .i { display: none; }
  .dat-row .pl, .dat-row .no { grid-column: 2; }
}
@media (max-width: 640px) {
  .t-nav a { font-size: clamp(38px, 12vw, 60px); }
  .bar { grid-template-columns: 1fr auto; }
  .bar-meta { display: none; }
  .bar-nav { gap: 14px; }
  .view-head { padding-top: 28px; }
  .dat-row { grid-template-columns: minmax(0, 1fr); }
  .dat-row .pl, .dat-row .no { grid-column: 1; }
}

/* ---------- footer ---------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 24px;
  padding: 16px var(--gutter-r) calc(16px + env(safe-area-inset-bottom, 0px)) var(--gutter-l);
  border-top: 1px solid var(--rule);
  font-size: var(--s-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.foot-links a { color: var(--blue); font-weight: 600; text-decoration: none; text-transform: none; letter-spacing: 0.02em; }
.foot-links a:hover, .foot .top:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.foot .top { color: var(--ink); text-decoration: none; }

/* sound toggle on project videos */
.p-frame { position: relative; }
.p-frame .snd { position: absolute; right: 8px; bottom: 8px; font: inherit; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; background: var(--paper); color: var(--ink); border: 0; padding: 4px 8px; cursor: pointer; }
.p-frame .snd.on { background: var(--blue); color: #ffffff; }

/* gallery rows: files listed together in content.js sit side by side */
.p-row { display: flex; gap: 16px; align-items: flex-start; }
.p-row > .p-frame { flex: 1 1 0; min-width: 0; }
.p-row[style*="--n: 5"], .p-row[style*="--n:5"] { gap: 8px; }
.p-row .p-frame .snd { font-size: 9px; padding: 3px 6px; right: 6px; bottom: 6px; }
/* back to WORKS, top left above the media */
.p-back-wrap { padding: 0 12px 12px; }
.p-back { display: flex; width: 100%; justify-content: center; background: var(--ink); border-color: var(--ink); color: #ffffff; font-size: var(--s-sm); letter-spacing: 0; text-transform: uppercase; }
.p-back-wrap .p-back:hover, .p-back-wrap .p-back:active, .p-back-wrap .p-back:focus-visible { background: var(--blue) !important; border-color: var(--blue) !important; color: var(--ink) !important; }
.params h1, .p-nav .btn span { text-transform: uppercase; }
.p-nav .btn.ghost:hover { background: var(--ink); border-color: var(--ink); color: #ffffff; }
/* collaborator tags in project texts: orange, no underline */
.p-text a { color: var(--blue); text-decoration: none; }
.p-text a:hover { background: var(--blue); color: var(--ink); text-decoration: none; }

/* about / cv: links orange without underline; on hover orange background with black text */
.about-text a, .about-lead a, .kv .prow a { color: var(--blue); text-decoration: none; }
.about-text a:hover, .about-lead a:hover, .kv .prow a:hover { background: var(--blue); color: var(--ink); text-decoration: none; }

/* censorship bars (romanzo rosa) */
.censor { position: absolute; background: #000000; pointer-events: none; will-change: transform; }

/* floating top button */
.to-top { position: fixed; right: calc(32px + env(safe-area-inset-right, 0px)); bottom: calc(32px + env(safe-area-inset-bottom, 0px)); z-index: 50; display: none; align-items: center; justify-content: center; gap: 10px; min-width: 56px; height: 52px; padding: 0 20px; font: inherit; font-size: var(--s-sm); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--blue); background: var(--blue); color: var(--ink); cursor: pointer; }
.to-top.on { display: inline-flex; }
.to-top:hover, .to-top:focus-visible { background: var(--ink); border-color: var(--ink); color: #ffffff; }
