/* Reusable blocks shared across pages. */

/* Button: a hand-drawn sticker with a hard shadow. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-size);
  padding: 0 var(--space-5);
  border: var(--line);
  border-radius: var(--radius-wobble);
  background: var(--color-white);
  box-shadow: var(--shadow-hard);
  font-family: var(--font-hand);
  font-size: var(--hand-md);
  font-weight: 700;
  line-height: 1;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.button:active {
  transform: translate(2px, 3px);
  box-shadow: 0 0 0 var(--color-ink);
}

.button--primary {
  background: var(--color-pink);
}

.button--sunny {
  background: var(--color-butter);
}

.button--large {
  min-height: 56px;
  font-size: 1.75rem;
  box-shadow: 3px 4px 0 var(--color-ink);
}

.button--block {
  width: 100%;
}

/* Text button: a link-like action with a wavy underline. */
.text-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-size);
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-hand);
  font-size: 1.3rem;
  text-decoration: underline wavy var(--color-pink-marker);
  text-underline-offset: 5px;
}

.text-button--accent {
  font-weight: 700;
  color: var(--color-pink-text);
  text-decoration: none;
}

.text-button--danger {
  color: var(--color-pink-text);
  text-decoration-color: currentColor;
}

.text-button--quiet {
  color: var(--color-ink-soft);
  text-decoration: none;
}

/* Icon button: round arrow buttons for paging days and months. */
.icon-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--tap-size);
  height: var(--tap-size);
  border: var(--line-thin);
  border-radius: 50%;
  background: var(--color-white);
}

.icon-button--disabled {
  border-style: dashed;
  border-color: #cdb8b8;
  background: transparent;
  color: var(--color-ink-faint);
  cursor: default;
}

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Avatar: a player's icon in an inked circle. */
.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border: var(--line);
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-white);
}

.avatar--you {
  background: var(--color-pink-light);
}

.avatar--opponent {
  background: var(--color-brown-light);
}

/* A player's profile colour, added after avatar--you / avatar--opponent so it wins. */
.avatar--pink { background: var(--tag-pink); }
.avatar--butter { background: var(--tag-butter); }
.avatar--mint { background: var(--tag-mint); }
.avatar--sky { background: var(--tag-sky); }
.avatar--lilac { background: var(--tag-lilac); }
.avatar--toffee { background: var(--tag-toffee); }

.avatar--small {
  width: 32px;
  height: 32px;
  border: var(--line-thin);
}

.avatar--large {
  width: 92px;
  height: 92px;
  border-width: 3px;
}

/* Game tag: the little sticker in front of a game's name. */
.game-tag {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border: var(--line-thin);
  border-radius: 10px;
  background: var(--tag-pink);
  font-family: var(--font-hand);
  font-size: 1.25rem;
  font-weight: 700;
}

.game-tag--large {
  width: 54px;
  height: 54px;
  border: var(--line);
  border-radius: 14px;
  font-size: 1.9rem;
  transform: rotate(-6deg);
}

.game-tag--pink { background: var(--tag-pink); }
.game-tag--butter { background: var(--tag-butter); }
.game-tag--mint { background: var(--tag-mint); }
.game-tag--sky { background: var(--tag-sky); }
.game-tag--lilac { background: var(--tag-lilac); }
.game-tag--toffee { background: var(--tag-toffee); }

.game-tag__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.game-tag__image--pixel {
  width: auto;
  height: 72%;
  image-rendering: pixelated;
}

/* Tape: a strip of washi tape stuck over a card's edge. */
.tape {
  position: absolute;
  width: 76px;
  height: 22px;
  background: repeating-linear-gradient(45deg, rgb(249 201 214 / 0.9) 0 6px, rgb(255 238 243 / 0.9) 6px 12px);
}

.tape--butter {
  background: repeating-linear-gradient(-45deg, rgb(255 229 138 / 0.9) 0 6px, rgb(255 244 205 / 0.9) 6px 12px);
}

/* Paper card: a white sheet with an inked edge and a pink offset shadow. */
.paper-card {
  position: relative;
  border: var(--line);
  border-radius: var(--radius-card);
  background: var(--color-white);
  box-shadow: var(--shadow-pink);
}

