/* Burrow, Storybook Critters: Clover the rabbit digs deeper with every word you
   make. Sky blue, chunky rounded type, white cards with a soft drop, sunflower
   buttons: the same storybook as the other games, and its shared pieces (the
   header, sheets, stats and dark colors) are theirs. */

:root {
  color-scheme: light;
  --sky: #cfeaff;
  --ink: #2e2a3b;
  --on-sun: #2e2a3b; /* text on sunny buttons and wooden signs, dark in both themes */
  --ink-2: #3e3a52;
  --muted: #5b5670;
  --card: #ffffff;
  --card-edge: #9cc8ea;
  --track: #eaf4ff;
  --sun: #ffb938;
  --sun-edge: #d68a00;
  --coral: #ff6f61;
  --leaf: #7bc96f;
  --tile: #ffe7b8; /* letter tiles, like Mother Tongue's wooden signs */
  --tile-edge: #b88a4e;
  --soil-1: #b07a4f; /* the burrow's layers, top to bottom */
  --soil-2: #8f5e3b;
  --soil-3: #7a6a5d;
  --soil-4: #4e4378;
  --soil-5: #2f6f7e;
  --error: #b23a2e;
  --good: #2f7d3e;
  --link: #1f5f99;
  --display: Fredoka, Nunito, system-ui, sans-serif;
  font: 16px/1.5 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
/* Headings break evenly, and paragraphs don't end on one short word. */
h1,
h2,
h3 {
  text-wrap: balance;
}

p,
li {
  text-wrap: pretty;
}

body {
  margin: 0;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sky);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: var(--link);
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

:focus-visible {
  outline: 3px solid rgba(31, 95, 153, 0.45);
  outline-offset: 3px;
}

.sheet h2:focus {
  outline: none;
}

/* Header */

.top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 14px 16px 6px;
}

.wordmark {
  text-align: center;
}

.wordmark h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.1;
}

.day-label {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--card-edge);
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
}

/* Layout and shared pieces */

main {
  flex: 1;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 6px 16px 24px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--card-edge);
}

.primary {
  min-height: 54px;
  padding: 12px 20px;
  border: 0;
  border-radius: 18px;
  background: var(--sun);
  box-shadow: 0 4px 0 var(--sun-edge);
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  color: var(--on-sun);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.primary:hover {
  filter: brightness(1.04);
}

.primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--sun-edge);
}

.secondary {
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
}

.link {
  align-self: center;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
}

.kicker {
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.note {
  margin: -6px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.note.reading {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.feedback {
  min-height: 22px;
  margin: -6px 0 0;
  text-align: center;
  font-weight: 700;
  color: var(--error);
}

.feedback.ok {
  color: var(--good);
}

/* Start screen */

.hello {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
}

.hello-clover {
  width: 112px;
  height: 112px;
  flex: none;
}

.bubble {
  position: relative;
  margin: 0 0 58px;
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--card-edge);
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
}

.bubble::after {
  content: "";
  position: absolute;
  right: -14px;
  bottom: 12px;
  border: 8px solid transparent;
  border-left-color: var(--card);
}

.headline {
  margin: -6px 0 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.2;
}

#intro > p {
  margin: 0;
  text-align: center;
  color: var(--ink-2);
}

#intro > .fine {
  font-size: 13px;
}

.example {
  display: grid;
  gap: 8px;
}

.example p {
  margin: 0;
}

.example .example-answer {
  margin: -4px 0 2px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
}

.example-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.example-row .muted {
  font-weight: 400;
}

/* Tiers */

.tier-list {
  display: grid;
  gap: 2px;
  padding: 6px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--card-edge);
}

.tier {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 14px;
}

.tier svg {
  width: 22px;
  height: 22px;
  flex: none;
}

.tier b {
  flex: 1;
  font-family: var(--display);
  font-weight: 600;
}

.tier span {
  color: var(--muted);
}

.tier.now {
  min-height: 42px;
  background: var(--sun);
  color: var(--on-sun);
}

.tier.now span {
  color: var(--ink);
  font-weight: 800;
}

/* Results */

.results-hero {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
}

.hug-clover {
  width: 132px;
  height: 132px;
}

#results .kicker + .kicker {
  margin-top: -12px;
}

.tier-name {
  margin: -10px 0 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 38px;
  line-height: 1.1;
}

.total {
  margin: -8px 0 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
}

