/* webthinking.io: the tools site. */

@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #eceae3;
  --tile: #ffffff;
  --tile-2: #fbf6ec;
  --line: #dcd8cc;
  --text: #17181c;
  --muted: #5d5f68;
  --accent: #e8452c;
  --accent-ink: #ffffff;
  --g1: #e8452c;
  --g2: #d02a8a;
  --g3: #6d4cff;
  --logo-bg: #17181c;
  --shadow: 0 1px 2px rgba(23, 24, 28, 0.06), 0 12px 32px -18px rgba(23, 24, 28, 0.25);
  --radius: 22px;
  --gap: clamp(12px, 1.6vw, 18px);
  --pad: clamp(20px, 4vw, 56px);
  --web: 0.42;
  color-scheme: light;
}

/* Light is the default. The page sets data-theme to light, dark or system
   (follow the device) before it paints, from the visitor's saved choice. */
:root[data-theme="dark"] {
  --bg: #0c0d10;
  --tile: #1d1f25;
  --tile-2: #272c36;
  --line: #30333b;
  --text: #f1efe9;
  --muted: #a3a6b1;
  --accent: #ff6a4d;
  --accent-ink: #16171b;
  --g1: #ff6a4d;
  --g2: #f0509f;
  --g3: #a58bff;
  --logo-bg: #22252c;
  --web: 0.6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0c0d10;
    --tile: #1d1f25;
    --tile-2: #272c36;
    --line: #30333b;
    --text: #f1efe9;
    --muted: #a3a6b1;
    --accent: #ff6a4d;
    --accent-ink: #16171b;
    --g1: #ff6a4d;
    --g2: #f0509f;
    --g3: #a58bff;
    --logo-bg: #22252c;
    --web: 0.6;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -20px rgba(0, 0, 0, 0.8);
    color-scheme: light dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

a {
  color: inherit;
}

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

/* ---------- Layout: brand panel + tool shelf ---------- */

/* On wide screens the left column is a panel the height of the window: the
   name at the top, the theme switch and credits at the bottom, and a web
   drawn behind the space between. All three share the column's one grid
   area, so each can stick for the whole length of the page. */
.page {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 64px);
  max-width: 1280px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: var(--pad);
}

.web,
.intro,
.foot {
  grid-column: 1;
  grid-row: 1;
}

.shelf {
  grid-column: 2;
  grid-row: 1;
}

.intro {
  position: sticky;
  top: var(--pad);
  align-self: start;
}

.web {
  position: sticky;
  top: var(--pad);
  align-self: start;
  width: calc(100% + var(--pad));
  height: calc(100vh - 2 * var(--pad));
  height: calc(100svh - 2 * var(--pad));
  margin-left: calc(-1 * var(--pad));
  pointer-events: none;
  opacity: var(--web);
}

