/*
 * hyd-map-notes.css - place-pinned paper notes on the Places map.
 *
 * Styles four things built by hyd-map-notes.js (and hyd-world.js for the last): the notes toolbar and the place
 * chooser above the Places map (#places), the folded-paper pins and popups drawn on the Leaflet map (#area-map),
 * the note composer dialog (#hyd-map-note) with its saved-notes list, and the one-line summary on the Area page
 * (.area-gone-summary). Colours come from the --paper-* and --finder-* custom properties of the active theme,
 * with the fallback written inline in each var().
 *
 * Loaded after the Finder and desktop sheets. Touch sizing follows the pointer (pointer: coarse), not the width.
 */

/* Small paper notes on the existing Finder map. The map and media keep their UI. */
#world #places .map-notes-toolbar {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-bottom: 1px solid var(--paper-edge,#89818f);
  background: var(--paper-panel,#353239);
  color: var(--paper-text,#f5f3f6);
  font: 12px/1.4 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
}

/* One button look for the toolbar actions and the chooser buttons: Finder gradient, 4 px corners,
   29 px minimum height (44 px on touch, see the pointer block below). */
#world #places .map-notes-toolbar :is(.map-note-leave, .map-notes-more),
#world #places .map-note-chooser button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 29px;
  padding: 4px 12px;
  border: 1px solid #7e848c;
  border-radius: 4px;
  background: var(--finder-button,linear-gradient(#f7f7f7,#c6cbd1));
  color: var(--finder-ink,#292733);
  font: 12px/1.35 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  box-shadow: inset 0 1px #fff9;
  text-shadow: none;
  transform: none;
}
#world #places .map-note-button-art {
  font:
    18px/1 Georgia,
    serif;
}

/* Show-notes toggle with its checkbox, and the note count pushed to the right edge. */
#world #places .map-notes-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
}
#world #places .map-notes-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #6493c2;
}
#world #places .map-notes-count {
  margin-left: auto;
  color: var(--paper-muted,#c8c4cd);
  font-size: 11px;
}

/* Place chooser under the toolbar, shown while the visitor picks a spot on the map. */
#world #places .map-note-chooser {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--paper-edge,#89818f);
  background: var(--paper-inset,#1c1a20);
  color: var(--paper-text,#f5f3f6);
  font: 12px/1.4 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
}
#world #places .map-note-chooser[hidden] {
  display: none;
}
#world #places .map-note-chooser p {
  flex-basis: 100%;
  margin: 0 0 3px;
  font: 12px/1.4 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  color: var(--paper-text,#f5f3f6);
}
#world #places .map-note-point-status {
  color: var(--paper-muted,#c8c4cd);
  font-size: 11px;
}
#world #places .map-note-chooser button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* While picking, the map and its clickable layers show a crosshair. */
#area-map.map-note-picking,
#area-map.map-note-picking .leaflet-interactive {
  cursor: crosshair;
}

/* Map pins: a folded paper note. A gone note leaves only the empty outline, a changed note paints
   half of the paper, and a draft pin has a dashed outline. */
#area-map .map-note-pin {
  background: transparent;
  border: 0;
}
.map-note-pin-paper {
  position: relative;
  margin: 4px 0 0 6px;
  display: grid;
  place-items: center;
  width: 29px;
  height: 31px;
  background: #f4e7a8;
  border: 1px solid #887348;
  border-radius: 1px 7px 1px 1px;
  box-shadow: 1px 2px 3px #0006;
  transform: rotate(-7deg);
  font:
    23px/1 Georgia,
    serif;
  color: #66502f;
  text-shadow: none;
}
.map-note-pin-paper::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -1px;
  width: 8px;
  height: 8px;
  border-left: 1px solid #a38b54;
  border-bottom: 1px solid #a38b54;
  background: #fff6d5;
  border-radius: 0 6px 0 1px;
}

/* Gone and changed notes drop the paper fill; a gone note also hides its glyph and a changed note
   repaints only its left half. */
