/* Arrow Challenge: game styles. Colors and fonts come from ../shared/eg-theme.css */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.45;
}
[hidden] { display: none !important; }

.noscript { margin: 16px; padding: 16px; border: 2px solid var(--ink); border-radius: 12px; background: #FBF6EA; color: #1F3246; }

:root { --grid: var(--rule); }
:root[data-contrast="high"] { --grid: #B5B5B5; }  /* the grid stays quiet so the arrows stand out */

:focus-visible { outline: 4px solid var(--mid); outline-offset: 2px; }
/* Headings and the board frame take focus only so screen readers land in the right place; they are not controls. */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* ---------- header and settings ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px;
  padding: 8px 16px 4px;
}
.name-block { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.name { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 24px; line-height: 1.15; white-space: nowrap; }
.kind { margin: 0; white-space: nowrap; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.kind::before { content: ""; width: 14px; height: 14px; border-radius: 2px; background: var(--dot); border: 2px solid var(--ink); flex: none; } /* square = Challenge */

.textlink {
  color: var(--ink); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 4px;
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; white-space: nowrap;
}
.linkbtn { background: none; border: 0; cursor: pointer; }

.settings {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 4px 16px 10px; border-bottom: 2px solid var(--rule);
}
.settings-label { font-size: 18px; margin-right: 2px; }

/* ---------- buttons ---------- */
.btn {
  min-height: 52px; padding: 8px 16px;
  font: inherit; font-weight: 700; font-size: 20px; line-height: 1.2;
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: 12px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn.small { min-height: 46px; font-size: 18px; padding: 6px 14px; }
.btn.primary { background: var(--ink); color: var(--card); }
.btn[aria-disabled="true"] { opacity: 0.5; border-style: dashed; cursor: default; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--card); }

/* ---------- layout ---------- */
main { padding: 12px 12px 40px; max-width: 760px; margin: 0 auto; }
main.playing { padding-bottom: 8px; }
.h2 { margin: 8px 0 12px; font-family: var(--font-head); font-weight: 800; font-size: 30px; line-height: 1.15; }
.panel { background: var(--card); border: 2px solid var(--rule); border-radius: 20px; padding: 4px 18px; margin: 0 0 16px; }
.howto { margin: 14px 0; font-size: 20px; }
.note { margin: 12px 0 0; font-size: 18px; }

.msg {
  margin: 0 0 8px; padding: 8px 12px;
  font-size: 19px; line-height: 1.35;
  background: var(--card); border: 2px solid var(--rule); border-radius: 12px;
}
.msg:empty { display: none; }

/* ---------- choose a puzzle ---------- */
.plist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.ptile {
  width: 100%; min-height: 92px; padding: 12px 14px; text-align: left;
  font: inherit; color: var(--ink); background: var(--card);
  border: 3px solid var(--ink); border-radius: 20px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; gap: 0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ptile .pn { font-family: var(--font-head); font-weight: 800; font-size: 26px; line-height: 1.1; }
.ptile .pz { font-size: 18px; }
.ptile .ps { font-size: 18px; min-height: 1.3em; }
.ptile.done .ps, .ptile.going .ps { font-weight: 700; color: var(--accent-text); }

/* ---------- playing ---------- */
.titlerow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.titlerow .h2 { font-size: 26px; margin: 4px 0; }
.stats { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: 16px; row-gap: 2px; margin: 0 0 8px; }
.count, .tries { margin: 0; font-size: 18px; }
.tries { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.pips { display: inline-flex; gap: 4px; }
.pip { width: 16px; height: 16px; border: 2px solid var(--ink); border-radius: 3px; background: var(--dot); }
.pip.used { background: transparent; border-style: dashed; }

.stage { display: flex; gap: 8px; align-items: stretch; }
.board-wrap {
  flex: 1 1 auto; min-width: 0; position: relative; display: flex;
  height: var(--wrap-h, 420px);
  background: var(--iconbg); border: 3px solid var(--ink); border-radius: 16px;
  padding: 6px; overflow: hidden;
  touch-action: none;             /* the page handles dragging and pinching itself */
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.board-wrap.dragging { cursor: grabbing; }
.board {
  --cell: 40px; --w: 8; --h: 8; --lw: 15;
  position: relative; flex: none; margin: auto; line-height: 0;
  width: calc(var(--w) * var(--cell)); height: calc(var(--h) * var(--cell));
  overflow: hidden; border-radius: 10px;
  box-sizing: content-box;                 /* the puzzle's edge is drawn outside the cells */
  border: 9px double var(--ink);           /* a double line marks the outer edge of the puzzle */
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}
.board.tiny { background-image: none; }
.board.tiny .arrow .hit, .board.tiny .arrow .halo { pointer-events: none; }

/* Zoom control: a tall track on the right. Up is closer. */
.zoomer {
  flex: none; width: 64px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card); border: 3px solid var(--ink); border-radius: 16px;
  height: var(--wrap-h, 420px);
}
.zl { font-size: 15px; font-weight: 700; line-height: 1.1; text-align: center; }
.ztrack {
  position: relative; flex: 1 1 auto; width: 100%; min-height: 100px;
  touch-action: none; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.zrail {
  position: absolute; left: 50%; top: 24px; bottom: 24px; width: 12px; margin-left: -6px;
  background: var(--iconbg); border: 2px solid var(--ink); border-radius: 8px;
}
.ztick { position: absolute; left: 6px; right: 6px; height: 0; border-top: 4px solid var(--dot); pointer-events: none; }
.zthumb {
  position: absolute; left: 50%; width: 50px; height: 48px; margin-left: -25px;
  background: var(--dot); border: 3px solid var(--ink); border-radius: 14px; pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--card);
}
.ztrack:focus-visible { outline: 4px solid var(--mid); outline-offset: 2px; border-radius: 12px; }

.board svg { display: block; width: 100%; height: 100%; }
.board.over { opacity: 0.55; pointer-events: none; }

/* One arrow = a halo (shows hints, blockers and touches), the line with its head, and a wide invisible touch area. */
.arrow { cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.arrow.gone { display: none; }
.arrow .line { fill: none; stroke: var(--ink); stroke-width: var(--lw, 15); stroke-linecap: round; stroke-linejoin: round; }
.arrow .head { fill: var(--ink); stroke: var(--ink); stroke-width: 6; stroke-linejoin: round; }
.arrow .halo { fill: none; stroke: transparent; stroke-width: 44; stroke-linecap: round; stroke-linejoin: round; }
.arrow .hit { fill: none; stroke: transparent; stroke-width: 80; stroke-linecap: round; stroke-linejoin: round; pointer-events: stroke; }

/* A solid orange band means "try this one". A dashed band means "this one is in the way". */
.arrow.hint .halo { stroke: var(--dot); }
.arrow.blocker .halo { stroke: var(--accent-text); stroke-dasharray: 22 16; stroke-linecap: butt; }
.arrow.touch .halo { stroke: var(--mid); opacity: 0.45; }
.arrow:focus-visible .halo { stroke: var(--mid); }
.arrow.nudge .body { animation: nudge 0.35s ease-in-out; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-9px); } 75% { transform: translateX(9px); } }
.fx .line { fill: none; stroke: var(--ink); stroke-width: var(--lw, 15); stroke-linecap: round; stroke-linejoin: round; }
.fx .head { fill: var(--ink); stroke: var(--ink); stroke-width: 6; stroke-linejoin: round; }

.dock {
  position: sticky; bottom: 0; z-index: 5;
  margin-top: 10px; padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  background: var(--bg); border-top: 2px solid var(--rule);
}
.dock .controls { margin-top: 0; grid-template-columns: repeat(2, 1fr); }
.dock .controls .btn { padding: 6px 4px; }
.dock.static { position: static; }
@media (max-height: 480px) { .dock { position: static; } }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin-top: 12px; }
.controls.two { grid-template-columns: 1fr 1fr; }
.controls .btn { min-height: 56px; font-size: 19px; }

/* ---------- all clear ---------- */
.clear { margin-top: 16px; padding: 18px; }
.clear-title { margin: 0 0 6px; font-family: var(--font-head); font-weight: 800; font-size: 36px; line-height: 1.1; }
.clear p { margin: 0 0 14px; }
.clear-buttons { display: grid; gap: 8px; }
.clear-buttons .btn { min-height: 56px; }

@media (prefers-reduced-motion: reduce) {
  .arrow.nudge .body { animation: none; }
}
