/* The paper, card, accent and line colors change with the seasons, set by
   ../shared/seasons.js. These defaults are spring's, for the moment before the
   script runs, which the splash covers. */
:root {
  --paper: #f9eff0;
  --card: #fffafa;
  --ink: #1f2a30;
  --accent: #8b2d55;
  --accent-dark: #5f1c3a;
  --line: #9c7480;
  --hint-fill: #ffe6ad;
  --hint-line: #9a5f00;
  --hint-ink: #3d2a00;
  --quiet-ink: #47525a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 400ms ease;
}

[hidden] {
  display: none !important;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 8px) 14px calc(env(safe-area-inset-bottom) + 10px);
}

#status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: clamp(16px, 4.6vw, 20px);
  font-weight: 700;
  white-space: nowrap;
}

#board-area {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 6px 0;
}

#board {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-auto-rows: var(--cell);
  gap: 4px;
}

.cell {
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 14%;
  background: var(--card);
  color: transparent;
  font-size: calc(var(--cell) * 0.64);
  font-weight: 800;
  line-height: 1;
}

.cell.shown {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  animation: settle 200ms ease-out;
}

.cell.hinted {
  border-color: var(--hint-line);
  background: var(--hint-fill);
  color: var(--hint-ink);
  animation: settle 200ms ease-out;
}

@keyframes settle {
  from {
    transform: scale(0.82);
  }
}

#entry {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 2px 0 8px;
  text-align: center;
}

/* Between puzzles, the panel says everything, so the message line steps aside. */
#app:has(#done:not([hidden])) #entry {
  display: none;
}

#current {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

#message {
  margin: 0;
  font-size: clamp(17px, 4.8vw, 20px);
  font-weight: 600;
  line-height: 1.2;
}

#play {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#wheel {
  position: relative;
  flex: none;
  width: min(82vw, 36vh, 340px);
  width: min(82vw, 36dvh, 340px);
  aspect-ratio: 1;
  margin: 0 auto;
  touch-action: none;
}

#trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

#trace-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-opacity: 0.45;
  stroke-width: 3.5;
}

.tile {
  position: absolute;
  width: var(--tile-size);
  height: var(--tile-size);
  padding: 0;
  transform: translate(-50%, -50%);
  border: 3px solid var(--accent);
  border-radius: 24%;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: calc(var(--tile-size) * 0.58);
  font-weight: 800;
  line-height: 1;
  touch-action: none;
  transition: left 180ms ease, top 180ms ease;
}

.tile.selected {
  background: var(--accent);
  color: #fff;
}

#actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

#actions button,
#next,
#other {
  min-height: 56px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: var(--card);
  color: var(--accent-dark);
  font: inherit;
  font-size: clamp(15px, 4.6vw, 20px);
  font-weight: 700;
}

#actions #check,
#next {
  background: var(--accent);
  color: #fff;
}

#actions button:disabled {
  opacity: 0.4;
}

#actions button:active:not(:disabled),
#next:active,
#other:active {
  transform: translateY(1px);
}

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

#done {
  padding: 4px 0 8px;
  text-align: center;
}

#done-title {
  margin: 0 0 6px;
  font-size: clamp(25px, 7vw, 30px);
  line-height: 1.15;
}

#done-detail {
  margin: 0 0 12px;
  font-size: clamp(18px, 5vw, 21px);
  line-height: 1.3;
}

#done-note {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: clamp(18px, 5vw, 21px);
  font-weight: 700;
}

#next,
#other {
  width: 100%;
}

#next {
  min-height: 64px;
  font-size: 24px;
}

#other {
  margin-top: 10px;
  font-size: clamp(18px, 5vw, 21px);
}

/* The orchard keeps one height and grows wider with each full tree, shrinking to
   fit if the row would be wider than the screen. */
#tree {
  height: clamp(84px, 19dvh, 170px);
  margin: 0 auto 10px;
}

#tree svg {
  display: block;
  width: auto;
  max-width: 100%;
  height: 100%;
  margin: 0 auto;
}

#tree .more-trees {
  fill: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

#tree .ground {
  fill: #c9b99a;
}

#tree .trunk {
  fill: #7a5230;
}

#tree .canopy {
  fill: #4f8a3c;
}

#tree .canopy-light {
  fill: #6aa553;
}

#tree .apple {
  fill: #c8302a;
  stroke: #7d1a16;
  stroke-width: 0.8;
}

#tree .apple.fresh {
  transform-box: fill-box;
  transform-origin: center;
  animation: arrive 700ms cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

@keyframes arrive {
  from {
    transform: translateY(-14px) scale(0.3);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    transition: none;
  }

  .cell.shown,
  .cell.hinted,
  #tree .apple.fresh {
    animation: none;
  }

  .tile {
    transition: none;
  }
}
