/**
 * Headlines — Wordle-clue headline unscramble.
 *
 * Everything is scoped under `.game-headlines`.
 */

.game-headlines {
  --ink: #16150f;
  --paper: #ffffff;
  --muted: #6b6b66;
  --slot: #e7e2d6;
  --slot-border: #d5d0c2;
  --accent: #8040a0;
  /* Official Wordle tile colours */
  --green: #6aaa64;
  --orange: #c9b458;
  --grey: #787c7e;
  --green-ink: #ffffff;
  --orange-ink: #ffffff;
  --grey-ink: #ffffff;
  --tile-h: 42px;
  --slots-gap: 6px;
}

.game-headlines * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Baloo 2", system-ui, sans-serif;
}

.game-headlines [hidden] {
  display: none !important;
}

html:has(.game-headlines) {
  height: auto;
  min-height: 100%;
  color: var(--pd-colour-text, #16150f);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body:has(.game-headlines) {
  position: relative !important;
  width: 100% !important;
  height: auto !important;
  min-height: 100dvh !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  background: transparent !important;
  touch-action: manipulation;
}

body:has(.game-headlines) .pd-game-root {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.game-headlines {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.game-headlines .hsf-content {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 1403px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--paper);
  line-height: normal;
}

.game-headlines .hsf-shell {
  width: 100%;
  max-width: 640px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 20px max(12px, env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  html:has(.game-headlines),
  body:has(.game-headlines) {
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .game-headlines .hsf-shell {
    max-width: none;
    padding-left: 16px;
    padding-right: 16px;
  }

  .game-headlines .hsf-content,
  .game-headlines .hsf-shell {
    min-height: 0 !important;
  }

  html:has(.game-headlines.is-done),
  body:has(.game-headlines.is-done) {
    height: auto !important;
    max-height: none !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .game-headlines.is-done .hsf-content,
  .game-headlines.is-done .hsf-shell,
  .game-headlines.is-done .pd-play-area {
    min-height: auto !important;
    height: auto !important;
    overflow: visible !important;
  }
}

/* --- Chrome ------------------------------------------------------------- */

.game-headlines .help-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  transition: color 0.15s ease;
}

.game-headlines .help-btn:hover {
  color: var(--accent);
}

.game-headlines .help-btn svg {
  width: 30px;
  height: 30px;
  display: block;
}

/* --- Play --------------------------------------------------------------- */

.game-headlines .hsf-play {
  --hsf-meta-gap: 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
  box-sizing: border-box;
}

body.pd-game:not(.pd-welcome):not(.pd-done):not(:has(.is-done)) .pd-game-root.game-headlines,
body.pd-game:not(.pd-welcome):not(.pd-done):not(:has(.is-done)) .game-headlines .hsf-content,
body.pd-game:not(.pd-welcome):not(.pd-done):not(:has(.is-done)) .game-headlines .hsf-shell,
body.pd-game:not(.pd-welcome):not(.pd-done):not(:has(.is-done)) .game-headlines .pd-play-area {
  overflow: visible !important;
}

body.pd-game:not(.pd-welcome):not(.pd-done):not(:has(.is-done)) .game-headlines .pd-play-area {
  justify-content: center !important;
  align-items: stretch !important;
  padding-bottom: 80px;
}

body.pd-game:not(.pd-welcome):not(.pd-done):not(:has(.is-done)) .game-headlines .hsf-play {
  flex: 0 1 auto !important;
  overflow: visible !important;
  max-height: none;
}

.game-headlines .hsf-status {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-top: var(--hsf-meta-gap);
  padding-top: 0;
}

.game-headlines .hsf-masthead {
  display: flex;
  justify-content: center;
  margin: 0 0 var(--hsf-meta-gap);
  text-align: center;
}

.game-headlines .hsf-masthead[hidden] {
  display: none !important;
}

.game-headlines .hsf-masthead-title {
  margin: 0;
  font-family: var(--pd-font-ui);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--muted);
}

/* --- Tutorial ----------------------------------------------------------- */

.game-headlines .tut-text { display: none; }

body:has(.game-headlines.is-tutorial) #pd-chrome-tools { display: none; }

.game-headlines.is-tutorial .hsf-status,
.game-headlines.is-tutorial .hsf-masthead { display: none !important; }

/* Reserve two lines so step copy changes don't shift the board. */
.game-headlines.is-tutorial #tutTextSlot {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: calc(2 * 1.55 * clamp(18px, 5vw, 24px) + 10px);
  margin: 0 auto 4px;
}

.game-headlines.is-tutorial .tut-text,
.game-headlines.is-tutorial .tut-text * {
  font-family: var(--pd-font-ui);
}

.game-headlines.is-tutorial .tut-text {
  display: block;
  width: 100%;
  text-align: center;
  margin: 0;
  font-weight: 800;
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.55;
  color: var(--ink);
}

.game-headlines.is-tutorial .tut-text b {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.game-headlines.is-tutorial .tut-text .tut-l1 {
  display: block;
  margin-bottom: 12px;
}

.game-headlines.is-tutorial .tut-text .tut-l2 {
  display: inline-block;
  margin-top: 10px;
}

.game-headlines.is-tutorial .tut-text .hsf-swatch {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.2em;
  margin-left: 0.15em;
  border-radius: 4px;
  vertical-align: -0.1em;
}

.game-headlines.is-tutorial .tut-text .hsf-swatch:first-child {
  margin-left: 0;
}

.game-headlines.is-tutorial .tut-text .hsf-swatch-green { background: var(--green); }
.game-headlines.is-tutorial .tut-text .hsf-swatch-orange { background: var(--orange); }
.game-headlines.is-tutorial .tut-text .hsf-swatch-grey { background: var(--grey); }

@keyframes headlines-tutTextOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.82); }
}