/* Highlight: a marker swipe behind a few words. */
.highlight {
  position: relative;
  z-index: 0;
  display: inline-block;
}

.highlight::after {
  content: '';
  position: absolute;
  z-index: -1;
  right: -6px;
  bottom: 0.12em;
  left: -6px;
  height: 0.3em;
  border-radius: 6px;
  background: var(--color-butter);
  transform: rotate(-1.5deg);
}

.marker {
  padding: 0 6px;
  border-radius: 4px;
  background: var(--color-butter);
}

/* Field: a label over an underlined, handwritten input. */
.field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.field__label {
  font-family: var(--font-hand);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-ink-soft);
}

.field__input {
  width: 100%;
  height: var(--tap-size);
  padding: 0 2px;
  border: 0;
  border-bottom: var(--line);
  border-radius: 0;
  background: transparent;
  font-family: var(--font-hand);
  font-size: 1.75rem;
  font-weight: 700;
}

.field__input:focus {
  outline: none;
  border-bottom-color: var(--color-pink-marker);
}

.field__input::placeholder {
  color: var(--color-ink-faint);
  font-weight: 400;
}

.field__error {
  margin-top: 4px;
  font-size: var(--text-sm);
  color: var(--color-pink-text);
}

/* Page header: a title with an optional line under it, flanked by arrows. */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.page-header__text {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page-header__title {
  font-family: var(--font-hand);
  font-size: var(--hand-xl);
  font-weight: 700;
  line-height: 0.95;
}

.page-header__title--left {
  align-self: flex-start;
}

.page-header__subtitle {
  margin-top: var(--space-1);
  font-family: var(--font-hand);
  font-size: 1.2rem;
  color: var(--color-ink-soft);
}

.page-header__subtitle--tag {
  padding: 0 10px;
  border-radius: 4px;
  background: var(--color-butter);
  color: var(--color-ink);
  transform: rotate(-2deg);
}

/* Top bar: back link on the left, main action on the right. */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-bar__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap-size);
  font-family: var(--font-hand);
  font-size: var(--hand-md);
  font-weight: 700;
}

/* Switch: an on/off checkbox drawn as an inked pill with a sliding knob. */
.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  margin: 0;
  border: var(--line-thin);
  border-radius: 999px;
  background: var(--color-white);
  box-shadow: var(--shadow-hard);
  appearance: none;
  cursor: pointer;
  transition: background 0.15s;
}

.switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border: var(--line-thin);
  border-radius: 50%;
  background: var(--color-butter);
  transition: transform 0.15s;
}

.switch:checked {
  background: var(--color-pink);
}

.switch:checked::before {
  transform: translateX(20px);
}

.switch:focus-visible {
  outline: 2px solid var(--color-pink-marker);
  outline-offset: 3px;
}

.switch:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Section heading: a handwritten title with an optional aside. */
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 30px;
}

.section-heading__title {
  font-family: var(--font-hand);
  font-size: var(--hand-lg);
  font-weight: 700;
}

.section-heading__aside {
  font-family: var(--font-hand);
  font-size: 1.05rem;
  color: var(--color-ink-soft);
}

/* Subheading: a smaller handwritten heading, also used as a fieldset legend. */
.subheading {
  margin-top: 28px;
  padding: 0;
  font-family: var(--font-hand);
  font-size: 1.75rem;
  font-weight: 700;
}

/* Speech bubble: a note with a tail, used for status lines. */
.speech-bubble {
  position: relative;
  padding: 10px 14px;
  border: var(--line-thin);
  border-radius: 18px 16px 18px 6px;
  background: var(--color-white);
}

.speech-bubble--tail-top {
  border-width: 2.5px;
  border-radius: 22px 18px 24px 16px / 18px 24px 16px 22px;
}

.speech-bubble--tail-top::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 56px;
  width: 18px;
  height: 18px;
  border-top: var(--line);
  border-left: var(--line);
  background: var(--color-white);
  transform: rotate(45deg);
}

/* Tail under the right-hand player, for when the opponent has the day. */
.speech-bubble--tail-right::before {
  right: 56px;
  left: auto;
}