.map-note-pin:is(.is-gone, .is-changed) .map-note-pin-paper {
  background: transparent;
  box-shadow: none;
}
.map-note-pin:is(.is-gone, .is-changed) .map-note-pin-paper::after {
  background: transparent;
}
.map-note-pin.is-gone .map-note-pin-paper {
  color: transparent;
}
.map-note-pin.is-changed .map-note-pin-paper::before {
  content: '';
  position: absolute;
  inset: 0 50% 0 0;
  background: #f4e7a8;
  z-index: -1;
}
.map-note-draft-pin .map-note-pin-paper {
  outline: 2px dashed #365d88;
  outline-offset: 3px;
  background: #fff4c5;
  transform: none;
}

/* Keyboard focus ring for a pin. */
#area-map .map-note-pin:focus-visible {
  outline: 3px solid #426fa0;
  outline-offset: 6px;
  border-radius: 4px;
}

/* Popup for a published note: heading, serif note text and a small footnote line. */
#area-map .map-note-popup {
  font: 12px/1.55 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  color: #302e28;
  text-shadow: none;
}
#area-map .map-note-popup > strong {
  display: block;
  font-size: 13px;
}
#area-map .map-note-popup .map-note-public-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 10px 0 12px;
  font:
    14px/1.55 Georgia,
    serif;
}
#area-map .map-note-popup small {
  display: block;
  color: #60594a;
  font-size: 10px;
}

/* Composer dialog (#hyd-map-note): a modal on the dark paper surface with a Finder-style title bar,
   the form and the saved-notes list. */
