/*
 * AskAndrew.cc styles.
 * The blue, red and yellow are taken straight from Logo.gif.
 * No outside fonts or images are loaded: only fonts already on the visitor's device.
 */

:root {
  --blue: #3300cc;
  --blue-deep: #1f0080;
  --red: #d50020;
  --yellow: #ffd400;
  --ink: #1b0f52;
  --paper: #ffffff;
  --tint: #efecff;
  --line: 3px solid var(--blue);
  --display: "Trebuchet MS", "Lucida Grande", "Segoe UI", sans-serif;
  --body: Verdana, Geneva, "DejaVu Sans", sans-serif;
  color-scheme: light;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 1.5rem 1rem 2.5rem;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--body);
}

.masthead,
main,
.footer {
  max-width: 760px;
  margin-inline: auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h2 {
  margin: 2.75rem 0 0.9rem;
  color: var(--blue);
  font: italic bold 1.9rem/1.1 var(--display);
}

h3 {
  margin-bottom: 0.8rem;
  color: var(--blue);
  font: italic bold 1.25rem/1.2 var(--display);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.note {
  font-size: 0.82rem;
  line-height: 1.5;
}

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

/* ---------- Masthead ---------- */

.masthead {
  text-align: center;
}

.masthead img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.tagline {
  margin-top: 0.2rem;
  font: italic bold 1.05rem/1.3 var(--display);
}

/* ---------- Ask Andrew ---------- */

.ask {
  margin-top: 2rem;
}

/* A speech bubble whose tail points up at the logo: the logo is the one talking. */
.bubble {
  position: relative;
  display: grid;
  align-content: center;
  min-height: 8.5rem;
  padding: 1.1rem 1.5rem 1.3rem;
  border: var(--line);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 7px 7px 0 var(--yellow);
  text-align: center;
}

.bubble::before,
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  border-style: solid;
  border-color: transparent;
  border-top-width: 0;
}

.bubble::before {
  top: -24px;
  margin-left: -16px;
  border-width: 0 16px 24px;
  border-bottom-color: var(--blue);
}

.bubble::after {
  top: -17px;
  margin-left: -11px;
  border-width: 0 11px 17px;
  border-bottom-color: var(--paper);
}

.bubble-asked {
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.bubble-answer {
  margin-top: 0.3rem;
  color: var(--blue);
  font: italic bold clamp(1.45rem, 4.6vw, 2.15rem) / 1.2 var(--display);
  text-wrap: balance;
}

.bubble.pop {
  animation: pop 0.22s ease-out;
}

@keyframes pop {
  from { transform: scale(0.95); }
  60%  { transform: scale(1.02); }
  to   { transform: scale(1); }
}

.ask-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.ask-form input {
  flex: 1 1 14rem;
}

.ask .note {
  margin-top: 0.8rem;
}

/* ---------- Buttons and fields ---------- */

.btn {
  padding: 0.6rem 1.05rem;
  border: var(--line);
  border-radius: 10px;
  background: var(--blue);
  box-shadow: 0 4px 0 var(--blue-deep);
  color: #fff;
  font: bold 1rem/1.2 var(--display);
  white-space: nowrap;
  cursor: pointer;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--blue-deep);
}

.btn.quiet {
  background: var(--paper);
  color: var(--blue);
}

.btn.small {
  padding: 0.4rem 0.8rem;
  font-size: 0.92rem;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--blue);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.3 var(--body);
}

.ask-form input {
  border-width: 3px;
  border-radius: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0 0.3rem 0 0;
  accent-color: var(--blue);
  vertical-align: -0.15em;
}

.field {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.82rem;
}

