/* ---------------------------------------------------------------
   Mattia (Metiu) — personal site
   One column, one typeface, no ornament.
   --------------------------------------------------------------- */

:root {
  --bg:      #ffffff;
  --bg-soft: #f6f6f7;
  --text:    #111214;
  --text-2:  #5b5f66;
  --text-3:  #8b9098;
  --rule:    #e6e7e9;
  --accent:  #1b4dd8;
  --bg-light: #ffffff;
  --bg-dark:  #101113;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #101113;
    --bg-soft: #17181b;
    --text:    #f2f3f5;
    --text-2:  #a2a7af;
    --text-3:  #71767e;
    --rule:    #25272b;
    --accent:  #7fa0ff;
  }
}

:root[data-theme="dark"] {
  --bg:      #101113;
  --bg-soft: #17181b;
  --text:    #f2f3f5;
  --text-2:  #a2a7af;
  --text-3:  #71767e;
  --rule:    #25272b;
  --accent:  #7fa0ff;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

main {
  width: min(100% - 2.5rem, 40rem);
  margin-inline: auto;
  padding: clamp(3rem, 9vw, 5.5rem) 0 4rem;
}

/* ---------- theme toggle ---------- */

.toggle {
  position: fixed; top: 1.25rem; right: 1.25rem; z-index: 10;
  display: grid; place-items: center;
  width: 2rem; height: 2rem; padding: 0;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 6px;
  color: var(--text-2); cursor: pointer;
}
.toggle:hover { color: var(--text); }
.toggle svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

.icon-sun  { display: block; }
.icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun  { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}
:root[data-theme="dark"]  .icon-sun  { display: none; }
:root[data-theme="dark"]  .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun  { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }

/* ---------- intro ---------- */

.intro { margin-bottom: clamp(3rem, 7vw, 4.5rem); }

.intro__top {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* side by side there is no room for the game on a phone: stack them so
   the strip gets the full width */
@media (max-width: 40rem) {
  .intro__top { flex-direction: column; gap: 1.25rem; }
  .game { width: 100%; }
  .toggle { top: .75rem; right: .75rem; }
}

.portrait {
  width: 112px; height: 112px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

/* the pixel runner — no frame, no background of its own */
.game {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: .35rem;
}

.game canvas {
  display: block;
  background: none;
  image-rendering: pixelated;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;   /* no blue flash on tap */
  user-select: none;
  outline-offset: 4px;
}

.game__hint,
.game__score {
  margin: 0;
  font-size: .68rem;
  color: var(--text-3);
  letter-spacing: .01em;
  line-height: 1.35;
}

/* unlocked by reaching 5000 m in the runner */
.reward {
  margin: 2rem 0 0;
  padding: 1.25rem 1.25rem 1.4rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg-soft);
}

.reward h2 {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.01em;
  text-transform: none;
  color: var(--text);
  border: none;
  padding: 0;
  margin-bottom: .6rem;
}

.reward__badge {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--text);
  border-radius: 3px;
  padding: .15rem .4rem;
}

.reward p { margin: 0 0 1rem; color: var(--text-2); font-size: .95rem; text-wrap: pretty; }

.pitch textarea,
.pitch input[type="email"] {
  width: 100%;
  padding: .65rem .75rem;
  font: inherit;
  font-size: .92rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  resize: vertical;
}
.pitch input[type="email"] { margin-top: .5rem; resize: none; }
.pitch textarea::placeholder,
.pitch input[type="email"]::placeholder { color: var(--text-3); }
.pitch textarea:focus-visible,
.pitch input[type="email"]:focus-visible { border-color: var(--accent); outline: none; }
.pitch button[disabled] { opacity: .55; cursor: default; }

.pitch__row { display: flex; align-items: center; gap: .9rem; margin-top: .6rem; flex-wrap: wrap; }

.pitch button {
  font: inherit;
  font-size: .88rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--text);
  border: none;
  border-radius: 6px;
  padding: .5rem 1rem;
  cursor: pointer;
}
.pitch button:hover { background: var(--accent); }

.pitch__note { font-size: .75rem; color: var(--text-3); }

.pitch__done {
  margin: 0;
  padding: .7rem .85rem;
  font-size: .9rem;
  color: var(--text-2);
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.pitch__done:focus-visible { outline: none; border-color: var(--accent); }

/* ---- the door: reads as a link, behaves as a button ---- */
.idea-open {
  font: inherit;
  font-size: .95rem;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.idea-open:hover { text-decoration: underline; text-underline-offset: 2px; }

.reward p.reward__go { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin: 0; }
.reward__note { font-size: .75rem; color: var(--text-3); }
.contact-go { margin: 1rem 0 0; }

/* ---- the card ---- */
.idea {
  width: min(30rem, calc(100vw - 2rem));
  padding: 1.5rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
}
.idea::backdrop { background: rgba(9, 10, 12, .55); }
.idea:not([open]) { display: none; }

.idea h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.015em;
  text-transform: none;
  color: var(--text);
  border: none;
  padding: 0;
  margin: 0 0 .5rem;
}

.idea__badge {
  display: inline-block;
  margin: 0 0 .6rem;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--text);
  border-radius: 3px;
  padding: .15rem .4rem;
}