html[data-theme] #hyd-map-note.map-note-window {
  width: min(530px, calc(100vw - 28px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #747980;
  border-radius: 7px;
  background: var(--paper-surface,#28262c);
  color: var(--paper-text,#f5f3f6);
  box-shadow:
    0 15px 50px #0008,
    0 0 0 1px #ffffff60;
  font: calc(12 * var(--px))/1.5 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  text-shadow: none;
}
html[data-theme] #hyd-map-note.map-note-window[open] {
  display: flex;
  flex-direction: column;
}
#hyd-map-note::backdrop {
  background: #08090c99;
}
#hyd-map-note .map-note-titlebar {
  display: grid;
  grid-template-columns: 23px 1fr 23px;
  gap: 8px;
  align-items: center;
  flex: none;
  padding: 8px 11px;
  border-bottom: 1px solid #858a93;
  background: var(--finder-chrome,linear-gradient(#f5f5f5,#cacbd0));
  color: var(--finder-ink,#292733);
  box-shadow: inset 0 1px #fff;
}
html[data-theme] #hyd-map-note .map-note-titlebar h2 {
  margin: 0;
  text-align: center;
  font: 600 13px/1.3 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  letter-spacing: 0;
  text-shadow: 0 1px #ffffff90;
  color: var(--finder-ink,#292733);
}

/* Close disc: 18 px red button, grown to 44 px by the touch block below. */
#hyd-map-note .map-note-close {
  position: static;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 1px solid #925852;
  border-radius: 50%;
  background: linear-gradient(#ffd3c9, #e07c6d);
  color: #65322c;
  font:
    bold 15px/1 Arial,
    sans-serif;
  box-shadow: inset 0 1px #fff9;
}

/* Form: scrolls inside the dialog; fields, character counter, preview, consent line and action row. */
#hyd-map-note .map-note-form {
  min-height: 0;
  padding: 18px 23px 22px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
html[data-theme] #hyd-map-note p {
  margin: 0 0 13px;
  font: calc(12 * var(--px))/1.55 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  color: var(--paper-text,#f5f3f6);
}

/* Fields: labelled inputs and the textarea on the inset paper colour. */
#hyd-map-note .map-note-field {
  display: block;
  margin: 0 0 12px;
  font-weight: 600;
  color: var(--paper-text,#f5f3f6);
}
#hyd-map-note .map-note-field :is(input, textarea) {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 4px 0 0;
  padding: 8px 9px;
  border: 1px solid var(--paper-edge,#89818f);
  border-radius: 3px;
  background: var(--paper-inset,#1c1a20);
  color: var(--paper-text,#f5f3f6);
  font: calc(13 * var(--px))/1.5 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  box-shadow: inset 0 1px 2px #0003;
}
#hyd-map-note textarea {
  resize: vertical;
  min-height: 80px;
}
#hyd-map-note input::placeholder {
  color: var(--paper-muted,#c8c4cd);
  opacity: 1;
}

/* Pin row (the place pin and its Move pin button) and the character counter. */
#hyd-map-note .map-note-pin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -5px 0 14px;
  font-size: calc(10 * var(--px));
  color: var(--paper-muted,#c8c4cd);
}
#hyd-map-note .map-note-character-count {
  display: block;
  margin: -9px 0 13px;
  text-align: right;
  font-size: calc(10 * var(--px));
  color: var(--paper-muted,#c8c4cd);
}

/* Preview of the note in serif type on a paper strip, then the consent checkbox line. */
#hyd-map-note .map-note-preview {
  margin: 15px 0;
  padding: 14px 16px;
  background: #f5eac5;
  border: 1px solid #aa9361;
  border-left-width: 3px;
  color: #40382b;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font:
    calc(16 * var(--px))/1.5 Georgia,
    serif;
  text-shadow: none;
}
#hyd-map-note .map-note-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: calc(11 * var(--px));
  line-height: 1.5;
  color: var(--paper-muted,#c8c4cd);
}
#hyd-map-note .map-note-consent input {
  flex: none;
  width: 15px;
  height: 15px;
  margin: 1px 0 0;
  accent-color: #6493c2;
}

/* Action row. */
#hyd-map-note .map-note-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 17px 0 11px;
}

/* Secondary buttons in the form share one look; the Save button further down is the primary action. */
#hyd-map-note :is(.map-note-actions, .map-note-pin-row, .map-note-condition) button {
  min-height: 29px;
  padding: 5px 10px;
  border: 1px solid #7e858e;
  border-radius: 4px;
  background: var(--finder-button,linear-gradient(#f7f7f7,#c6cbd1));
  color: var(--finder-ink,#292733);
  font: calc(12 * var(--px))/1.3 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  box-shadow: inset 0 1px #fff9;
  text-shadow: none;
}
#hyd-map-note .map-note-actions button:disabled,
#hyd-map-note .map-note-actions .map-note-save[aria-disabled='true'] {
  opacity: 0.45;
  cursor: default;
}
html[data-theme] #hyd-map-note :is(.map-note-help, .map-note-status) {
  font-size: calc(11 * var(--px));
  color: var(--paper-muted,#c8c4cd);
}
html[data-theme] #hyd-map-note .map-note-status:empty {
  display: none;
}

/* One focus ring for the composer controls and for the Places notes toolbar and chooser. */
#hyd-map-note :is(button, input, textarea):focus-visible,
#places
  :is(.map-note-chooser button, .map-notes-toolbar button, .map-notes-toggle input):focus-visible {
  outline: 2px solid #85bbef;
  outline-offset: 3px;
}

/* Narrow screens: tighter toolbar and form spacing. */
@media (max-width: 550px) {
  #world #places .map-notes-toolbar {
    gap: 11px;
  }
  #world #places .map-notes-count {
    flex-basis: 100%;
    margin: 0;
  }
  #hyd-map-note .map-note-form {
    padding: 16px;
  }
  #hyd-map-note .map-note-actions {
    gap: 7px;
  }
}

/* The glyph inside the leave-a-note button: a fixed 28 px image. */
#world .map-note-leave .map-note-button-art {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

/* Primary action: the full-width blue Save button. */
#hyd-map-note .map-note-actions .map-note-save {
  width: 100%;
  min-height: 38px;
  border-color: #5484a9;
  background: linear-gradient(#e7f5ff, #a3ccea 48%, #87b3d4 49%, #bedff3);
  color: #193d59;
  font-weight: 600;
}

