@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;600&family=Newsreader:wght@600&display=swap');

:root {
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-mono: monospace;
  --color-bg: #faf4e5;
  --color-text: #1f1b14;
  --color-muted: #5e5647;
  --color-link: #0057ff;
  --max-width: 34rem;
  --spacing: 1.5rem;
}

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

html {
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #1a1712;
    --color-text: #ede5d3;
    --color-muted: #a39a87;
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #1a1712;
  --color-text: #ede5d3;
  --color-muted: #a39a87;
}

html[data-theme="light"] {
  color-scheme: light;
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing);
}

/* --- Header --- */

header {
  padding: 5.5rem 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

@media (max-width: 640px) {
  header {
    padding: 3.5rem 0 0;
  }
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .avatar {
    width: 68px;
    height: 68px;
  }
}

header h1 {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 1.75rem;
}

header h1 a {
  color: var(--color-text);
  text-decoration: none;
}

header h1 a:hover {
  color: var(--color-muted);
}

nav {
  margin: 0 0 2.25rem;
}

nav ul {
  display: flex;
  justify-content: flex-start;
  gap: 1.25rem;
  list-style: none;
}

nav a,
nav [aria-current="page"] {
  font-size: 0.875rem;
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

nav [aria-current="page"] {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  cursor: default;
}

/* --- Main --- */

main {
  padding: 0 0 4rem;
}

/* --- Sections --- */

.section-label {
  font-size: 0.8125rem;
  color: var(--color-muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.02em;
}

main p {
  margin-bottom: 1rem;
  line-height: 1.7;
}

main section {
  margin-bottom: 2.5rem;
}

main section:last-child {
  margin-bottom: 0;
}

/* --- Links in body --- */

main a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

main a:hover {
  color: var(--color-muted);
}

/* --- Projects (Portfolio) --- */

.projects {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.projects li {
  line-height: 1.6;
}

.projects .title {
  font-weight: 600;
}

.projects .desc {
  color: var(--color-muted);
}

.projects a {
  font-size: 0.875rem;
}

.projects a.title {
  font-size: inherit;
  text-decoration: none;
}

.projects a.title:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* --- Game page --- */

/* Player breaks out of the text column; the Unity build is a fixed 960x642 page, scaled down to fit. */
.player {
  --player-scale: 1;
  --player-w: 960;
  --player-h: 644;
  width: min(calc(var(--player-w) * 1px), 100vw - 2 * var(--spacing));
  aspect-ratio: var(--player-w) / var(--player-h);
  margin-left: 50%;
  translate: -50% 0;
  overflow: hidden;
  background: #000;
}

.player iframe {
  display: block;
  width: calc(var(--player-w) * 1px);
  height: calc(var(--player-h) * 1px);
  border: 0;
  transform: scale(var(--player-scale));
  transform-origin: 0 0;
}

/* Project pages: a breadcrumb as wide as the game frame, lined up with its left edge. */
.crumbs {
  width: min(960px, 100vw - 2 * var(--spacing));
  margin: 5.5rem 0 1rem 50%;
  translate: -50% 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.875rem;
  color: var(--color-muted);
}

.crumbs a {
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.crumbs [aria-current="page"] {
  color: var(--color-text);
}

.crumbs-sep {
  opacity: 0.5;
}

@media (max-width: 640px) {
  .crumbs {
    margin-top: 3.5rem;
  }
}

.page-game .crumbs {
  width: min(1440px, 100vw - 2 * var(--spacing));
  margin-top: 1.25rem;
}

/* Type Master is responsive: no scaling, the frame fills the screen below a compact nav. */
.player--type-master {
  width: min(1440px, 100vw - 2 * var(--spacing));
  height: clamp(28rem, 100svh - 5rem, 56rem);
  aspect-ratio: auto;
  background: var(--color-bg);
}

.player--type-master iframe {
  width: 100%;
  height: 100%;
  transform: none;
}

/* Phones: the frame runs edge to edge, so the game gets the full screen width. */
@media (max-width: 600px) {
  .player--type-master {
    width: 100vw;
  }
}

.player-meta {
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.note {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.controls {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.controls th {
  text-align: left;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--color-muted);
  padding: 0 0.75rem 0.5rem 0;
}

.controls td {
  padding: 0.375rem 0.75rem 0.375rem 0;
  vertical-align: top;
}

.controls tbody tr + tr td {
  border-top: 1px solid color-mix(in srgb, var(--color-muted) 25%, transparent);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 0.05rem 0.35rem;
  border: 1px solid color-mix(in srgb, var(--color-muted) 50%, transparent);
  border-radius: 3px;
  white-space: nowrap;
}

/* --- Footer --- */

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3.5rem 0 3rem;
}

footer ul {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

footer a {
  display: inline-flex;
  align-items: center;
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

footer svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* --- Theme toggle --- */

#theme-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  margin-left: auto;
  color: var(--color-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s ease;
}

#theme-toggle:hover {
  color: var(--color-text);
}

#theme-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}

#theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) #theme-toggle .icon-sun {
    display: none;
  }
  html:not([data-theme="light"]) #theme-toggle .icon-moon {
    display: block;
  }
}

html[data-theme="dark"] #theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] #theme-toggle .icon-moon {
  display: block;
}

html[data-theme="light"] #theme-toggle .icon-sun {
  display: block;
}

html[data-theme="light"] #theme-toggle .icon-moon {
  display: none;
}

/* --- Focus styles --- */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
  border-radius: 2px;
}
