/* "Try it yourself": a mini crossword in a mock browser, with the real side panel framed beside it. Uses the page's :root tokens. */

.try {
  padding: 40px 0;
}

.try-demo {
  --np-ink: #1d1d1f;
  --site-paper: #fdfcf8;
  --site-cell: #fff;
  --site-hl: #ffe293;
  --site-bar: #dde8fb;
  --panel-paper: #fffbf3;
  --panel-ink: #1c1f3b;
  --panel-w: 400px;
  container: try / inline-size;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .try-demo {
    --site-paper: #e2ddd0;
    --site-cell: #f3efe5;
    --site-hl: #f2d277;
    --site-bar: #c9d8f2;
  }
}

:root[data-theme="dark"] .try-demo {
  --site-paper: #e2ddd0;
  --site-cell: #f3efe5;
  --site-hl: #f2d277;
  --site-bar: #c9d8f2;
}

.try-demo p,
.try-demo h3,
.try-demo ol {
  margin: 0;
}

/* ============ browser chrome ============ */
.try-browser {
  --cell: 54px;
  display: flex;
  flex-direction: column;
  height: 660px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-card);
  box-shadow: 10px 12px 0 -2px rgba(18, 181, 168, 0.28);
  color: var(--ink);
  font: 400 15px/1.4 var(--body);
}

.try-tabs {
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 14px;
  padding: 9px 14px 0;
  border-bottom: 1.5px solid var(--line-strong);
  background: var(--paper-tint);
}

.try-dots {
  display: flex;
  gap: 6px;
  align-self: center;
  padding-bottom: 8px;
}

.try-dots i {
  width: 12px;
  height: 12px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--coral);
}

.try-dots i:nth-child(2) { background: var(--sun); }
.try-dots i:nth-child(3) { background: var(--teal); }

.try-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 320px;
  margin-bottom: -1.5px;
  padding: 7px 14px 8px;
  border: 1.5px solid var(--line-strong);
  border-bottom-color: var(--paper-card);
  border-radius: 9px 9px 0 0;
  background: var(--paper-card);
  font: 600 13px/1.2 var(--body);
}

.try-fav {
  display: grid;
  flex: none;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: var(--np-ink);
  color: #f3eee1;
  font: 900 11px/1 var(--display);
}

.try-tab-text,
.try-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.try-toolbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  padding: 7px 10px 7px 14px;
  border-bottom: 1.5px solid var(--ink);
}

.try-nav {
  font: 400 20px/1 var(--body);
  letter-spacing: 0.2em;
  color: var(--muted);
}

.try-url {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper-tint);
  font-size: 13px;
  color: var(--muted);
}

.try-url svg {
  flex: none;
  width: 11px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.try-host {
  font-weight: 600;
  color: var(--ink);
}

.try-ext {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -6px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.try-ext::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--sun-tint);
  box-shadow: inset 0 0 0 1.5px var(--ink);
  transition: background-color 0.25s;
}

.try-ext img {
  position: relative;
  width: 18px;
  height: 18px;
}

.try-ext:hover::before,
.try-open .try-ext::before {
  background: var(--sun);
}

/* a ring that ripples out from the icon until the panel is first opened */
.try-ext::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid var(--coral);
  border-radius: 50%;
  opacity: 0;
  animation: try-call 2.4s var(--ease-out) 1s infinite;
}

.try-loaded .try-ext::after,
.try-open .try-ext::after {
  animation: none;
}

/* ============ the newspaper page ============ */
.try-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--site-paper);
  color: var(--np-ink);
}

.try-site {
  height: 100%;
  margin-right: var(--panel-w);
  padding: 22px 30px 30px;
  overflow: auto;
}

.try-mast {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 3px double var(--np-ink);
}

.try-paper {
  font: 900 24px/1 var(--display);
  font-variation-settings: "SOFT" 0, "WONK" 0, "opsz" 144;
  letter-spacing: -0.01em;
}

.try-paper span {
  font-style: italic;
  font-weight: 500;
}

