/* The free play drawing tool at /draw/ (public/draw/draw.js). Loaded after
   site.css; same palette: navy, turf, chalk, coach orange. */

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ head */

.draw-head {
  background: var(--navy);
  color: #fff;
}

.draw-head .container {
  padding-top: 18px;
  padding-bottom: 22px;
}

.draw-head .crumbs {
  margin-bottom: 10px;
}

.draw-head h1 {
  margin: 0 0 8px;
  font-size: clamp(27px, 6.6vw, 42px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.draw-head p {
  max-width: 44em;
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 16px;
}

/* ------------------------------------------------------------------ tool */

.tool {
  padding: 14px 0 36px;
  background: linear-gradient(var(--navy) 0, var(--navy) 120px, var(--bg) 120px);
}

.tool .container {
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
}

.tool-grid {
  display: grid;
  gap: 14px;
  align-items: start;
}

.tool-main,
.tool-side {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--hairline), var(--shadow);
}

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
  margin: 0;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field select,
.chipselect select,
.name input,
.link-row input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--text);
  font: 600 16px/1 var(--font);
}

.field select,
.chipselect select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* Segmented control. */
.seg {
  display: flex;
  height: 42px;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.seg button {
  flex: 1;
  min-width: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: 700 15px/1 var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(11, 20, 34, 0.16), 0 0 0 1px var(--hairline);
}

.seg-small {
  height: 38px;
}

.seg-small button {
  padding: 0 9px;
  font-size: 14px;
}

/* The board: name, field, toolbar. */
.board {
  border-radius: 18px;
  background: var(--navy);
  box-shadow: 0 18px 40px rgba(11, 20, 34, 0.22);
  overflow: hidden;
}

.board-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.name {
  flex: 1;
  min-width: 0;
}

.name input {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}

.name input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.board .seg {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.board .seg button {
  color: rgba(255, 255, 255, 0.7);
}

.board .seg button[aria-pressed="true"] {
  background: #fff;
  color: var(--navy);
}

.stage-wrap {
  position: relative;
}

.stage {
  position: relative;
  min-height: 240px;
  background: var(--turf);
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.stage[data-mode="move"] {
  cursor: grab;
}

.stage svg {
  display: block;
  width: 100%;
  height: auto;
}

.hint {
  position: absolute;
  left: 50%;
  top: 12px;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(11, 20, 34, 0.78);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
  width: max-content;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px;
}

.toolbar-gap {
  flex: 1 0 0;
}

.tbtn {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tbtn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tbtn-text {
  padding: 0 12px;
  font: 700 14px/1 var(--font);
}

.tbtn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
}

.tbtn:disabled {
  opacity: 0.35;
  cursor: default;
}

.animate {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 21px;
  background: var(--orange);
  color: #fff;
  font: 800 16px/1 var(--font);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245, 110, 26, 0.38);
  -webkit-tap-highlight-color: transparent;
}

.animate:hover {
  background: var(--orange-press);
}

.animate .icon {
  width: 20px;
  height: 20px;
}

/* ------------------------------------------------------------ side panels */

.panel {
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--hairline), var(--shadow);
}

.panel-tip p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.panel-tip strong {
  color: var(--text);
}

.pp-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.pp-label {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font: 900 15px/1 var(--font-round);
}

.pp-label[data-shape="square"] {
  border-radius: 8px;
}

.pp-label[data-shape="triangle"] {
  border-radius: 8px 8px 50% 50%;
}

.pp-title {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.pp-done {
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 17px;
  background: var(--bg);
  color: var(--text);
  font: 700 14px/1 var(--font);
  cursor: pointer;
}

.pp-cap {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chipbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 18px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--text);
  font: 650 14px/1 var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chipbtn b {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: -5px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font: 900 12px/1 var(--font-round);
}

.chipbtn:hover:not(:disabled) {
  box-shadow: inset 0 0 0 1.5px var(--orange);
}

.chipbtn[aria-pressed="true"] {
  background: var(--orange-wash);
  box-shadow: inset 0 0 0 1.5px var(--orange);
  color: var(--orange-ink);
}

.chipbtn:disabled {
  opacity: 0.4;
  cursor: default;
}

.chipbtn-danger {
  color: #c62828;
}

.chipselect select {
  height: 36px;
  border-radius: 18px;
  font-size: 14px;
  background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px;
}

/* Share. */
.share h2 {
  margin: 0 0 4px;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.share-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.link-row {
  display: block;
}

.link-row input {
  height: 38px;
  color: var(--muted);
  font: 500 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-overflow: ellipsis;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.sbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 22px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--text);
  font: 700 15px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sbtn-primary {
  flex: 1 0 auto;
  background: var(--orange);
  box-shadow: none;
  color: #fff;
}

.sbtn-primary:hover:not(:disabled) {
  background: var(--orange-press);
}

.sbtn:disabled {
  opacity: 0.6;
  cursor: default;
}

.sbtn-app {
  width: 100%;
  background: var(--navy);
  box-shadow: none;
  color: #fff;
}

.sbtn-app img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.copy-status {
  min-height: 1.3em;
  margin: 8px 0 0;
  color: var(--turf);
  font-size: 14px;
  font-weight: 600;
}

.copy-status:empty {
  display: none;
}

.open-app {
  margin-top: 10px;
}

/* The app CTA: navy, so the white badge (SEO.md badge rules). */
.app-cta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  padding: 18px;
  border-radius: 16px;
  background: var(--navy);
  color: #fff;
}

.app-cta > img {
  width: 56px;
  height: 56px;
  border-radius: 13px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.app-cta h2 {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.3;
}

.app-cta p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
}

.app-cta .store-badge {
  margin: 12px 0 0;
}

/* ------------------------------------------------------- landing content */

.steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 14px 16px 14px 58px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--hairline);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 16px;
  top: 14px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--orange);
  color: #fff;
  font: 900 15px/1 var(--font-round);
}

.steps span {
  color: var(--muted);
  font-size: 16px;
}

.formation-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.formation-list li {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--hairline);
  font-size: 15px;
}

.formation-list strong {
  font-size: 16px;
}

.formation-list span {
  color: var(--muted);
}

.tree-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree-list li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px 0 6px;
  border-radius: 19px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--hairline);
  font-weight: 650;
  font-size: 15px;
}

.tree-list b {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 13px;
  background: var(--navy);
  color: #fff;
  font: 900 13px/1 var(--font-round);
}

/* ---------------------------------------------------------------- layout */

@media (max-width: 639px) {
  .draw-head p {
    font-size: 15px;
    line-height: 1.45;
  }

  .setup {
    gap: 8px 10px;
    padding: 10px;
  }

  .field select,
  .seg {
    height: 40px;
  }

  .field > span {
    font-size: 11px;
  }
}

@media (min-width: 640px) {
  .setup {
    grid-template-columns: 1.1fr 1fr 1.3fr 1.3fr;
  }

  .formation-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 960px) {
  .tool {
    padding-top: 18px;
  }

  .tool-grid {
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 20px;
  }

  .tool-side {
    position: sticky;
    top: 76px;
  }
}

@media (prefers-color-scheme: dark) {
  .board {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  }

  .seg button[aria-pressed="true"] {
    background: #24324a;
  }

  .chipbtn b,
  .tree-list b,
  .pp-label {
    background: #f5f2eb;
    color: var(--navy);
  }

  .chipbtn-danger {
    color: #ff8a80;
  }
}

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