/* Word Fishing: a bright morning harbour. The page is pale sea glass so the
   scene carries the colour; the word sits on a white dock sign with a brass
   porthole for the picture. ABeeZee (drawn for children learning to read, with
   a one-storey a and g) for letters and words, Lilita One for the title. */

:root {
  --mist: #e4f0ef;
  --mist-deep: #cfe2e2;
  --ink: #12354d;
  --ink-soft: #3d5d72;
  --harbour: #145a83;
  --harbour-deep: #0e4565;
  --buoy: #c8432a;
  --buoy-hover: #b23820;
  --brass: #b98a3c;
  --brass-dark: #8a6327;
  --porthole: #dff3fa;
  --sign: #fffdf8;
  --tile: #edf5f6;
  --tile-line: #93b3c3;
  --sun: #ffcf4a;
  --sun-hover: #ffdb73;
  --leaf: #2f8a5a;

  --display: "Lilita One", "Arial Rounded MT Bold", sans-serif;
  --body: "ABeeZee", "Andika", system-ui, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

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

html { color-scheme: light; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--mist);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--body);
}

.harbour {
  max-width: 64rem;
  margin: 0 auto;
  padding: clamp(0.6rem, 2vw, 1.4rem) clamp(1rem, 3vw, 2rem) 2.5rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
  margin-bottom: 0.8rem;
}
.back { color: var(--ink-soft); text-underline-offset: 3px; }
.back:hover { color: var(--ink); }
h1 {
  margin: 0;
  flex: 1;
  font: 400 clamp(1.6rem, 3.6vw, 2.4rem)/1.05 var(--display);
  color: var(--harbour);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.levels { display: flex; gap: 0.3rem; padding: 0.3rem; border-radius: 999px; background: var(--mist-deep); }
.levels button {
  min-height: 2.75rem;
  font: 400 0.95rem/1.1 var(--body);
  padding: 0.4rem 0.95rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.levels button[aria-pressed="true"] { background: var(--harbour); color: #fff; }
.levels button:hover:not([aria-pressed="true"]) { color: var(--ink); background: rgba(255, 255, 255, 0.5); }

/* the sign hangs on the dock above the water */
.stage {
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 0.9rem 2.6rem rgba(18, 53, 77, 0.22);
}

.card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "pic tiles hear" "hint hint hint";
  align-items: center;
  gap: 0.5rem 1.1rem;
  padding: 0.75rem 1.1rem 0.7rem;
  background: var(--sign);
  border-bottom: 0.4rem solid var(--brass);
}

.porthole {
  grid-area: pic;
  display: grid;
  place-items: center;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--porthole);
  border: 0.35rem solid var(--brass);
  box-shadow: inset 0 0 0 0.2rem rgba(255, 255, 255, 0.8), 0 0 0 2px var(--brass-dark);
}
.picture {
  font: 400 3.1rem/1 var(--emoji);
}
.picture.arrive { animation: arrive 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }

.tiles {
  grid-area: tiles;
  display: flex;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tiles li {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 4rem;
  border-radius: 0.6rem;
  background: var(--tile);
  border: 2px dashed var(--tile-line);
  font: 400 2.5rem/1 var(--body);
  color: var(--ink);
}
.tiles li.next { border: 3px solid var(--buoy); background: #fff; }
.tiles li.fill { background: #fff; border: 2px solid var(--harbour); box-shadow: 0 0.2rem 0 var(--harbour); }
.tiles li.fill span { animation: pop 0.4s cubic-bezier(0.3, 1.7, 0.5, 1); }
/* a little splash ring when a letter lands */
.tiles li.fill::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 0.7rem;
  border: 3px solid #5cc6e6;
  opacity: 0;
  animation: splash 0.6s ease-out;
}
.tiles.cheer li { animation: bounce 0.6s cubic-bezier(0.3, 1.5, 0.5, 1) both; animation-delay: calc(var(--i, 0) * 0.08s); }
.tiles.cheer li.fill { border-color: var(--leaf); box-shadow: 0 0.2rem 0 var(--leaf); }

.hear {
  grid-area: hear;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 0;
  border-radius: 50%;
  background: var(--sun);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 0.18rem 0 #d9a514;
}
.hear:hover { background: var(--sun-hover); }
.hear:active { transform: translateY(2px); box-shadow: none; }
.hear[hidden] { display: none; }

.hint {
  grid-area: hint;
  margin: 0;
  min-height: 3em;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100svh - 17rem);
  touch-action: none;
  cursor: crosshair;
  background: #56c0dc;
}
canvas:focus-visible { outline: 4px solid var(--sun); outline-offset: -4px; }

.below {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 0.9rem;
}
.progress {
  display: grid;
  grid-template-columns: repeat(8, 2.6rem);
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.progress li {
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  background: var(--mist-deep);
  color: var(--brass-dark);
  font-size: 0.65rem;
  letter-spacing: -0.05em;
}
.progress li.now { box-shadow: inset 0 0 0 2px var(--harbour); }
.progress li.done { background: #fff; }

.tally { display: flex; gap: 1.25rem; margin: 0 0 0 auto; }
.tally div { display: flex; align-items: baseline; gap: 0.4rem; }
.tally dt { font-size: 0.95rem; color: var(--ink-soft); }
.tally dd { margin: 0; font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.again {
  min-height: 2.75rem;
  font: 400 1rem/1 var(--body);
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--buoy);
  color: #fff;
  cursor: pointer;
}
.again:hover { background: var(--buoy-hover); }
.again:focus-visible,
.hear:focus-visible,
.levels button:focus-visible,
.back:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.keys { max-width: 46rem; margin: 1.4rem 0 0; font-size: 0.95rem; color: var(--ink-soft); }

.about { max-width: 46rem; margin-top: 1.5rem; }
.about h2 { margin: 0 0 0.25rem; font: 400 1.25rem/1.2 var(--display); color: var(--harbour); }
.about p { margin: 0; font-size: 0.95rem; color: var(--ink-soft); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@keyframes pop { from { transform: translateY(-0.6em) scale(0.4); opacity: 0; } }
@keyframes splash { 0% { opacity: 0.9; transform: scale(0.9); } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes bounce { 40% { transform: translateY(-0.7rem); } 70% { transform: translateY(0.1rem); } }
@keyframes arrive { from { transform: scale(0.3); opacity: 0; } }

@media (max-width: 760px) {
  .harbour { padding-top: 0.5rem; }
  .top { gap: 0.35rem 1rem; margin-bottom: 0.55rem; }
  .levels { width: 100%; }
  .levels button { flex: 1; padding: 0.3rem 0.4rem; font-size: 0.9rem; }
  .card { gap: 0.35rem 0.6rem; padding: 0.5rem 0.65rem 0.5rem; border-bottom-width: 0.3rem; }
  .porthole { width: 3.6rem; height: 3.6rem; border-width: 0.25rem; }
  .picture { font-size: 2.15rem; }
  .tiles { gap: 0.25rem; }
  .tiles li { width: 2.35rem; height: 2.8rem; font-size: 1.75rem; border-radius: 0.45rem; }
  .hear { width: 2.75rem; height: 2.75rem; }
  .hint { font-size: 1rem; min-height: 4.35em; line-height: 1.45; }
  canvas { aspect-ratio: 6 / 7; max-height: none; }
  .below { margin-top: 0.7rem; gap: 0.6rem 1rem; }
  .progress { grid-template-columns: repeat(8, 1fr); width: 100%; }
  .progress li { height: 1.9rem; }
  .tally { margin: 0; }
  .again { margin-left: auto; }
  .keys, .about p { font-size: 1rem; }
}

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