.try-section {
  font: 700 12px/1 var(--body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.try-title {
  margin: 16px 0 18px !important;
  font: 800 26px/1.1 var(--display);
  font-variation-settings: "SOFT" 30, "opsz" 72;
}

.try-title span {
  font-weight: 400;
  color: #5d5a55;
}

.try-play {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 22px 30px;
}

.try-gridcol {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 12px;
  width: calc(5 * var(--cell) + 6 * 2px);
}

.try-clue-bar {
  min-height: calc(2 * 1.35em + 18px);
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--site-bar);
  font-size: 14.5px;
  line-height: 1.35;
}

.try-clue-bar b {
  margin-right: 4px;
}

.try-grid {
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  grid-auto-rows: var(--cell);
  gap: 2px;
  padding: 2px;
  background: var(--np-ink);
}

.try-cell {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--site-cell);
  cursor: pointer;
  transition: background-color 0.2s;
}

.try-cell.try-hl {
  background: var(--site-hl);
}

.try-cell:hover:not(.try-hl) {
  background: #f5f0e2;
}

.try-num {
  position: absolute;
  top: 2px;
  left: 4px;
  font: 600 11px/1 var(--body);
}

.try-letter {
  padding-top: 0.12em;
  font: 700 calc(var(--cell) * 0.56) / 1 var(--hand);
  color: #2a3a8c;
}

.try-letter:not(:empty) {
  animation: try-ink 0.45s var(--ease-pop) both;
}

.try-cell:nth-child(5n + 2) .try-letter { animation-delay: 60ms; }
.try-cell:nth-child(5n + 3) .try-letter { animation-delay: 120ms; }
.try-cell:nth-child(5n + 4) .try-letter { animation-delay: 180ms; }
.try-cell:nth-child(5n + 5) .try-letter { animation-delay: 240ms; }

