/* Pieceling Tiles - try-it page (demo.pieceling.com)
   Look A, "Gallery": Cream ground, flat black frame, wide white mount, museum wall label.
   Tokens match web/css/site.css. Grout lines are the mount colour and never go away. */

@font-face {
  font-family: 'Source Serif 4'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(/fonts/source-serif-4-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Serif 4'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(/fonts/source-serif-4-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Source Serif 4'; font-style: italic; font-weight: 400; font-display: swap;
  src: url(/fonts/source-serif-4-italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F;
}

:root {
  --ground: #F0EBDE;
  --text: #1C1C1E;
  --muted: #5E5C58;
  --hairline: rgba(28,28,30,0.12);
  --outline: rgba(28,28,30,0.30);
  --label-rule: rgba(28,28,30,0.45);
  --button-fill: #1C1C1F;
  --button-text: #F0EBDE;
  --frame: #1C1C1E;
  --mount: #FBFAF7;
  --frame-shadow: 0 2px 6px rgba(28,28,30,0.12), 0 16px 40px rgba(28,28,30,0.20);
  --serif: 'Source Serif 4', 'New York', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --frame-w: 14px;
  --mount-w: 40px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font-family: var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, p { margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: fixed; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.page {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; gap: 20px;
  padding: max(20px, env(safe-area-inset-top)) max(40px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(40px, env(safe-area-inset-left));
  max-width: 1400px; margin: 0 auto;
}

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 20px; }
.logo { font-size: 30px; line-height: 1; text-decoration: none; color: inherit; display: block; }
.logo .stack { display: inline-flex; flex-direction: column; align-items: stretch; gap: 0.16em; }
.logo .word { font-family: var(--serif); font-weight: 600; line-height: 1; letter-spacing: -0.012em; white-space: nowrap; display: inline-block; }
.logo .dot { position: relative; display: inline-block; }
.logo .dot svg { position: absolute; left: 50%; top: 0.12em; width: 0.17em; height: 0.17em; transform: translateX(-44%); overflow: visible; }
.logo .rule { display: block; height: 1px; background: currentColor; opacity: 0.35; }
.logo .row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.2em; font-family: var(--serif); line-height: 1.2; white-space: nowrap; }
.logo .puzzles { font-size: 0.2em; font-weight: 600; letter-spacing: 0.42em; }
.logo .made { font-size: 0.13em; font-style: italic; letter-spacing: 0.02em; }
.mode { display: flex; align-items: baseline; gap: 10px; padding-left: 20px; border-left: 1px solid var(--hairline); align-self: stretch; align-items: center; }
.mode-name { font-family: var(--serif); font-weight: 600; font-size: 24px; }
.mode-try { font-size: 15px; font-weight: 500; color: var(--muted); }
.get { margin-left: auto; font-size: 15px; font-weight: 500; text-decoration: underline; text-decoration-color: var(--outline); text-underline-offset: 4px; }
.get:hover { text-decoration-color: currentColor; }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.seg { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--hairline); border-radius: 999px; }
.seg button {
  height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent;
  font-size: 15px; font-weight: 500; cursor: pointer; touch-action: manipulation; white-space: nowrap;
}
.seg button span { font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--button-fill); color: var(--button-text); }
.seg button:not([aria-pressed="true"]):hover { background: var(--hairline); }
.tools { display: flex; gap: 8px; }
.tool {
  height: 46px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--hairline); border-radius: 999px; background: transparent;
  font-size: 15px; font-weight: 500; cursor: pointer; touch-action: manipulation; white-space: nowrap;
}
.tool:hover { border-color: var(--outline); }
.tool[aria-pressed="true"] { border-color: var(--outline); }
.switch { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--outline); flex: none; transition: background 220ms var(--ease); }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #FBFAF7; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 220ms var(--ease); }
.tool[aria-pressed="true"] .switch { background: var(--button-fill); }
.tool[aria-pressed="true"] .switch .knob { transform: translateX(14px); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- stage: frame, mount, board, label ---------- */
.stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center; gap: 40px;
}
.frame { background: var(--frame); padding: var(--frame-w); border-radius: 2px; box-shadow: var(--frame-shadow); flex: none; }
.mount { background: var(--mount); padding: var(--mount-w); }
.board {
  position: relative; background: var(--mount); width: 300px; height: 240px;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.board:focus { outline: none; }
.board.instant .tile { transition: none !important; }

.tile {
  position: absolute; left: 0; top: 0; padding: 0; margin: 0; border: 0;
  background-color: #8C8A80; background-repeat: no-repeat;
  cursor: grab; -webkit-tap-highlight-color: transparent; touch-action: none;
  transition: transform 260ms var(--ease), box-shadow 220ms var(--ease);
  will-change: transform;
}
.tile.lifted { z-index: 3; box-shadow: 0 0 0 3px var(--mount), 0 12px 26px rgba(0,0,0,0.38), 0 2px 4px rgba(0,0,0,0.2); }
.tile.dragging { z-index: 4; transition: box-shadow 220ms var(--ease); cursor: grabbing; box-shadow: 0 16px 34px rgba(0,0,0,0.42), 0 2px 4px rgba(0,0,0,0.2); }
.tile.target { box-shadow: 0 0 0 3px var(--text); z-index: 2; }
.tile.locked { cursor: default; }
.tile:focus { outline: none; }
.tile:focus-visible { outline: 3px solid var(--text); outline-offset: -3px; z-index: 2; }
.board.peeking .tile { cursor: default; }
.board.done .tile { cursor: default; }

.side { flex: none; width: 240px; display: flex; flex-direction: column; gap: 28px; }
.label {
  flex: none; padding-top: 12px; border-top: 1px solid var(--label-rule);
  display: flex; flex-direction: column; gap: 4px;
}
.label-title { font-family: var(--serif); font-weight: 600; font-size: 18px; line-height: 23px; }
.label-line { font-size: 14px; line-height: 19px; }
.label-muted { font-size: 13px; line-height: 18px; color: var(--muted); }
.label-credit { font-size: 12px; line-height: 17px; color: var(--muted); margin-top: 8px; }

/* ---------- status and footer ---------- */
.status { display: flex; flex-direction: column; align-items: flex-start; }
.status .finished { justify-content: flex-start; }
.hint { font-size: 15px; line-height: 22px; color: var(--muted); }
.finished { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; animation: rise 600ms var(--ease) both; }
.finished-word { font-family: var(--serif); font-weight: 600; font-size: 22px; }
.finished-note { font-size: 15px; }
.cta {
  white-space: nowrap; height: 46px; padding: 0 20px; display: inline-flex; align-items: center; border-radius: 10px;
  background: var(--button-fill); color: var(--button-text); text-decoration: none; font-size: 15px; font-weight: 500;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.foot {
  border-top: 1px solid var(--hairline); padding-top: 14px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px;
  font-size: 13px; line-height: 18px; color: var(--muted);
}
.foot a { color: var(--text); }
.noscript { text-align: center; padding: 20px; }

.phone-only { display: none; }

/* ---------- narrower screens: label under the frame ---------- */
@media (max-width: 999px) {
  .stage { flex-direction: column; gap: 22px; }
  .side { width: min(100%, 460px); gap: 16px; }
  .label { text-align: center; align-items: center; }
  .status { align-items: center; text-align: center; }
  .status .finished { justify-content: center; }
}
/* Short screens (iPad landscape, small Mac windows): give the picture the room. */
@media (max-height: 900px) and (min-width: 700px) {
  :root { --frame-w: 12px; --mount-w: 28px; }
  .page { gap: 14px; padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}

/* ---------- phones ---------- */
@media (max-width: 699px) {
  :root { --frame-w: 8px; --mount-w: 14px; }
  .page { gap: 18px; padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
  .logo { font-size: 28px; }
  .mode-name { font-size: 20px; }
  .desktop-only { display: none !important; }
  .phone-only { display: inline; }
  /* The board comes first on a phone; buttons sit under it, within thumb reach. */
  .stage { order: 1; flex: none; }
  .controls { order: 2; flex-direction: column; gap: 10px; }
  .foot { order: 3; }
  .tool { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile, .tile.dragging, .switch, .switch .knob { transition: none; }
  .finished { animation: none; }
}