.total .muted {
  font-family: Nunito, sans-serif;
  font-weight: 400;
}

#total-note {
  margin: -12px 0 0;
  text-align: center;
}

.summary {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 16px;
  list-style: none;
}

.summary li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
}

.s-question {
  font-size: 14px;
  font-weight: 700;
}

.s-detail {
  grid-column: 1;
  font-size: 13px;
  color: var(--muted);
}

.s-points {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--track);
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
}

.s-points.great {
  background: var(--sun);
  color: var(--on-sun);
}

.next-in {
  margin: 0;
  text-align: center;
  color: var(--ink-2);
}

.next-in strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Dialogs */

.sheet {
  width: min(460px, calc(100% - 32px));
  padding: 20px;
  border: 0;
  border-radius: 24px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--card-edge);
}

.sheet::backdrop {
  background: rgba(46, 42, 59, 0.45);
}

.sheet h2 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 700;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-head h2 {
  margin: 0;
}

.sheet-clover {
  width: 64px;
  height: 64px;
  flex: none;
}

.sheet ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
  padding-left: 20px;
}

.sheet .primary {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  padding: 12px 6px;
  border-radius: 16px;
  background: var(--sky);
  text-align: center;
}

.stat strong {
  display: block;
  font-family: var(--display);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: 12px;
  color: var(--ink-2);
}

.foot {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 10px 16px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-2);
}

.foot p {
  text-wrap: balance;
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* The header: help on the left, stats and settings on the right, the name centered */

.top {
  grid-template-columns: 1fr auto 1fr;
}

.top > .icon-button {
  justify-self: start;
}

.top-end {
  display: flex;
  gap: 6px;
  justify-self: end;
}

@media (max-width: 400px) {
  .top .icon-button {
    width: 38px;
    height: 38px;
  }

  .wordmark h1 {
    font-size: 23px;
  }
}

/* The settings sheet (settings.js) */

.setting {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.setting legend,
.toggle > span:first-of-type {
  padding: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 46px;
  padding: 6px 8px;
  border-radius: 14px;
  background: var(--track);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--sun);
  box-shadow: 0 3px 0 var(--sun-edge);
  color: var(--on-sun);
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  margin: 0 0 16px;
  cursor: pointer;
}

.toggle input {
  grid-row: span 2;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--sun-edge);
}

.toggle-note,
.setting-note {
  font-size: 13px;
  color: var(--muted);
}

.setting-note {
  margin: 0 0 14px;
}

/* Stats: your days by tier, and the last five weeks (stats-view.js) */

.stats-sub {
  margin: 18px 0 8px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
}

.tier-bars {
  display: grid;
  gap: 6px;
}

.tier-bar {
  display: grid;
  grid-template-columns: minmax(0, 10em) 1fr 2em;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.tier-bar-label {
  overflow: hidden;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tier-bar.now {
  color: var(--ink);
}

.tier-bar.now .tier-bar-label {
  font-weight: 800;
}

.tier-bar-track {
  height: 14px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--track);
}

.tier-bar-fill {
  display: block;
  height: 100%;
  border-radius: 7px;
}

.tier-bar-count {
  font-weight: 800;
  text-align: right;
}

.calendar {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.cal-head,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-head span {
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  color: var(--muted);
}

.cal-day {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 9px;
  background: var(--track);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.cal-day.played {
  background: var(--c);
  font-weight: 800;
  color: var(--on-sun);
}

.cal-day.deep {
  color: #fff;
}

.cal-day.today {
  box-shadow: inset 0 0 0 2px var(--ink);
}

.cal-day.out {
  opacity: 0.35;
}

/* How everyone did today (everyone.js), under the results */

.everyone {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--track);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  color: var(--ink-2);
}

/* Dark colors, chosen in Settings or by the device (settings.js sets data-theme).
   The art keeps its own colors; text on sunny buttons and wooden signs stays dark. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --sky: #141a2b;
  --ink: #f3f0fb;
  --ink-2: #d6d0e8;
  --muted: #a8a2c0;
  --card: #1f2638;
  --card-edge: #0a0e18;
  --track: #2b3449;
  --error: #ff8f80;
  --good: #7ed98b;
  --link: #93c8ff;
  --glass: rgba(31, 38, 56, 0.92);
  --glass-soft: rgba(31, 38, 56, 0.6);
}

/* Less motion, chosen in Settings (the device's own setting is handled above) */
:root[data-motion="less"] *,
:root[data-motion="less"] *::before,
:root[data-motion="less"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}


/* Playing: the clock, the word being made, the seven tiles */

.play-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.timer span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--leaf);
  transition: width 0.25s linear;
}

