/* pegsolitaire.app
   Page shell + a DOM reproduction of the Monolume HUD. Every size, offset and
   letter-spacing in the .stage section comes from PegSolitaireScene.swift. */

:root {
  --font: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --page-bg: #0a0c0c;
  --page-raise: #101413;
  --page-fg: #f4f5f0;
  --page-secondary: #8d9590;
  --page-accent: #b8f34a;
  --page-line: rgba(255, 255, 255, 0.1);
  --shell: min(1120px, 100% - 2.5rem);
  --radius: 24px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--page-fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  font-weight: 700;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 3.9rem);
}

h2 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

h3 {
  font-size: 1.12rem;
}

p {
  margin: 0 0 1em;
}

.shell {
  width: var(--shell);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--page-accent);
  color: #0a0c0c;
  padding: 0.6rem 1rem;
  z-index: 99;
  border-radius: 0 0 10px 0;
}

.skip-link:focus {
  left: 0;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--page-secondary);
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}

.eyebrow::before {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--page-accent);
}

/* ------------------------------------------------------------------ header */

.site-header {
  border-bottom: 1px solid var(--page-line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 12, 12, 0.88);
  backdrop-filter: blur(14px);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  text-decoration: none;
  text-transform: uppercase;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.nav-links {
  display: flex;
  gap: 1.4rem;
  font-size: 0.86rem;
}

.nav-links a {
  color: var(--page-secondary);
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--page-fg);
}

/* -------------------------------------------------------------------- play */

.play {
  padding: 2.6rem 0 1rem;
  text-align: center;
}

.play h1 {
  margin-bottom: 0.35rem;
}

.play-lede {
  color: var(--page-secondary);
  max-width: 46ch;
  margin-inline: auto;
  font-size: 1.02rem;
}

.stage-wrap {
  margin: 1.8rem auto 0;
}

/* ------------------------------------------------------- the game itself */