/* Saved notes: a collapsible list of notes saved on this browser; each row reopens its note. */
#hyd-map-note .map-note-saved {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--paper-edge,#89818f);
  font-size: calc(11 * var(--px));
}
#hyd-map-note .map-note-saved[hidden] {
  display: none;
}
#hyd-map-note .map-note-saved summary {
  cursor: pointer;
  color: var(--paper-muted,#c8c4cd);
}
#hyd-map-note .map-note-saved-list {
  display: grid;
  gap: 6px;
  padding-top: 9px;
}
#hyd-map-note .map-note-saved-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
#hyd-map-note .map-note-saved-open {
  padding: 5px 0;
  border: 0;
  background: none;
  box-shadow: none;
  text-align: left;
  text-decoration: underline;
  color: var(--paper-text,#f5f3f6);
  overflow-wrap: anywhere;
  font: inherit;
}
#hyd-map-note .map-note-saved-row small {
  color: var(--paper-muted,#c8c4cd);
}

/* Condition chooser: the three marks (still there, changed, gone) as pressable buttons in one row. */
#hyd-map-note .map-note-condition {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
/* Bigger text (see --px in hyd-platform.css): still there, changed and gone stack in one column. */
@container not style(--px: 1px) {
  #hyd-map-note .map-note-condition {
    grid-template-columns: minmax(0, 1fr);
  }
}
#hyd-map-note .map-note-condition legend {
  margin: 0 0 6px;
  padding: 0;
  font-weight: 600;
}
#hyd-map-note .map-note-condition button {
  min-width: 0;
  min-height: 44px;
  padding: 6px 4px;
}
#hyd-map-note .map-note-condition button[aria-pressed='true'] {
  background: var(--paper-inset,#1c1a20);
  color: var(--paper-text,#f5f3f6);
  box-shadow: inset 1px 2px 3px #0006;
}
#hyd-map-note .map-note-condition button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Mark text (still there, changed or gone) appended to a popup heading. */
#area-map .map-note-mark {
  font-weight: 400;
}

/* Area page: a one-line summary of what people remember as gone, built by hyd-world.js and shown
   under the area heading. */
#world #area .area-gone-summary {
  order: -2;
  margin: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--paper-edge,#89818f);
  background: var(--paper-panel,#353239);
  font: 12px/1.5 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
  color: var(--paper-text,#f5f3f6);
}
#world #area .area-gone-summary[hidden] {
  display: none;
}

/* Touch sizing follows the pointer, including landscape phones and tablets. */
@media (pointer: coarse) {
  #world #places .map-note-chooser button {
    min-height: 44px;
  }
  #hyd-map-note .map-note-titlebar {
    min-height: 48px;
    grid-template-columns: 44px 1fr 44px;
  }
  #hyd-map-note .map-note-close {
    width: 44px;
    height: 44px;
    min-height: 44px;
    font-size: 24px;
  }
  #world #hyd-map-note .map-note-form :is(button, summary) {
    min-height: 44px;
  }
  #hyd-map-note .map-note-consent {
    min-height: 44px;
    align-items: center;
  }
  #hyd-map-note .map-note-field :is(input, textarea) {
    font-size: calc(16 * var(--px));
    min-height: 44px;
  }
}

/* The existing composer also accepts changes to a place; say so at its entry. */
#world #places .map-note-button-copy {
  display: grid;
  gap: 1px;
  text-align: left;
}

/* The hint line and the pocket-places cue label stay hidden so the button reads as one line (see
   the last rule). */
#world #places .map-note-button-hint {
  display: none;
}
#world #places .pocket-note-label {
  display: none;
}
#world #places .map-note-leave {
  min-height: 44px;
}

/* Keep the familiar one-line button; the composer names its three status choices. */
html[data-theme] #world #places .map-notes-toolbar .map-note-leave {
  flex: 0 0 auto;
  width: auto;
  min-width: 116px;
  white-space: nowrap;
}