/* ---------- Games ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.35rem;
}

.tab {
  margin-bottom: -3px;
  padding: 0.5rem 0.9rem;
  border: var(--line);
  border-radius: 10px 10px 0 0;
  background: var(--tint);
  color: var(--blue);
  font: bold 1rem/1.2 var(--display);
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--yellow);
  color: var(--ink);
}

.stage {
  padding: 1.25rem;
  border: var(--line);
  border-radius: 0 6px 6px 6px;
}

.game {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.25rem 1.75rem;
}

.game-side {
  display: grid;
  flex: 1 1 13rem;
  gap: 0.7rem;
  justify-items: start;
}

.score {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  padding-bottom: 0.25rem;
  border-bottom: 2px dotted var(--blue);
}

.score b {
  color: var(--blue);
  font: italic bold 1.5rem/1 var(--display);
}

.snake-canvas {
  width: 360px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  border: var(--line);
  border-radius: 4px;
  touch-action: none; /* swipes steer the snake instead of scrolling the page */
}

.pairs-grid,
.oxo-grid {
  display: grid;
  gap: 0.5rem;
  width: 360px;
  max-width: 100%;
}

.pairs-grid {
  grid-template-columns: repeat(4, 1fr);
}

.oxo-grid {
  grid-template-columns: repeat(3, 1fr);
  width: 300px;
}

.pair-card,
.oxo-cell {
  aspect-ratio: 1;
  padding: 0;
  border: var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.pair-card {
  background: var(--blue);
  font-size: clamp(1.6rem, 9vw, 2.4rem);
  line-height: 1;
}

.pair-card.up {
  background: var(--paper);
}

.pair-card.done {
  background: var(--yellow);
  cursor: default;
}

.oxo-cell {
  background: var(--paper);
  color: var(--blue);
  font: bold clamp(2.2rem, 13vw, 3.4rem) / 1 var(--display);
}

.oxo-cell.nought {
  color: var(--red);
}

.oxo-cell.win {
  background: var(--yellow);
}

.react-pad {
  flex: 1 1 18rem;
  min-height: 15rem;
  padding: 1rem;
  border: var(--line);
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font: italic bold 1.6rem/1.25 var(--display);
  cursor: pointer;
  touch-action: manipulation;
}

.react-pad[data-state="waiting"],
.react-pad[data-state="early"] {
  background: var(--red);
}

.react-pad[data-state="go"] {
  background: var(--yellow);
  color: var(--ink);
}

/* ---------- Tools ---------- */

.tools {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.tool {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem 1.3rem;
  border: var(--line);
  border-radius: 6px;
}

.tool h3 {
  margin-bottom: 0;
}

.tool.wide {
  grid-column: span 3;
}

.tool.narrow {
  grid-column: span 2;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.row > div {
  flex: 1 1 0;
  min-width: 0;
}

.row > .grow {
  flex-grow: 2;
}

.row.centred {
  flex-wrap: wrap;
  justify-content: center;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
}

.password {
  font-family: Consolas, Menlo, "DejaVu Sans Mono", monospace !important;
}

.result {
  font-size: 0.9rem;
}

.result b {
  color: var(--blue);
}

.result.big {
  color: var(--blue);
  font: italic bold 1.35rem/1.25 var(--display);
}

.token {
  display: grid;
  place-items: center;
  width: 6.5rem;
  height: 6.5rem;
  margin: 0.2rem auto 0.3rem;
  border: var(--line);
  background: var(--yellow);
  color: var(--ink);
  font: italic bold 1.35rem/1 var(--display);
}

.token[data-kind="coin"] {
  border-radius: 50%;
}

.token[data-kind="dice"] {
  border-radius: 16px;
  background: var(--paper);
  color: var(--red);
  font-size: 3.4rem;
  font-style: normal;
}

.token.pop {
  animation: pop 0.22s ease-out;
}

/* ---------- Footer ---------- */

.footer {
  margin-top: 3rem;
  font-size: 0.72rem;
  text-align: center;
}

/* ---------- Small screens and reduced motion ---------- */

@media (max-width: 640px) {
  .tools {
    grid-template-columns: 1fr;
  }

  .tool.wide,
  .tool.narrow {
    grid-column: auto;
  }

  .stage {
    padding: 0.9rem;
  }

  .ask-form .btn {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bubble.pop,
  .token.pop {
    animation: none;
  }
}