.idea__hint {
  margin: 0 0 1rem;
  padding: .55rem .7rem;
  font-size: .8rem;
  color: var(--text-3);
  background: var(--bg-soft);
  border-radius: 6px;
}

.idea__lead { margin: 0 0 1rem; font-size: .92rem; color: var(--text-2); text-wrap: pretty; }

.idea__close {
  position: absolute;
  top: .5rem;
  right: .65rem;
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text-3);
  background: none;
  border: none;
  padding: .2rem .35rem;
  cursor: pointer;
}
.idea__close:hover { color: var(--text); }

.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;
}

.intro h1 {
  font-size: clamp(1.75rem, 4.5vw, 2.25rem);
  font-weight: 600;
  margin-bottom: .75rem;
}
.alias {
  font-weight: 400;
  color: var(--text-3);
}

/* the character sits on this dash, so it has to be a real element */
.dash {
  font-weight: 400;
  color: var(--text-3);
  padding-inline: .15em;
}

.intro__line {
  font-size: 1.05rem;
  color: var(--text-2);
  margin: 0 0 1.5rem;
  max-width: 34rem;
  text-wrap: pretty;
}

.intro__links { display: flex; flex-wrap: wrap; gap: 1.25rem; margin: 0; font-size: .9rem; }

/* ---------- sections ---------- */

section { margin-bottom: clamp(3rem, 7vw, 4.5rem); }

h2 {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-bottom: .75rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--rule);
}

/* ---------- background / timeline ---------- */

.path { list-style: none; margin: 0; padding: 0; }

.path li {
  display: grid;
  grid-template-columns: 1fr;
  gap: .35rem;
  padding-bottom: 1.75rem;
}
.path li:last-child { padding-bottom: 0; }

@media (min-width: 34rem) {
  .path li { grid-template-columns: 5.5rem 1fr; gap: 1.75rem; }
}

.path__when {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-3);
  padding-top: .15rem;
  white-space: nowrap;
}

.path__what h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .3rem;
}
.path__what p { margin: 0; color: var(--text-2); font-size: .95rem; text-wrap: pretty; }

/* ---------- what I do ---------- */

.skills { margin: 0; padding: 0; }

.skills > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: .2rem;
  padding-bottom: 1.25rem;
}
.skills > div:last-child { padding-bottom: 0; }

@media (min-width: 34rem) {
  .skills > div { grid-template-columns: 9rem 1fr; gap: 1.75rem; }
}

.skills dt {
  font-size: .95rem;
  font-weight: 600;
}
.skills dd {
  margin: 0;
  color: var(--text-2);
  font-size: .95rem;
  text-wrap: pretty;
}

/* ---------- projects ---------- */

.work { list-style: none; margin: 0; padding: 0; }

.work__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .25rem 1rem;
  padding: .9rem 0;
  border-bottom: 1px solid var(--rule);
  color: inherit;
}
.work li:first-child .work__row { border-top: 1px solid var(--rule); }
.work__row:hover { text-decoration: none; }
.work__row:hover .work__name { color: var(--accent); }

.work__name { font-weight: 600; font-size: .98rem; }

.work__desc {
  grid-column: 1;
  color: var(--text-2);
  font-size: .92rem;
  text-wrap: pretty;
}

.work__tag {
  grid-row: 1;
  grid-column: 2;
  font-size: .78rem;
  color: var(--text-3);
  padding-top: .12rem;
  white-space: nowrap;
}

.all { margin: 1.5rem 0 0; font-size: .9rem; }

/* ---------- the stagehand and the curtain he drags ---------- */

.stage {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  image-rendering: pixelated;
}

.stage-curtain {
  position: fixed;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  will-change: transform;
}

/* he is on phones too, just smaller */

/* ---------- talking to the stagehand ---------- */

.stage-hit {
  position: fixed;
  -webkit-tap-highlight-color: transparent;
  z-index: 31;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.stage-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* an author display rule beats the hidden attribute, so say it again */
.talk[hidden], .talk__bubble[hidden], .stage-hit[hidden] { display: none; }

.talk {
  position: fixed;
  z-index: 32;
  display: flex;
  flex-direction: column;
  min-width: 11rem;
  padding: .3rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 6px 20px -10px rgba(0, 0, 0, .3);
}

.talk button {
  font: inherit;
  font-size: .8rem;
  text-align: left;
  color: var(--text-2);
  background: none;
  border: 0;
  border-radius: 5px;
  padding: .38rem .5rem;
  cursor: pointer;
}
.talk button:hover,
.talk button:focus-visible { color: var(--text); background: var(--bg-soft); outline: none; }

.talk__bubble {
  position: fixed;
  z-index: 32;
  margin: 0;
  max-width: 15rem;
  padding: .4rem .6rem;
  font-size: .76rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, .3);
  text-wrap: pretty;
}

@media (max-width: 40rem) {
  .talk { min-width: 9rem; }
  .talk__bubble { max-width: calc(100vw - 2rem); }
}

/* ---------- contact & footer ---------- */

.contact-line { margin: 0 0 1rem; color: var(--text-2); }

footer {
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
footer p { margin: 0; font-size: .82rem; color: var(--text-3); }
