/* ================================================
   KWAKD PORTFOLIO — style.css
   ================================================ */

:root {
  --bg: #f7f7f7;
  --fg: #000000;
  --dim: #666666;
  --border: #dddddd;
  --max: 640px;
  --pad: clamp(1rem, 5vw, 2rem);
}

body.dark {
  --bg: #111111;
  --fg: #cccccc;
  /* #777 was 4.22:1 on #111 -- under AA for the 17 places --dim is used */
  --dim: #8b8b8b;
  --border: #2a2a2a;
}

/* Heading root for pages whose title is not drawn on screen. */
.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;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent; /* removes blue flash on iOS tap */
  -webkit-text-size-adjust: 100%; /* prevents iOS from auto-scaling text */
}

img {
  max-width: 100%;
  display: block;
}
a {
  color: var(--fg);
}
a:hover {
  opacity: 0.6;
}
p {
  margin-bottom: 0.9em;
}
p:last-child {
  margin-bottom: 0;
}
h1,
h2,
h3,
h4 {
  font-weight: 600;
  margin-bottom: 0.4em;
  line-height: 1.3;
}

/* index.html's section headings carry no class and so fell back to UA
   sizes. They were h3/h4; raising them to h2/h3 for a correct outline
   would have resized them, so the old sizes are pinned here. */
.index-section > h2 {
  font-size: 17px;
}
.index-section > h3 {
  font-size: 15px;
}
em {
  font-style: italic;
}
strong {
  font-weight: 700;
}
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

/* ---------- CENTERED COLUMN — shared by nav + page ---------- */
.col {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* ---------- NAV ---------- */
nav {
  padding: 1em 0;
}

.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1em;
}

.nav-logo {
  display: flex;
  align-items: center;
}
.nav-logo img {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  object-fit: contain;
  cursor: default;
  display: block;
  /* larger tap target on touch */
  /* padding: 7px;
  margin: -7px; */
}

nav a {
  text-decoration: none;
  color: var(--dim);
  font-size: 14px;
  padding: 5px 0;
}
nav a:hover,
nav a.here {
  color: var(--fg);
  opacity: 1;
}

.dm-btn {
  background: none;
  border: none;
  color: var(--dim);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 5px 0;
}
.dm-btn:hover {
  color: var(--fg);
}

/* ---------- PAGE ---------- */
.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2em var(--pad) 5em;
}

/* ---------- UTILS ---------- */
.dim {
  color: var(--dim);
}
.small {
  font-size: 13px;
}

.back {
  font-size: 13px;
  color: var(--dim);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 1.5em;
}
.back:hover {
  color: var(--fg);
  opacity: 1;
}
.back::before {
  content: "← ";
}

/* prev / next links at the foot of a blog entry */
.entry-nav {
  display: flex;
  gap: 1.5em;
  margin-bottom: 1.6em;
  padding-bottom: 1.1em;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.entry-nav a {
  color: var(--dim);
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-nav a:hover {
  color: var(--fg);
}
.entry-nav .older::before {
  content: "← ";
}
.entry-nav .newer {
  margin-left: auto;
  text-align: right;
}
.entry-nav .newer::after {
  content: " →";
}

.tag {
  display: inline-block;
  font-size: 12px;
  color: var(--dim);
  border: 1px solid var(--border);
  padding: 0 5px;
  margin-right: 3px;
}

.section-label {
  display: block;
  font-size: 13px;
  color: var(--dim);
  margin: 1.5em 0 0.6em;
}

.star {
  text-align: left;
  color: var(--dim);
  padding: 0.4em 0;
}

/* ---------- LIST ITEMS (blog + project) ---------- */
.list-item {
  display: flex;
  gap: 0.9em;
  padding: 0.85em 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.list-item:first-of-type {
  border-top: 1px solid var(--border);
}
.list-item:hover {
  opacity: 0.6;
}

.list-thumb {
  width: 150px;
  min-width: 150px;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--border);
}

.list-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  padding-top: 0.1em;
}
.list-date {
  font-size: 12px;
  color: var(--dim);
}
.list-title {
  font-size: 14px;
}

/* ---------- ENTRY PAGES ---------- */
.entry-hero {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--border);
  margin-bottom: 1.1em;
}

/* Art that is not 16:9 gets beheaded by the cover crop. `fit` lets the image
   keep its own proportions and show in full. */
.entry-hero.fit {
  aspect-ratio: auto;
  object-fit: contain;
}

.entry-meta {
  font-size: 20px;
  color: var(--dim);
  margin-bottom: 0.2em;
}
.entry-title {
  font-size: 17px;
  margin-bottom: 1.4em;
}

.entry-section {
  margin-bottom: 2em;
}
.entry-section-head {
  font-size: 17px;
  color: var(--dim);
  margin-bottom: 0.65em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}
.entry-section p {
  font-size: 14px;
  line-height: 1.75;
  margin-bottom: 0.75em;
}
.entry-section p:last-child {
  margin-bottom: 0;
}

/* The global reset zeroes list padding, which hides the markers; put the
   indent back and match the body copy. */
.entry-section ul {
  font-size: 14px;
  line-height: 1.75;
  margin: 0 0 0.75em 1.15em;
}
.entry-section li {
  margin-bottom: 0.2em;
}
.entry-section img {
  width: 100%;
  background: var(--border);
  margin-top: 0.9em;
}