@keyframes headlines-tutTextIn {
  from { opacity: 0; transform: scale(0.82); }
  to { opacity: 1; transform: scale(1); }
}

.game-headlines.is-tutorial .tut-text.tut-anim-out {
  animation: headlines-tutTextOut 0.18s ease forwards;
}

.game-headlines.is-tutorial .tut-text.tut-anim-in {
  animation: headlines-tutTextIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.game-headlines .tut-skip {
  display: none;
  width: auto !important;
  margin: 18px auto 0;
  padding: 10px 22px !important;
  font-family: var(--pd-font-ui) !important;
  font-size: 16px !important;
  font-weight: 700;
  line-height: 1.2;
  border-radius: 999px;
  border: 2px solid transparent;
  background: #f0efe9;
  color: var(--ink);
  cursor: pointer;
}

.game-headlines.is-tutorial .tut-skip:not([hidden]) {
  display: block;
}

.game-headlines .tut-skip:hover {
  background: #e6e4db;
}

.game-headlines .tut-skip.tut-skip-play {
  background: #1a1a1a !important;
  border-color: #1a1a1a !important;
  color: #fff !important;
}

.game-headlines.is-tutorial .hsf-tile.tut-locked {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

html[data-theme="dark"] .game-headlines .tut-skip {
  border-color: var(--ink);
  background: var(--pd-colour-surface, #1c1c19);
  color: var(--ink);
}

html[data-theme="dark"] .game-headlines .tut-skip:hover {
  background: #2a2a26;
}

html[data-theme="dark"] .game-headlines .tut-skip.tut-skip-play {
  background: var(--ink) !important;
  border-color: var(--ink) !important;
  color: var(--paper, #141412) !important;
}

.game-headlines .hsf-swaps {
  font-family: var(--pd-font-ui);
  font-size: 22px;
  font-weight: 700;
  color: var(--muted);
}

.game-headlines .hsf-board {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.game-headlines .hsf-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px 0;
  box-sizing: border-box;
  overflow: visible;
}

.game-headlines .hsf-row + .hsf-row {
  border-top: 1px solid var(--slot-border);
}

.game-headlines .hsf-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--green);
  color: var(--green-ink);
  box-sizing: border-box;
  text-align: left;
}

.game-headlines .hsf-card.is-entering {
  opacity: 0;
  transform: scale(0.92) translateY(10px);
}

.game-headlines .hsf-card.is-entering.is-in {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.game-headlines .hsf-card-title {
  margin: 0;
  font-family: var(--pd-font-ui);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  text-wrap: balance;
}

.game-headlines.is-tutorial .hsf-card.is-tut-card {
  gap: 0;
  min-height: var(--tile-h);
  padding: 10px 16px;
  justify-content: center;
}

.game-headlines.is-tutorial .hsf-card.is-tut-card.is-entering {
  transform: none;
}

.game-headlines.is-tutorial .hsf-card.is-tut-card .hsf-card-title {
  text-wrap: unset;
  white-space: nowrap;
}

.game-headlines .hsf-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.game-headlines .hsf-card-source {
  font-family: var(--pd-font-ui);
  font-size: 13px;
  font-weight: 700;
  opacity: 0.88;
}

.game-headlines .hsf-card-link {
  font-family: var(--pd-font-ui);
  font-size: 13px;
  font-weight: 800;
  color: var(--green-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.game-headlines .hsf-card-link:hover {
  opacity: 0.85;
}

.game-headlines .hsf-slots {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: var(--slots-gap);
  width: 100%;
  height: auto;
  min-height: var(--tile-h);
  overflow: visible;
  /* Room for edge tiles to jiggle/celebrate without clipping. */
  padding: 4px 6px;
  margin: -4px -6px;
  box-sizing: border-box;
}

.game-headlines .hsf-slot {
  flex: 0 0 auto;
  max-width: 100%;
  border-radius: 8px;
  background: transparent;
  height: auto;
  min-height: var(--tile-h);
  overflow: visible;
}

.game-headlines .hsf-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  height: var(--tile-h);
  min-height: var(--tile-h);
  padding: 7px 11px;
  border: none;
  border-radius: 7px;
  background: var(--grey);
  color: var(--grey-ink);
  cursor: pointer;
  touch-action: manipulation;
  overflow: hidden;
  transform: translateZ(0);
  transform-origin: center center;
  backface-visibility: hidden;
  transition:
    background 0.12s ease,
    color 0.12s ease;
  box-sizing: border-box;
}

.game-headlines .hsf-tile-label {
  position: relative;
  z-index: 1;
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.game-headlines .hsf-tile.is-green {
  background: var(--green);
  color: var(--green-ink);
  cursor: default;
}

.game-headlines .hsf-tile.is-orange {
  background: var(--orange);
  color: var(--orange-ink);
}

.game-headlines .hsf-tile.is-grey {
  background: var(--grey);
  color: var(--grey-ink);
}

.game-headlines .hsf-tile.is-locked {
  cursor: default;
}

.game-headlines .hsf-tile.is-selected {
  z-index: 3;
  overflow: visible;
  /* iOS homescreen-style jiggle while waiting for the swap partner. */
  animation: headlines-tile-jiggle 0.18s ease-in-out infinite alternate;
}

@keyframes headlines-tile-jiggle {
  from { transform: rotate(-2deg) scale(1.04); }
  to { transform: rotate(2deg) scale(1.04); }
}

.game-headlines .hsf-tile.is-celebrate {
  animation: headlines-tile-celebrate 0.52s cubic-bezier(0.22, 1, 0.36, 1) both;
  z-index: 2;
}

@keyframes headlines-tile-celebrate {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-10px) scale(1.06); }
  60% { transform: translateY(2px) scale(0.98); }
  100% { transform: translateY(0) scale(1); }
}

.game-headlines .hsf-tile.is-color-sheen {
  transition: background 0.28s ease, color 0.28s ease;
}

.game-headlines .hsf-tile:focus,
.game-headlines .hsf-tile:focus-visible {
  outline: none;
}

.game-headlines .hsf-tile:disabled:not(.is-locked) {
  cursor: default;
}

.game-headlines.is-paused #hsfPlay {
  visibility: hidden;
}

.game-headlines.is-done,
.game-headlines.is-done .hsf-content,
.game-headlines.is-done .hsf-shell,
.game-headlines.is-done .pd-play-area {
  flex: none !important;
  min-height: auto !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

.game-headlines.is-done .hsf-play {
  flex: none;
  min-height: 0;
}

.game-headlines.is-done .hsf-status {
  display: none !important;
}

.game-headlines.is-done .hsf-tile {
  cursor: default;
}

.game-headlines #hsfComplete.pd-complete-panel {
  margin-top: 8px;
  padding-left: 8px;
  padding-right: 8px;
}

.game-headlines .hsf-c-stars {
  margin: 0 0 16px;
  font-size: 20px;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--orange);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.game-headlines .hsf-c-sources {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 0;
}

.game-headlines .hsf-c-source {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(22, 21, 15, 0.04);
  box-shadow: inset 4px 0 0 var(--green);
}

.game-headlines .hsf-c-source-label {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
}

.game-headlines .hsf-c-source-meta {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.game-headlines .hsf-c-source-link {
  margin-top: 4px;
  align-self: flex-start;
  font-size: 14px;
  font-weight: 800;
  color: #2e9e5b;
  text-decoration: none;
}

.game-headlines .hsf-c-source-link:hover {
  text-decoration: underline;
}

@media (max-width: 520px) {
  .game-headlines {
    --tile-h: 40px;
    --slots-gap: 5px;
  }

  .game-headlines .hsf-row {
    padding: 20px 0;
  }

  .game-headlines .hsf-tile {
    padding: 6px 10px;
  }

  .game-headlines .hsf-tile-label {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-headlines .hsf-tile {
    transition: none;
  }

  .game-headlines .hsf-tile.is-selected {
    animation: none;
    transform: scale(1.04);
  }

  .game-headlines .hsf-tile.is-celebrate {
    animation: none;
    transform: none;
  }

  .game-headlines .hsf-tile.is-color-sheen {
    transition: none;
  }

  .game-headlines .hsf-card.is-entering {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

html[data-theme="dark"] .game-headlines {
  --ink: #dddace;
  --paper: #141412;
  --muted: #9a9a92;
  --slot: #2a2a26;
  --slot-border: #3a3a35;
  --accent: #b57ad4;
  /* Wordle night-mode tile colours */
  --green: #538d4e;
  --orange: #b59f3b;
  --grey: #3a3a3c;
  --green-ink: #ffffff;
  --orange-ink: #ffffff;
  --grey-ink: #ffffff;
}

html[data-theme="dark"] .game-headlines .hsf-content {
  background: var(--pd-colour-background, #141412);
}

html[data-theme="dark"] .game-headlines .hsf-c-source {
  background: rgba(240, 239, 232, 0.06);
}