.web path {
  fill: none;
  stroke: url(#webg);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.web stop:nth-child(1) { stop-color: var(--g1); }
.web stop:nth-child(2) { stop-color: var(--g2); }
.web stop:nth-child(3) { stop-color: var(--g3); }

.web-knots {
  fill: #ffb547;
}

.foot {
  position: sticky;
  bottom: var(--pad);
  align-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.credit {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.credit p {
  margin: 0;
}

.credit a {
  color: var(--text);
  font-weight: 600;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.mark {
  display: block;
  flex: none;
  width: 88px;
  height: 88px;
  margin: 0 0 28px;
}

.mark-tile {
  fill: var(--logo-bg);
}

/* "web" in the text colour, "thinking" stepping from orange to violet. */
.think {
  background: linear-gradient(90deg, var(--g1), var(--g2) 55%, var(--g3));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--g2);
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
}

.pitch {
  max-width: 15ch;
  margin: 14px 0 0;
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--muted);
}

/* ---------- Theme switch ---------- */

.theme {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.theme button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.theme button:hover {
  color: var(--text);
}

.theme button[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

/* Wide screens show the words; narrow ones swap them for icons. */
.theme .ico {
  display: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The switch needs JavaScript, and so does remembering the choice. */
html:not(.js) .theme {
  display: none;
}

/* A screenshot for each theme; only the matching one shows. */
.img-dark {
  display: none !important;
}

:root[data-theme="dark"] .img-light {
  display: none !important;
}

:root[data-theme="dark"] .img-dark {
  display: block !important;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .img-light {
    display: none !important;
  }

  :root[data-theme="system"] .img-dark {
    display: block !important;
  }
}

/* ---------- Tiles ---------- */

.shelf {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: var(--gap);
}

.tile {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 2.4vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--tile);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.tile:hover {
  transform: translateY(-3px);
}

/* Scorpion Solitaire gets the larger share of the row, gcwind the narrower one. */
.tile-wide {
  grid-column: span 4;
  display: flex;
  flex-direction: column;
}

.tile-tall {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
}

.tile-feature {
  grid-column: span 6;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(20px, 3vw, 40px);
  align-items: center;
}

.tile-feature .shot {
  align-self: stretch;
  margin: calc(-1 * clamp(20px, 2.4vw, 28px)) calc(-1 * clamp(20px, 2.4vw, 28px)) calc(-1 * clamp(20px, 2.4vw, 28px)) 0;
  padding-top: clamp(20px, 2.4vw, 28px);
  padding-bottom: clamp(20px, 2.4vw, 28px);
}

/* The app's name is the tile's headline. */
.tile h2 {
  margin: 0;
  font-size: clamp(2rem, 3.4vw, 2.75rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
}

.tile-feature h2 {
  font-size: clamp(2.4rem, 4.6vw, 3.6rem);
}

.tile p {
  margin: 0;
}

.tile-text > p:not(.actions) {
  max-width: 34ch;
  margin-top: 12px;
  font-size: clamp(1.05rem, 1.5vw, 1.2rem);
  color: var(--muted);
}

.tile-text > p a {
  color: var(--text);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 18px !important;
}

.go {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.go:hover {
  transform: translateX(3px);
}

/* Screenshots sit at the bottom of their tile, cropped by the tile's edge. */
.shot {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 24px calc(-1 * clamp(20px, 2.4vw, 28px)) calc(-1 * clamp(20px, 2.4vw, 28px));
  padding: 0 clamp(20px, 2.4vw, 28px);
  /* A shade of its own, lighter than the page, so the screenshots sit apart
     from it without looking sunk into the tile. */
  background: var(--tile-2);
  min-height: 220px;
}

.shot img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px 14px 0 0;
  transition: transform 0.4s ease;
}

.shot-phone img {
  width: min(82%, 300px);
  margin-top: 28px;
  border: 6px solid var(--text);
  border-bottom: 0;
  border-radius: 30px 30px 0 0;
}

.shot-screen {
  align-items: center;
  padding-top: 28px;
  padding-bottom: 28px;
}

.shot-screen img {
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.tile:hover .shot img {
  transform: translateY(-4px);
}

/* ---------- Narrow screens ---------- */

@media (max-width: 1100px) {
  .tile-tall,
  .tile-wide {
    grid-column: span 6;
    grid-row: auto;
  }

  .tile-feature {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .tile-feature .shot {
    margin: 24px calc(-1 * clamp(20px, 2.4vw, 28px)) calc(-1 * clamp(20px, 2.4vw, 28px));
  }

  .tile-tall .shot,
  .tile-wide .shot,
  .tile-feature .shot {
    min-height: 0;
  }
}

/* A short window gets a smaller name, so the panel's top and bottom
   never meet. */
@media (min-width: 861px) and (max-height: 640px) {
  .mark {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
  }

  h1 {
    font-size: 2.6rem;
  }

  .pitch {
    margin-top: 8px;
    font-size: 1.2rem;
  }
}

/* Without room for the panel, the name becomes a header over the tiles,
   and the theme switch and credits follow them. */
@media (max-width: 860px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(24px, 3.6vw, 44px);
  }

  .intro,
  .shelf,
  .foot {
    grid-column: 1;
    grid-row: auto;
  }

  .intro,
  .foot {
    position: static;
  }

  .web {
    display: none;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
  }

  .mark {
    width: 60px;
    height: 60px;
    margin: 0;
  }

  h1 {
    font-size: clamp(2.3rem, 5vw, 2.8rem);
  }

  .pitch {
    max-width: none;
    margin-top: 6px;
    font-size: 1.1rem;
  }

  .foot {
    padding-top: 8px;
  }
}

/* Phones show the theme switch as icons. */
@media (max-width: 760px) {
  .theme button {
    min-width: 44px;
    padding: 6px 12px;
  }

  .theme .ico {
    display: block;
  }

  /* Hidden from sight, still read out as the button's name. */
  .theme .label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

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

@media (forced-colors: active) {
  .think {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: CanvasText;
  }

  .go {
    border: 1px solid ButtonText;
  }
}