.stage {
  --ui: 1;
  position: relative;
  width: 100%;
  /* Phone-shaped, so the board geometry ported from the app lands at the same
     proportions it has on an iPhone. The vh line is a fallback for browsers
     without svh, which would otherwise drop the cap entirely. */
  aspect-ratio: 44 / 95;
  max-height: min(78vh, 760px);
  max-height: min(78svh, 760px);
  /* The app's fixed bottom offsets (progress at 103px, controls at 21px) only
     clear the coach line on a board at least ~630px tall — every iPhone is.
     Below that the stage would fold in on itself, so it scrolls instead. */
  min-height: 640px;
  margin-inline: auto;
  border-radius: 30px;
  overflow: hidden;
  isolation: isolate;
  background: var(--bg-top, #0a0c0c);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  font-family: var(--font);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

@media (min-width: 820px) {
  .stage {
    aspect-ratio: 7 / 5;
    max-width: 1080px;
    max-height: 780px;
    /* The side-panel layout stacks its chrome beside the board, so it needs
       far less height than the portrait one. */
    min-height: 520px;
  }
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage-cells {
  position: absolute;
  inset: 0;
}

.cell {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cell[aria-disabled="true"] {
  cursor: default;
}

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

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--fg);
}

.hud > * {
  pointer-events: auto;
}

/* Every offset in the HUD scales with --ui alongside the type and controls it
   sits next to. Leaving any of them fixed lets the taller top-bar buttons grow
   into the stats panel on a wide stage. */
.hud-top {
  position: absolute;
  top: calc(10px * var(--ui));
  left: calc(15px * var(--ui));
  right: calc(15px * var(--ui));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hud-title {
  margin: 0;
  font-size: calc(16px * var(--ui));
  font-weight: 700;
  letter-spacing: calc(3.4px * var(--ui));
  text-indent: calc(3.4px * var(--ui));
}

.icon-button {
  width: calc(40px * var(--ui));
  height: calc(40px * var(--ui));
  border-radius: 50%;
  border: 1px solid var(--glass-stroke);
  background: var(--glass);
  color: var(--fg);
  font-size: calc(15px * var(--ui));
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.stats {
  position: absolute;
  top: calc(58px * var(--ui));
  left: calc(16px * var(--ui));
  right: calc(16px * var(--ui));
  height: calc(70px * var(--ui));
  border-radius: 22px;
  border: 1px solid var(--glass-stroke);
  background: var(--glass);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(2px * var(--ui));
  position: relative;
}

.stat + .stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: calc(36px * var(--ui));
  background: var(--glass-stroke);
}

.stat-caption {
  font-size: calc(8px * var(--ui));
  font-weight: 600;
  letter-spacing: calc(1.8px * var(--ui));
  text-indent: calc(1.8px * var(--ui));
  color: var(--secondary);
}

.stat strong {
  font-size: calc(25px * var(--ui));
  font-weight: 700;
  line-height: 1.05;
}

.stat:first-child strong {
  color: var(--accent);
}

.coach {
  position: absolute;
  top: var(--coach-y, 60%);
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  /* A status label that spans the stage must never sit between a finger and a
     control button. */
  pointer-events: none;
  font-size: calc(10px * var(--ui));
  font-weight: 600;
  letter-spacing: calc(1.7px * var(--ui));
  text-indent: calc(1.7px * var(--ui));
  color: var(--secondary);
}

.progress {
  position: absolute;
  bottom: calc(103px * var(--ui));
  left: calc(29px * var(--ui));
  right: calc(29px * var(--ui));
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: calc(8px * var(--ui));
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--secondary);
  margin-bottom: 5px;
}

.progress-track {
  height: 5px;
  border-radius: 2.5px;
  background: var(--track);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0.6%;
  border-radius: 2.5px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.controls {
  position: absolute;
  bottom: calc(21px * var(--ui));
  left: calc(20px * var(--ui));
  right: calc(20px * var(--ui));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.control {
  height: calc(62px * var(--ui));
  border-radius: 18px;
  border: 1px solid var(--glass-stroke);
  background: var(--glass);
  color: var(--fg);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(3px * var(--ui));
  padding: 0;
}

.control span:first-child {
  font-size: calc(22px * var(--ui));
  font-weight: 500;
  line-height: 1;
}

.control span:last-child {
  font-size: calc(8px * var(--ui));
  font-weight: 700;
  letter-spacing: calc(1.4px * var(--ui));
  text-indent: calc(1.4px * var(--ui));
}

.control.is-highlighted {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-top);
}

.control:disabled {
  opacity: 0.28;
  cursor: default;
}

/* Wide layout — mirrors usesWideLayout in the scene. */
.stage.is-wide .stats {
  left: auto;
  right: auto;
  width: min(36%, 420px);
  margin-left: 78%;
  transform: translateX(-50%);
}

/* The coach line belongs under the board, which sits at 32% in this layout —
   not centred on the stage. */
.stage.is-wide .coach {
  right: auto;
  width: 64%;
}

.stage.is-wide .progress {
  left: auto;
  right: auto;
  bottom: 50%;
  width: min(34%, 390px);
  margin-left: 78%;
  transform: translateX(-50%);
}

.stage.is-wide .controls {
  left: auto;
  right: auto;
  bottom: auto;
  top: calc(63% - 29px);
  width: min(36%, 420px);
  margin-left: 78%;
  transform: translateX(-50%);
  grid-template-columns: 1fr;
  gap: 14px;
}

.stage.is-wide .control {
  height: 58px;
  flex-direction: row;
  gap: 12px;
}

/* ---------------------------------------------------------------- dialogs */

dialog.sheet {
  width: min(430px, calc(100vw - 30px));
  border: 1px solid var(--glass-stroke, rgba(255, 255, 255, 0.11));
  border-radius: 30px;
  background: var(--panel, rgba(23, 26, 25, 0.98));
  color: var(--fg, #f4f5f0);
  padding: 28px 24px 24px;
  font-family: var(--font);
  text-align: center;
}

dialog.sheet::backdrop {
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(3px);
}

dialog.sheet h2 {
  font-size: 26px;
  letter-spacing: 1px;
  margin-bottom: 0.35em;
}

.sheet-eyebrow {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2.2px;
  color: var(--accent, #b8f34a);
  margin-bottom: 0.8rem;
}

.sheet-copy {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--secondary, #8d9590);
}

.steps-list {
  list-style: none;
  margin: 1.4rem 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  text-align: left;
}

.steps-list li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.9px;
  color: var(--secondary, #8d9590);
}

.steps-list b {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--accent, #b8f34a);
  color: var(--bg-top, #0a0c0c);
  display: grid;
  place-items: center;
  font-size: 9px;
}

.sheet-button {
  appearance: none;
  border: 1px solid var(--glass-stroke, rgba(255, 255, 255, 0.11));
  background: var(--glass, rgba(255, 255, 255, 0.055));
  color: var(--fg, #f4f5f0);
  border-radius: 15px;
  height: 46px;
  padding-inline: 22px;
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.3px;
  cursor: pointer;
}

.sheet-button.is-primary {
  background: var(--accent, #b8f34a);
  border-color: var(--accent, #b8f34a);
  color: var(--bg-top, #0a0c0c);
}

.sheet-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.sheet-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 1.2rem;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 1.3rem 0;
}

.theme-card {
  border-radius: 17px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.theme-card[aria-pressed="true"] {
  border-width: 2.5px;
}

.theme-orb {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: none;
}

.theme-card b {
  display: block;
  font-size: 11px;
  letter-spacing: 1.4px;
}

.theme-card small {
  font-size: 8px;
  letter-spacing: 0.4px;
  opacity: 0.75;
}

.theme-card.onyx {
  background: #151a18;
  color: #f4f5f0;
  border-color: #b8f34a;
}

.theme-card.onyx .theme-orb {
  background: radial-gradient(circle at 34% 30%, #d6ff83, #86c52b 48%, #31440f);
}

.theme-card.aurora {
  background: #15102c;
  color: #f4f5f0;
}

.theme-card.aurora .theme-orb {
  background: radial-gradient(circle at 34% 30%, #d8cfff, #8563e8 48%, #2a1b61);
}

.theme-card.ember {
  background: #29130d;
  color: #f4f5f0;
}

.theme-card.ember .theme-orb {
  background: radial-gradient(circle at 34% 30%, #ffb37e, #e34f1e 48%, #651805);
}

.theme-card.pearl {
  background: #d5d0c5;
  color: #17221d;
}

.theme-card.pearl .theme-orb {
  background: radial-gradient(circle at 34% 30%, #41725e, #174b38 48%, #09271c);
}

.theme-card[aria-pressed="true"].aurora {
  border-color: #9e7bff;
}

.theme-card[aria-pressed="true"].ember {
  border-color: #ff6b35;
}

.theme-card[aria-pressed="true"].pearl {
  border-color: #1f5a45;
}

.theme-card[aria-pressed="false"] {
  border-color: rgba(255, 255, 255, 0.1);
}

.result-mark {
  font-size: 40px;
  color: var(--accent, #b8f34a);
  line-height: 1;
}

/* ------------------------------------------------------------- store card */

.store-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  text-align: left;
  margin: 1.6rem auto 0;
  padding: 1.1rem 1.3rem;
  max-width: 580px;
  border: 1px solid var(--page-line);
  border-radius: 22px;
  background: var(--page-raise);
  text-decoration: none;
}

.store-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.store-card > img:not(.badge) {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  flex: none;
}

.store-card > span {
  flex: 1 1 190px;
}

.store-card b {
  display: block;
  font-size: 1rem;
}

.store-card span {
  font-size: 0.82rem;
  color: var(--page-secondary);
}

/* Apple's badge, unmodified. 148x44 keeps it above the minimum size with the
   10% clear space the guidelines ask for. */
.store-card .badge {
  margin-left: auto;
  flex: none;
  width: 148px;
  height: 44px;
  border-radius: 0;
}

/* Inside the result sheet the card is far narrower, so it stacks. */
dialog .store-card {
  flex-direction: column;
  text-align: center;
  gap: 0.75rem;
  padding: 1.2rem 1rem;
  margin-top: 1.4rem;
}

dialog .store-card .badge {
  margin-left: 0;
}

dialog .store-card > span {
  flex: none;
}

.store-note {
  text-align: center;
  color: var(--page-secondary);
  font-size: 0.78rem;
  margin-top: 0.9rem;
}

/* ----------------------------------------------------------------- prose */

.section {
  padding: 4rem 0;
  border-top: 1px solid var(--page-line);
  margin-top: 4rem;
}

.section:first-of-type {
  border-top: 0;
}

.prose {
  max-width: 68ch;
}

.prose h2 {
  margin-top: 2.4rem;
}

.prose h3 {
  margin-top: 1.8rem;
}

.prose ol,
.prose ul {
  padding-left: 1.2rem;
  color: var(--page-secondary);
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose strong {
  color: var(--page-fg);
}

.prose p {
  color: var(--page-secondary);
}

.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 2rem;
}

.card {
  border: 1px solid var(--page-line);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--page-raise);
}

.card p {
  color: var(--page-secondary);
  font-size: 0.94rem;
  margin: 0;
}

.faq-item {
  border-top: 1px solid var(--page-line);
  padding: 1.4rem 0;
}

.faq-item h3 {
  margin-bottom: 0.4rem;
}

.faq-item p {
  color: var(--page-secondary);
  margin: 0;
}

.notation {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.86rem;
}

.solution-table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.84rem;
}

.solution-scroll {
  overflow-x: auto;
  margin-top: 1.5rem;
}

.solution-table th,
.solution-table td {
  text-align: left;
  padding: 0.5rem 0.9rem 0.5rem 0;
  border-bottom: 1px solid var(--page-line);
  white-space: nowrap;
}

.solution-table th {
  color: var(--page-secondary);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.solution-table tbody tr {
  cursor: pointer;
  color: var(--page-secondary);
}

.solution-table tbody tr:hover {
  color: var(--page-fg);
}

.solution-table tbody tr.is-current {
  color: var(--page-accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- footer */

footer {
  border-top: 1px solid var(--page-line);
  margin-top: 4rem;
  padding: 2.6rem 0;
  color: var(--page-secondary);
  font-size: 0.85rem;
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
}

.footer-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-column h2 {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  color: var(--page-fg);
  margin: 0 0 0.3rem;
}

.footer-column a {
  color: var(--page-secondary);
  text-decoration: none;
}

.footer-column a:hover {
  color: var(--page-fg);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 2.4rem;
  font-size: 0.76rem;
}

.breadcrumb {
  font-size: 0.78rem;
  color: var(--page-secondary);
  padding-top: 1.6rem;
}

.breadcrumb a {
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .progress-fill {
    transition: none;
  }
}