.timer.low span {
  background: var(--coral);
}

.time-left {
  min-width: 52px;
  text-align: right;
  font: 700 20px var(--display);
  font-variant-numeric: tabular-nums;
}

.score-line {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font: 600 18px var(--display);
}

.score-line .muted {
  font-family: Nunito, sans-serif;
  font-weight: 800;
  font-size: 15px;
}

.word {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 66px;
  margin: 18px 0 8px;
}

.word .slot {
  display: grid;
  place-items: center;
  width: 42px;
  height: 54px;
  border-radius: 12px;
  background: var(--tile);
  border-bottom: 5px solid var(--tile-edge);
  color: var(--on-sun);
  font: 700 30px var(--display);
  text-transform: uppercase;
  animation: burrow-pop 0.18s ease-out;
}

.word .hint {
  color: var(--muted);
  font-weight: 800;
}

.word.shake {
  animation: burrow-shake 0.35s;
}

.tiles {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.tile {
  width: 46px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: var(--card);
  box-shadow: 0 5px 0 var(--card-edge);
  font: 700 32px var(--display);
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.tile:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--card-edge);
}

.tile.used {
  opacity: 0.3;
  transform: translateY(4px);
  box-shadow: none;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1.6fr;
  gap: 10px;
  margin-top: 20px;
}

.controls button {
  min-height: 52px;
  margin: 0;
}

#feedback {
  min-height: 26px;
  margin: 12px 0 0;
}

/* What's been found, and how deep Clover is */

.dig {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 14px;
  margin-top: 14px;
}

.found {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.found:empty::before {
  content: "Words you find go here.";
  color: var(--muted);
  font-weight: 700;
}

.found li {
  padding: 3px 10px 5px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 2px 0 var(--card-edge);
  font-weight: 800;
  font-size: 15px;
}

.found li b {
  margin-left: 4px;
  color: var(--muted);
}

.found li.seven {
  background: var(--sun);
  color: var(--on-sun);
}

.found li.seven b {
  color: var(--on-sun);
}

.found li.new {
  animation: burrow-pop 0.35s ease-out;
}

/* The burrow: layers for the tiers (Topsoil to 40 m, Root Cellar to 80, Clay Seam to 130, Bedrock to 190, then the Glowworm Cave), on a 220 m scale. */
.gauge {
  position: relative;
  height: 270px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(var(--leaf) 0 12px, var(--soil-1) 12px 18%, var(--soil-2) 18% 36%, var(--soil-3) 36% 59%, var(--soil-4) 59% 86%, var(--soil-5) 86%);
}

.gauge .tunnel {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 12px;
  margin-left: -6px;
  border-radius: 0 0 6px 6px;
  background: rgba(20, 12, 6, 0.4);
  transition: height 0.6s ease-out;
}

.gauge .digger {
  position: absolute;
  left: 50%;
  width: 52px;
  height: 52px;
  margin: -40px 0 0 -26px;
  transition: top 0.6s ease-out;
}

.gauge .meters {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  color: #fff;
  text-align: center;
  font: 700 16px var(--display);
}

/* Results */

.finds {
  margin-top: 16px;
  padding: 14px 16px;
  text-align: left;
}

.finds p {
  margin: 0 0 8px;
}

.finds p:last-child {
  margin-bottom: 0;
}

.finds .w {
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tier-ladder {
  display: grid;
  gap: 4px;
  margin-top: 14px;
}

#tier-blurb {
  margin: 2px 0 0;
  text-align: center;
}

.tier-ladder > span {
  display: flex;
  justify-content: space-between;
  padding: 6px 14px;
  border-radius: 12px;
  color: #fff;
  font: 600 16px var(--display);
}

.tier-ladder > span.now {
  outline: 3px solid var(--sun);
  outline-offset: -3px;
}

@keyframes burrow-pop {
  0% {
    transform: scale(0.6);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes burrow-shake {
  25% {
    transform: translateX(-8px);
  }
  50% {
    transform: translateX(8px);
  }
  75% {
    transform: translateX(-4px);
  }
}

@media (max-width: 370px) {
  .tile {
    width: 41px;
    height: 54px;
    font-size: 28px;
  }
  .word .slot {
    width: 38px;
  }
}