.try-list {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

.try-list h3 {
  margin: 0 0 4px;
  padding-bottom: 5px;
  border-bottom: 1.5px solid var(--np-ink);
  font: 700 12px/1.2 var(--body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.try-list ol + h3 {
  margin-top: 16px;
}

.try-list ol {
  padding: 0;
  list-style: none;
}

.try-clue {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: 400 15px/1.4 var(--body);
  text-align: left;
  cursor: pointer;
}

.try-clue b {
  min-width: 1.2em;
}

.try-clue-text {
  flex: 1;
}

.try-clue:hover {
  background: rgba(29, 29, 31, 0.06);
}

.try-clue.selected {
  background: var(--site-bar);
}

.try-clue.try-solved .try-clue-text {
  color: #5d5a55;
}

.try-clue.try-solved b::after {
  content: " ✓";
  color: #0b6f68;
}

.try-done {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px !important;
  padding: 10px 16px 10px 10px;
  border: 2px solid var(--np-ink);
  border-radius: 14px;
  background: #fff4cf;
  font: 700 17px/1.3 var(--hand);
  color: #2a3a8c;
  animation: try-rise 0.5s var(--ease-pop) both;
}

.try-done[hidden] {
  display: none;
}

/* ============ before it opens: where the panel will go ============ */
.try-cta {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: var(--panel-w);
  padding: 24px 32px;
  border-left: 2px dashed rgba(29, 29, 31, 0.3);
  background: repeating-linear-gradient(-45deg, transparent 0 14px, rgba(29, 29, 31, 0.03) 14px 28px), rgba(255, 201, 60, 0.08);
  text-align: center;
  transition: opacity 0.3s;
}

.try-cta p {
  max-width: 22ch;
  font: 700 21px/1.3 var(--hand);
  color: #2a3a8c;
}

.try-cta .btn-primary {
  border-color: var(--np-ink);
  background: var(--np-ink);
  color: #fffbf3;
}

.try-otto {
  width: 84px;
  height: auto;
}

.try-open .try-cta {
  opacity: 0;
  pointer-events: none;
}

/* ============ the side panel ============ */
.try-panel {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: var(--panel-w);
  border-left: 2px solid var(--panel-ink);
  background: var(--panel-paper);
  box-shadow: -8px 0 22px rgba(28, 31, 59, 0.14);
  color: var(--panel-ink);
  transform: translateX(104%);
  visibility: hidden;
  transition: transform 0.55s var(--ease-out), visibility 0s 0.55s;
}

.try-open .try-panel {
  transform: none;
  visibility: visible;
  transition: transform 0.55s var(--ease-out), visibility 0s;
}

.try-panel-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 14px;
  border-bottom: 1.5px solid rgba(28, 31, 59, 0.28);
  background: #fbf3e4;
  font: 600 14px/1 var(--body);
}

.try-close {
  width: 40px;
  height: 40px;
  margin-left: auto;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #4e4a5e;
  font: 400 24px/1 var(--body);
  cursor: pointer;
}

.try-close:hover {
  background: rgba(28, 31, 59, 0.08);
}

.try-panel-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.try-panel-body iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.try-loaded .try-panel-body iframe {
  opacity: 1;
}

.try-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  font: 700 19px/1 var(--hand);
  color: #2a3a8c;
}

.try-loading img {
  animation: try-bob 1.2s ease-in-out infinite alternate;
}

/* ============ under the demo ============ */
.try-next {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 18px;
  margin: 34px 0 0;
}

.try-next span {
  font: 700 20px/1.3 var(--hand);
  color: var(--biro);
}

/* ============ narrow: grid on top, the panel slides up as a sheet ============ */
@container try (max-width: 760px) {
  .try-done {
    margin-top: 0 !important;
  }

  .try-browser {
    --cell: 38px;
    height: 740px;
  }

  .try-tab {
    max-width: none;
  }

  .try-site {
    margin-right: 0;
    padding: 14px 16px 150px;
  }

  .try-title {
    margin: 10px 0 12px !important;
    font-size: 22px;
  }

  .try-play {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .try-gridcol {
    align-self: center;
    width: auto;
    max-width: 100%;
  }

  .try-grid {
    align-self: center;
  }

  .try-clue-bar {
    min-height: 0;
  }

  .try-list {
    max-width: none;
  }

  .try-cta {
    top: auto;
    left: 0;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px 12px;
    width: auto;
    padding: 12px 14px 14px;
    border-top: 2px dashed rgba(29, 29, 31, 0.3);
    border-left: 0;
    background: #fbf3e4;
  }

  .try-cta p {
    flex: 1;
    max-width: none;
    font-size: 17px;
    text-align: left;
  }

  .try-cta .btn {
    width: 100%;
  }

  .try-otto {
    width: 44px;
  }

  /* While the sheet is up, the page shows just its grid, so the answers can be seen going in. */
  .try-open .try-site {
    overflow: hidden;
  }

  .try-open .try-mast,
  .try-open .try-title,
  .try-open .try-clue-bar,
  .try-open .try-list,
  .try-open .try-done {
    display: none;
  }

  .try-panel {
    top: calc(14px + 5 * var(--cell) + 6 * 2px + 12px);
    left: 0;
    width: auto;
    border-top: 2px solid var(--panel-ink);
    border-left: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 22px rgba(28, 31, 59, 0.16);
    transform: translateY(104%);
    overflow: hidden;
  }

  .try-panel-head {
    position: relative;
    padding-top: 8px;
    border-radius: 14px 14px 0 0;
  }

  /* a grabber, as on a phone's sheet */
  .try-panel-head::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 2px;
    background: rgba(28, 31, 59, 0.25);
  }
}

@keyframes try-call {
  0% { opacity: 0.9; scale: 1; }
  70%, 100% { opacity: 0; scale: 1.7; }
}

@keyframes try-ink {
  from { opacity: 0; scale: 1.6; rotate: -8deg; }
}

@keyframes try-rise {
  from { opacity: 0; translate: 0 10px; }
}

@keyframes try-bob {
  to { translate: 0 -5px; }
}

@media (prefers-reduced-motion: reduce) {
  .try-demo *,
  .try-demo *::before,
  .try-demo *::after {
    animation: none !important;
    transition: none !important;
  }
}

.try-next .try-mini {
  flex-basis: 100%;
  font: 400 16px/1.4 var(--body);
  color: var(--muted);
  text-align: center;
}

.try-next .try-mini a {
  display: inline-block;
  padding: 8px 2px;
  color: var(--biro);
  font-weight: 600;
  text-underline-offset: 3px;
}
