/* St. John Almanac: the place chooser (place/picker.js). Every colour is one of the site's tokens.

   On a phone the parts stack: the box that finds a name, the map, what the pin reads, the name and the
   press that adds it. One finger scrolls the page over the whole-island view (touch-action: pan-y) and
   moves the map once it is zoomed in; everything outside the map always scrolls the page, and the map is
   never taller than two thirds of the screen, so there is always page to take hold of. On a desk the map
   stands beside the rest. */

.pk { --pk-r: 12px; display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); grid-template-areas: "find" "stage" "read" "add" "say"; min-width: 0; }
.pk [hidden] { display: none !important; }
.pk-find { grid-area: find; position: relative; min-width: 0; }
.pk-stage { grid-area: stage; position: relative; min-width: 0; height: clamp(17rem, 62svh, 34rem); border-radius: var(--pk-r); overflow: hidden; border: 1px solid var(--water-edge); background: var(--water); }
.pk-read { grid-area: read; min-width: 0; display: grid; gap: 0.7rem; }
.pk-add { grid-area: add; min-width: 0; display: grid; gap: 0.35rem; }
.pk-say { grid-area: say; margin: 0; min-height: 1.5em; font-size: var(--step--1); color: var(--ink-soft); overflow-wrap: anywhere; }
.pk-say b { color: var(--ink); }

@media (min-width: 60rem) {
  .pk { grid-template-columns: minmax(0, 1fr) minmax(18rem, 23rem); grid-template-areas: "stage find" "stage read" "stage add" "stage say" "stage ."; grid-template-rows: auto auto auto auto 1fr; gap: 0.9rem 1.5rem; }
  .pk-stage { height: clamp(26rem, 72vh, 44rem); }
}

/* ----- the map ----- */
/* the stage's box fills the stage whichever piece draws in it (the model's own sheet would make it stand in the flow) */
.pk-stage > .pk-map { position: absolute; inset: 0; min-height: 0; outline: none; }
.pk-flat:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; border-radius: var(--pk-r); }
.pk-flat canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.pk-flat--in canvas, .pk--full .pk-flat canvas { touch-action: none; }
.pk-flat--hold canvas { cursor: grabbing !important; }
/* on the model the hint and the scale's corner stand clear of the model's own line of words */
.pk--model .pk-hint { bottom: 64px; }

.pk-tools { position: absolute; top: 8px; right: 8px; display: grid; gap: 6px; }
.pk-tools button, .pk-wide, .pk-nudge button {
  width: 2.75rem; height: 2.75rem; padding: 0; display: grid; place-items: center;
  color: var(--ink); background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.pk-tools button, .pk-wide { box-shadow: 0 1px 4px color-mix(in srgb, var(--ink) 22%, transparent); }
.pk-tools button:hover, .pk-wide:hover, .pk-nudge button:hover { border-color: var(--ink); }
.pk-tools button:active, .pk-wide:active, .pk-nudge button:active { background: var(--land); }
.pk-tools button:focus-visible, .pk-wide:focus-visible, .pk-nudge button:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.pk-tools button[aria-pressed="true"] { background: var(--press); color: var(--on-press); border-color: var(--press); }
.pk-wide { position: absolute; top: 8px; left: 8px; }
.pk-looks { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--sheet); border: 1px solid var(--rule); box-shadow: 0 1px 4px color-mix(in srgb, var(--ink) 22%, transparent); }
.pk-looks button { font: inherit; font-size: 0.82rem; font-weight: 600; min-height: 2.25rem; padding: 0.3rem 0.8rem; border: 0; border-radius: 999px; color: var(--ink); background: none; cursor: pointer; white-space: nowrap; touch-action: manipulation; }
.pk-looks button[aria-pressed="true"] { background: var(--press); color: var(--on-press); }
.pk-looks button:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.pk-hint { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); margin: 0; max-width: calc(100% - 24px); padding: 0.4rem 0.8rem; border-radius: 999px; font-size: 0.86rem; font-weight: 600; text-align: center; white-space: nowrap; color: var(--on-press); background: color-mix(in srgb, var(--press) 92%, transparent); pointer-events: none; }