.loss-illustration {
  flex: none;
  width: 4.5rem;
  height: auto;
  border-radius: var(--radius-card);
}

/* Scribble: a pen circle drawn around a winning score. */
.scribble {
  position: absolute;
  top: -9px;
  left: -10px;
  width: calc(100% + 20px);
  height: calc(100% + 16px);
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: none;
}

.scribble--you {
  stroke: var(--color-pink-marker);
}

.scribble--opponent {
  stroke: var(--color-brown-marker);
}

/* Choice pills: radio buttons drawn as stickers. */
.choice-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: var(--space-3) 0 0;
  padding: 0;
  border: 0;
}

.choice-pills__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-pills__label {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 var(--space-4);
  border: 2px dashed var(--color-ink-faint);
  border-radius: var(--radius-wobble);
  background: var(--color-white);
  font-family: var(--font-hand);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
}

.choice-pills__input:checked + .choice-pills__label {
  border: var(--line);
  background: var(--color-pink);
  box-shadow: var(--shadow-hard);
}

.choice-pills__input:focus-visible + .choice-pills__label {
  outline: 3px solid var(--color-pink-marker);
  outline-offset: 2px;
}

/* Check list: radio options with a hand-drawn box and tick. */
.check-list {
  display: flex;
  flex-direction: column;
  margin: var(--space-1) 0 0;
  padding: 0;
  border: 0;
}

.check-list__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-list__option {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  cursor: pointer;
}

.check-list__box {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: var(--line);
  border-radius: 6px 8px 5px 7px;
  background: var(--color-white);
}

.check-list__tick {
  width: 26px;
  height: 26px;
  margin: -6px -4px 0 0;
  fill: none;
  stroke: var(--color-pink-text);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  visibility: hidden;
}

.check-list__input:checked + .check-list__option .check-list__box {
  background: var(--color-pink-light);
}

.check-list__input:checked + .check-list__option .check-list__tick {
  visibility: visible;
}

.check-list__input:focus-visible + .check-list__option .check-list__box {
  outline: 3px solid var(--color-pink-marker);
  outline-offset: 2px;
}

.check-list__text {
  display: flex;
  flex-direction: column;
}

.check-list__label {
  font-family: var(--font-hand);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.05;
}

.check-list__hint {
  font-size: var(--text-xs);
  color: var(--color-ink-soft);
}

/* Swatches: colour picker radios. */
.swatches {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding: 0;
  border: 0;
}

.swatches--start {
  justify-content: flex-start;
}

.swatches__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatches__swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-size);
  height: var(--tap-size);
  border: var(--line-thin);
  border-radius: 50%;
  cursor: pointer;
}

.swatches__swatch--pink { background: var(--color-pink); }
.swatches__swatch--butter { background: var(--color-butter); }
.swatches__swatch--mint { background: #cdebd9; }
.swatches__swatch--sky { background: #cfe4f7; }
.swatches__swatch--lilac { background: #e1d3f5; }
.swatches__swatch--toffee { background: var(--tag-toffee); }

.swatches__tick {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--color-ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  visibility: hidden;
}

.swatches__input:checked + .swatches__swatch {
  border-width: 3px;
  box-shadow: 2px 2px 0 var(--color-ink);
}

.swatches__input:checked + .swatches__swatch .swatches__tick {
  visibility: visible;
}

.swatches__input:focus-visible + .swatches__swatch {
  outline: 3px solid var(--color-pink-marker);
  outline-offset: 2px;
}

/* Tab bar: the three main sections, pinned to the bottom of the screen. */
.tab-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 10px var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  border-top: var(--line);
  background: var(--color-white);
}

.tab-bar__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  font-family: var(--font-hand);
  font-size: var(--hand-sm);
  color: var(--color-ink-soft);
}

.tab-bar__icon {
  display: flex;
  padding: 2px 14px;
  border: 2px solid transparent;
  border-radius: 16px 12px 16px 12px;
}

.tab-bar__link--active {
  font-weight: 700;
  color: var(--color-ink);
}

.tab-bar__link--active .tab-bar__icon {
  border-color: var(--color-ink);
  background: var(--color-pink);
}