.company-logo {
  height: 20px;
  width: auto;
  object-fit: contain;
  object-position: left;
  margin-bottom: 0.4em;
}

/* sits inline with the rest of the page column (capped at --max,
   same as everything else on the site) */
.game-embed {
  width: 100%;
}

.iframe-wrapper {
  width: 600px; /* Visible size */
  height: 360px;
  overflow: hidden;
}

.iframe-wrapper iframe {
  width: 960px; /* Actual game size */
  height: 620px;
  border: 0;

  transform: scale(0.6); /* 50% size */
  transform-origin: top left;
}

.game-thumb-link {
  display: none;
}

.game-thumb {
  width: 100%;
  aspect-ratio: 900 / 620;
  object-fit: cover;
}

/* under 700px, swap the live embed for a thumbnail */
@media (max-width: 700px) {
  .iframe-wrapper {
    display: none;
  }
  .game-thumb-link {
    display: block;
    width: 100%;
  }
}

/* ---------- INDEX ---------- */
.index-section {
  margin-bottom: 2em;
}

/* ---------- RESPONSIVE ---------- */

/* Tablets and small screens */
@media (max-width: 600px) {
  body {
    font-size: 16px; /* slightly larger base for readability */
  }

  .list-thumb {
    width: 100px;
    min-width: 100px;
  }

  .entry-title {
    font-size: 16px;
  }

  /* Bigger tap targets for nav links and button */
  nav a,
  .dm-btn {
    font-size: 15px;
    padding: 0.3em 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .dm-btn {
    justify-content: flex-end;
  }
}

/* Phones (portrait) */
@media (max-width: 400px) {
  .list-thumb {
    width: 80px;
    min-width: 80px;
  }

  .list-title {
    font-size: 13px;
  }
  .list-date {
    font-size: 11px;
  }

  .entry-section p {
    font-size: 13px;
  }
}

/* Touch devices — remove hover opacity flicker on tap */
@media (hover: none) {
  a:hover {
    opacity: 1;
  }
  .list-item:hover {
    opacity: 1;
  }
  .back:hover {
    opacity: 1;
  }
  nav a:hover {
    color: var(--dim);
  }
  .dm-btn:hover {
    color: var(--dim);
  }
}

/* ---------- PLAYGROUND ---------- */
.pg-window {
  width: 100%;
  max-width: var(--max);
  border: 1px solid var(--border);
  padding: 1.25em;
}

.pg-link-btn {
  display: inline-block;
  background: none;
  border: none;
  color: var(--dim);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin-top: 0.75em;
}
.pg-link-btn:hover {
  color: var(--fg);
}

.pg-3d-bar {
  display: flex;
  gap: 0.9em;
  align-items: center;
  margin-bottom: 0.7em;
}
/* `[hidden]` is a UA-stylesheet rule (display:none) at the same
   specificity as a class/id selector -- an author rule setting `display`
   on a toggled element wins the cascade and silently defeats `hidden`
   unless it's guarded with :not([hidden]) like this. */
.pg-3d-stage:not([hidden]) {
  width: 100%;
  aspect-ratio: 1/1;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  touch-action: none;   /* the painter handles its own gestures */
}
.pg-meadow-stage {
  aspect-ratio: 16/10;
  position: relative;
  cursor: grab;
}
.pg-meadow-hint {
  font-size: 12px;
  color: var(--dim);
}
.pg-meadow-note {
  font-size: 13px;
  color: var(--dim);
  margin-top: 0.6em;
}
.m-card {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 86%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8em 1em;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.m-card h2 {
  font-size: 15px;
  margin-bottom: 0.2em;
}
.m-card .m-date {
  font-size: 12px;
  color: var(--dim);
}
.m-card p {
  font-size: 13px;
  margin-top: 0.5em;
  line-height: 1.6;
}
.m-card button {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--dim);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.pg-3d-tools:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  align-items: center;
  margin: 0.7em 0;
}
.pg-3d-tools button:not(.pg-swatch) {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
  /* without this they fall back to the browser's own light-grey chrome,
     which looks wrong in dark mode */
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
}
.pg-3d-tools .pg-swatch {
  padding: 0;
}

.pg-pen-size-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 12px;
  color: var(--dim);
}
.pg-pen-size-label input[type="range"] {
  width: 72px;
  accent-color: var(--fg);
  cursor: pointer;
}

.pg-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

/* an active mode inverts -- a border alone is too easy to miss on a toggle */
.pg-3d-tools button.pg-active:not(.pg-swatch) {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}
.pg-3d-tools .pg-swatch.pg-active {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}

#pg-form {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  max-width: 320px;
}

#pg-form input,
#pg-form textarea {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.4em;
  font: inherit;
}

#pg-form textarea {
  resize: vertical;
  min-height: 4em;
}

#pg-submit-btn {
  align-self: flex-start;
  background: var(--fg);
  color: var(--bg);
  border: none;
  padding: 0.4em 1em;
  cursor: pointer;
}

.pg-error {
  color: #c0392b;
}

.pg-pending-state,
.pg-result-state {
  padding: 1em 0;
  color: var(--dim);
}

