/* Letters with CSS theme */
:root {
  --paper: #f4efe4;
  --surface: #fffdf8;
  --tile: #fffdf8;
  --text: #1e1b18;
  --muted: #6b645a;
  --line: #e3d9c6;
  --shadow: rgb(120 90 40 / 0.35);
  --ink: #d4472c;
  --accent: #b8361f;
  --on-accent: #ffffff;
  --eyebrow: #b8361f;
  --focus: #2b5ac8;
  --font-display: "Fraunces", Georgia, serif;
  --display-weight: 600;
  --tile-zoom: 0.62;
  --box-direction: row;
  --box-guides: linear-gradient(to bottom, transparent 54px, rgb(43 90 200 / 0.28) 54px 55px, transparent 55px 185px, rgb(43 90 200 / 0.28) 185px 186px, transparent 186px);
}

/* Page styles. The drawings themselves live in style.css. */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

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

.wrap {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

.skip-link {
  position: absolute;
  left: -999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  background: var(--surface);
  padding: 0.5rem 1rem;
  border-radius: 999px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.5rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  text-decoration: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--text);
}

.btn-accent {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.btn-accent:hover {
  border-color: var(--accent);
}

.btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Hero */

.hero {
  padding-block: clamp(2.5rem, 7vw, 5.5rem) clamp(2rem, 5vw, 3.5rem);
}

.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--eyebrow);
}

.hero h1 {
  margin: 0.75rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 6.5rem);
  font-weight: var(--display-weight);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.hero p {
  max-width: 38rem;
  margin: 1.25rem 0 0;
  font-size: 1.125rem;
  color: var(--muted);
}

/* Grid of pieces */

.grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(calc(240px * var(--tile-zoom) + 2rem), 1fr)
  );
  gap: 1rem;
  margin: 0;
  padding: 0 0 clamp(2.5rem, 6vw, 4rem);
  list-style: none;
}

/* Every tile in a row matches the tallest, so wrapped labels don't break the grid. */
.grid > li {
  display: flex;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 20px;
  background: var(--tile);
  padding: 1rem 1rem 0.9rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--line);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px -14px var(--shadow);
}

.tile-label {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
}

.tile-hint {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border-radius: 999px;
  background: var(--text);
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--surface);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tile:hover .tile-hint,
.tile:focus-visible .tile-hint {
  opacity: 1;
}

/* The 240×240 box every piece is drawn in. */
.piece-box {
  position: relative;
  display: flex;
  flex-direction: var(--box-direction);
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  width: 240px;
  height: 240px;
  background-image: var(--box-guides);
  background-size: var(--box-guides-size, auto);
  background-position: center;
}

.piece-box > span {
  display: block;
}

.tile .piece-box {
  zoom: var(--tile-zoom);
}

/* More projects */

.more {
  padding-bottom: clamp(3rem, 8vw, 5rem);
}

.more h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: var(--display-weight);
}

.more-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.more-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  height: 100%;
  border-radius: 20px;
  background: var(--tile);
  padding: 1.25rem 3rem 1.25rem 1.25rem;
  text-decoration: none;
  box-shadow: 0 1px 0 var(--line);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.more-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px -14px var(--shadow);
}

.more-name {
  font-weight: 600;
}

.more-desc {
  font-size: 0.9rem;
  color: var(--muted);
}

.more-arrow {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  color: var(--muted);
}

/* Code dialog */

.code-dialog {
  width: min(60rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  border: 0;
  border-radius: 28px;
  background: var(--surface);
  padding: 0;
  color: var(--text);
  box-shadow: 0 30px 80px -24px rgb(0 0 0 / 0.35);
}

.code-dialog[open] {
  animation: dialog-in 0.2s ease-out;
}

.code-dialog::backdrop {
  background: rgb(18 16 28 / 0.45);
  backdrop-filter: blur(4px);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.dialog-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
}

.dialog-preview {
  display: grid;
  place-items: center;
  min-height: 18rem;
  background: var(--tile);
  padding: 2rem;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding: 1.75rem;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: var(--display-weight);
  line-height: 1.1;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 1.25rem;
  color: var(--text);
  cursor: pointer;
}

.tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: 0.25rem;
  border-radius: 999px;
  background: var(--paper);
  padding: 0.25rem;
}

.tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0.4rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

.code-block {
  position: relative;
  border-radius: 16px;
  background: #17151d;
}

/* Fixed height so switching between HTML and CSS doesn't resize the dialog;
   longer code scrolls inside it. */
.code-block pre {
  height: 22rem;
  margin: 0;
  overflow: auto;
  padding: 1.25rem 1.25rem 1.25rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  color: #ece8f2;
  tab-size: 2;
}

.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.08);
  padding: 0.35rem 0.8rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
}

.copy-btn:hover {
  background: rgb(255 255 255 / 0.16);
}

.dialog-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Footer */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding-block: 2rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

@media (max-width: 760px) {
  .dialog-inner {
    grid-template-columns: 1fr;
  }

  .dialog-preview {
    min-height: 14rem;
    padding: 1rem;
  }

  .dialog-preview .piece-box {
    zoom: 0.8;
  }

  .code-block pre {
    height: 16rem;
  }
}

@media (max-width: 480px) {
  :root {
    --tile-zoom: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