/* ----- finding a name ----- */
.pk-q { font: inherit; width: 100%; min-width: 0; min-height: 3rem; padding: 0.7rem 0.9rem; color: var(--ink); background: var(--sheet); border: 1px solid var(--ink-soft); border-radius: var(--pk-r); -webkit-appearance: none; appearance: none; }
.pk-q:focus-visible, .pk-name:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.pk-q::placeholder, .pk-name::placeholder { color: var(--ink-soft); opacity: 1; }
.pk-hits { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 0.3rem; list-style: none; max-height: min(22rem, 55svh); overflow-y: auto; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--pk-r); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 22%, transparent); }
.pk-hit { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; padding: 0.62rem 0.7rem; border-radius: 8px; cursor: pointer; }
.pk-hit[aria-selected="true"], .pk-hit:hover { background: var(--land); }
.pk-hit-n { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.pk-hit-in { font-weight: 400; color: var(--ink-soft); }
.pk-hit-k { flex: none; font-size: 0.78rem; color: var(--ink-soft); }
.pk-none { padding: 0.55rem 0.7rem; font-size: var(--step--1); color: var(--ink-soft); }

/* ----- what the pin reads ----- */
.pk-facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.pk-fact { min-width: 0; margin: 0; padding: 0.6rem 0.75rem 0.65rem; border-radius: 10px; background: var(--land); border: 1px solid var(--land-edge); }
.pk-fact dt { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold); }
.pk-fact dd { margin: 0; font-family: var(--display); font-size: 1.22rem; line-height: 1.25; overflow-wrap: anywhere; }
.pk-fact dd.pk-sub { font-family: var(--text); font-size: 0.8rem; line-height: 1.35; color: var(--ink-soft); min-height: 1.35em; }
.pk-where span { white-space: nowrap; }
.pk--sea .pk-fact--where { background: var(--water); border-color: var(--water-edge); }

.pk-nudge { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.pk-nudge-say { font-weight: 600; margin-right: 0.2rem; }
.pk-step { font-size: var(--step--1); color: var(--ink-soft); margin-left: 0.2rem; }
@media (max-width: 24rem) { .pk-nudge-say { flex-basis: 100%; } }      /* on the narrowest phones the four arrows keep one row */

/* ----- naming it and adding it ----- */
.pk-add-label { font-weight: 700; overflow-wrap: anywhere; }
.pk-add-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pk-name { font: inherit; flex: 1 1 11rem; min-width: 0; min-height: 3rem; padding: 0.62rem 0.8rem; color: var(--ink); background: var(--sheet); border: 1px solid var(--ink-soft); border-radius: 10px; }
.pk-add-row .button { flex: 1 0 auto; min-height: 3rem; }

/* ----- the map filling the screen ----- */
html.pk-locked, html.pk-locked body { overflow: hidden; }
.pk--full { position: fixed; z-index: 1000; inset: 0; height: 100dvh; margin: 0; padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); gap: 0.5rem; background: var(--sheet); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto auto; grid-template-areas: "find" "stage" "read" "add" "say"; overflow: hidden; }
.pk--full .pk-stage { height: auto; min-height: 0; }
.pk--full .pk-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.35rem; }
.pk--full .pk-fact { padding: 0.4rem 0.5rem; }
.pk--full .pk-fact dd { font-size: 0.98rem; }
.pk--full .pk-fact dd.pk-sub { font-size: 0.72rem; }
.pk--full .pk-nudge-say { display: none; }
.pk--full .pk-say:empty { display: none; }
@media (max-width: 30rem) {
  .pk--full .pk-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pk--full .pk-fact:nth-child(n + 3) { display: none; }       /* a phone keeps the map: position and height stay, the rest is on the page */
}
@media (min-width: 60rem) {
  .pk--full { grid-template-columns: minmax(0, 1fr) minmax(18rem, 23rem); grid-template-rows: auto auto auto auto 1fr; grid-template-areas: "stage find" "stage read" "stage add" "stage say" "stage ."; gap: 0.9rem 1.25rem; padding: 1rem; }
  .pk--full .pk-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .pk--full   .pk--full .pk-fact dd { font-size: 1.22rem; }
  .pk--full .pk-nudge-say { display: inline; }
}

@media (prefers-reduced-motion: reduce) { .pk * { transition: none !important; } }
