/* The Art of the Box, v09: Weather Test */
:root {
  --sky: #2a2f36;
  --sky-low: #3a414b;
  --night: #1b1f25;
  --mist: #c9ced6;
  --paper: #f3ecdc;
  --board: #d5a274;
  --blue: #345463;
  --lamp: #fdd07e;
  --serif: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --hand: "Kalam", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }

html { background: var(--night); }

body {
  margin: 0;
  background: var(--night);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.45;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

/* Stage: one screen of weather */
.stage {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 620px;
  overflow: hidden;
  background: linear-gradient(180deg, #262b32 0%, var(--sky) 38%, var(--sky-low) 78%, #2b3038 100%);
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#weather {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Header */
.top {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
}

.home {
  color: var(--paper);
  text-decoration: none;
  font-size: 17px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 6px 2px;
  border-bottom: 1px solid rgba(243, 236, 220, 0.35);
}
.home:hover { border-bottom-color: var(--paper); }

.title {
  margin: 0;
  font-weight: 400;
  font-style: italic;
  font-size: 20px;
  letter-spacing: 0.04em;
  color: var(--mist);
  text-align: center;
}

.sound {
  font: inherit;
  font-family: var(--hand);
  font-size: 16px;
  color: var(--mist);
  background: transparent;
  border: 1px solid rgba(201, 206, 214, 0.4);
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
}
.sound[aria-pressed="true"] {
  color: var(--night);
  background: var(--lamp);
  border-color: var(--lamp);
}

/* Controls */
.deck {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 28px 24px;
  pointer-events: none;
}
.deck > * { pointer-events: auto; }

.deck-read { min-width: 0; }

.leaf-name {
  margin: 0;
  font-family: var(--hand);
  font-size: 24px;
  line-height: 1.1;
  color: var(--paper);
}

.hint {
  margin: 4px 0 0;
  font-family: var(--hand);
  font-size: 16px;
  color: var(--mist);
  opacity: 0.85;
}

.deck-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.deck-buttons button {
  font: inherit;
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: rgba(27, 31, 37, 0.55);
  border: 1px solid rgba(243, 236, 220, 0.38);
  border-radius: 3px;
  min-height: 44px;
  padding: 8px 18px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.deck-buttons button:hover:not(.off) { border-color: var(--paper); }
.deck-buttons button.off { opacity: 0.35; cursor: default; }
#turn { background: var(--paper); color: var(--night); border-color: var(--paper); }
#turn.off { background: rgba(27, 31, 37, 0.55); color: var(--paper); }
#rain[aria-pressed="true"] { background: var(--blue); border-color: var(--mist); }

/* The tag that carries the buy block */
.tag {
  position: absolute;
  z-index: 3;
  left: 0;
  top: 0;
  width: 212px;
  transform-origin: 50% 17px;
  will-change: transform;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35));
}
.tag[hidden] { display: none; }
.tag-card {
  padding: 40px 18px 18px;
  color: #2a2118;
  text-align: center;
  background:
    radial-gradient(circle at 50% 17px, transparent 0 6px, #b98d5c 6.5px 10px, transparent 10.5px),
    linear-gradient(170deg, #efe2c4, #e2cfa8);
  clip-path: polygon(22% 0, 78% 0, 100% 13%, 100% 100%, 0 100%, 0 13%);
  -webkit-mask: radial-gradient(circle at 50% 17px, transparent 6px, #000 6.5px);
  mask: radial-gradient(circle at 50% 17px, transparent 6px, #000 6.5px);
}

.tag-price {
  margin: 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.05;
}
.tag-edition {
  margin: 2px 0 12px;
  font-size: 16px;
  font-style: italic;
}
.tag-buy {
  font: inherit;
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--paper);
  background: var(--blue);
  border: 0;
  border-radius: 2px;
  min-height: 44px;
  width: 100%;
  padding: 8px 10px;
  cursor: pointer;
}
.tag-buy:hover { background: #2a4552; }
.tag-done {
  margin: 8px 0 0;
  min-height: 1.3em;
  font-family: var(--hand);
  font-size: 18px;
  color: #3b2a14;
}

/* Text for screen readers, and the flat fallback when canvas is missing */
.sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.book-text.flat {
  max-width: 34em;
  margin: 0 auto;
  padding: 48px 20px;
  color: var(--paper);
}
.book-text.flat img { width: 100%; height: auto; display: block; }
.book-text.flat h2 { font-weight: 400; font-size: 28px; margin: 1.4em 0 0.3em; }
.book-text figure { margin: 0 0 1.5em; }

/* Footer */
.end {
  background: var(--night);
  padding: 56px 28px 64px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.end-line {
  margin: 0;
  font-family: var(--hand);
  font-size: 20px;
  color: var(--mist);
}
.next {
  color: var(--paper);
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.next-label {
  font-size: 15px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mist);
}
.next-title {
  font-size: clamp(30px, 4.4vw, 54px);
  line-height: 1.05;
  font-style: italic;
  border-bottom: 1px solid rgba(243, 236, 220, 0.3);
}
.next:hover .next-title { border-bottom-color: var(--paper); }

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

/* Phone */
@media (max-width: 699px) {
  .top {
    flex-wrap: wrap;
    padding: 12px 16px 0;
    row-gap: 4px;
  }
  .home { font-size: 16px; }
  .title {
    order: 3;
    width: 100%;
    font-size: 17px;
  }
  .sound { font-size: 16px; padding: 5px 14px; }

  .deck {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 16px 18px;
  }
  .deck-read { display: block; }
  .leaf-name { font-size: 21px; }
  .hint { margin: 2px 0 0; font-size: 16px; }
  .deck-buttons { flex-wrap: nowrap; gap: 8px; }
  .deck-buttons button { flex: 1 1 0; padding: 8px 6px; font-size: 16px; letter-spacing: 0.02em; }

  .tag { width: 164px; }
  .tag-card { padding: 38px 12px 14px; }
  .tag-price { font-size: 28px; }
  .tag-edition { font-size: 15px; margin-bottom: 10px; }
  .tag-buy { font-size: 16px; }

  .end { padding: 44px 16px 52px; flex-direction: column; align-items: flex-start; }
  .next { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .deck-buttons button { transition: none; }
}
