/* AiB Platform — the canvas map grammar (Морето днес on /free-tools/).
   Loaded only by free_tool_canvas.html, after css/public/public.css. The
   design is the owner-approved concept mockup, spoken in the platform's
   tokens: monochrome cartography on paper, the sea a quiet info-family
   wash, and the three semantic statuses (--ok/--warn/--danger) doing ALL
   the talking. Sodium never appears here — wordmark discipline.

   Ladder literals used: 1019 (the side panel becomes the bottom sheet —
   the 1020 two-column fold) and 719 (phone: the JS crops the open sea out
   of the viewBox; sizes bump to stay legible and tappable). */

/* ---------- full-bleed sections ---------- */
/* Break out of .public-main's 1080px column; the body's overflow-x clip
   (base.css drift guard) absorbs the scrollbar-width remainder of 100vw. */
.sea-bleed { width: 100vw; margin-inline: calc(50% - 50vw); }

/* ---------- hero ---------- */
.sea-hero { margin-top: 18px; }
.sea-hero .public-statement { font-size: clamp(28px, 3.6vw, 44px); }
.sea-empty-note { color: var(--grey); max-width: 56ch; margin: 18px 0 0; }

.day-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 24px; }
.day-tab {
  border: 1px solid var(--hairline-strong); border-radius: 999px;
  background: none; cursor: pointer; padding: 8px 16px;
  font: inherit; font-size: 14px; color: var(--grey);
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out);
}
.day-tab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.day-meta { font-size: 12px; color: var(--grey); margin-left: 4px; }

/* ---------- the sticky spine: the coast barcode ---------- */
.sea-spine {
  /* the sticky ink header is ~70px tall (16px paddings + the CTA pill);
     the offset must clear it fully or the spine's own top padding slides
     underneath and the bars read as glued to the header */
  position: sticky; top: 68px;
  z-index: 40; background: var(--paper);
  border-bottom: 1px solid var(--hairline);
  padding: 14px var(--pad) 10px; margin-top: 26px;
}
.sea-spine-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 18px; }
.sea-spine-bar { flex: 1 1 auto; min-width: 0; }
.sea-barcode { display: flex; gap: 2px; height: 18px; min-width: 0; }
.sea-barcode button {
  flex: 1 1 0; min-width: 3px; border: 0; border-radius: 2px; padding: 0; cursor: pointer;
  transition: transform 140ms var(--ease-out), opacity 140ms;
}
.sea-barcode button:hover { opacity: 0.75; }
.sea-barcode button[aria-current="true"] { transform: scaleY(1.45); outline: 1.5px solid var(--ink); outline-offset: 1px; }
.bc-o { background: var(--ok); } .bc-w { background: var(--warn); }
.bc-d { background: var(--danger); } .bc-na { background: var(--hairline-strong); }
.sea-spine-ends { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.1em; color: var(--grey-dark); text-transform: uppercase; margin-top: 4px; }
.sea-counts { display: flex; gap: 14px; white-space: nowrap; font-size: 13px; color: var(--grey); }
.sea-counts b { color: var(--ink); font-weight: 600; }
.sea-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.sea-dot-o { background: var(--ok); } .sea-dot-w { background: var(--warn); } .sea-dot-d { background: var(--danger); }

/* ---------- region chips ---------- */
.sea-regions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 0 0; }
.sea-region-chip {
  border: 1px solid var(--hairline); border-radius: 999px; background: var(--paper);
  cursor: pointer; padding: 6px 14px; font: inherit; font-size: 13px; color: var(--grey);
}
.sea-region-chip:hover { border-color: var(--hairline-strong); color: var(--ink); }
/* narrow screens only: the panel is off-screen until a tap, so say so */
.sea-tap-hint { display: none; margin: 12px 0 0; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--grey); }

/* ---------- the map canvas ---------- */
.sea-map { background: var(--info-face); margin-top: 18px; border-block: 1px solid var(--hairline); }
.sea-grid {
  max-width: 1400px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 396px;
  gap: 0 28px; padding: 0 var(--pad);
}
.sea-coast { min-width: 0; }
.sea-coast svg { width: 100%; height: auto; display: block; }

.sea-panel-col { min-width: 0; }
.sea-panel {
  position: sticky; top: 134px; /* header + spine */
  /* A sticky box taller than the room under the header pins at the top and
     its tail surfaces only once the whole map has scrolled by — on a laptop
     (≈700px of CSS height at Windows scaling) that hid the panel's bottom
     until Резово. Cap it to the viewport; the short-viewport tier below
     tightens the rhythm so it usually fits whole, and the panel scrolls
     inside only as the last resort. */
  max-height: calc(100vh - 134px - 24px);
  max-height: calc(100dvh - 134px - 24px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: var(--paper); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
  padding: 22px; margin: 40px 0;
}
.sea-sheet-grip, .sea-sheet-close { display: none; }

.sea-panel-region { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--grey); margin: 0; }
.sea-panel-name { font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: -0.01em; margin: 4px 0 0; }
/* the panel's day switch: the hero's pills, one size down */
.sea-panel-days { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sea-panel-days .day-tab { padding: 5px 12px; font-size: 12.5px; }

.sea-verdict { display: inline-flex; align-items: center; gap: 9px; border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 15px; margin-top: 14px; }
.sea-verdict .sea-dot { width: 9px; height: 9px; margin: 0; }
.sea-verdict-o { background: var(--ok-face); color: var(--ok); }
.sea-verdict-w { background: var(--warn-face); color: var(--warn); }
.sea-verdict-d { background: var(--danger-face); color: var(--danger); }
.sea-reason { margin: 12px 0 0; font-size: 14px; max-width: 42ch; }
.sea-empty { color: var(--grey); font-size: 14px; margin: 10px 0 0; max-width: 40ch; }

/* five facts (waves, wind, air, water, UV) sit in two rows of three; the
   560 tier folds them to two columns where the panel is a phone sheet */
.sea-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--hairline); }
.sea-facts dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--grey); margin: 0; }
.sea-facts dd { margin: 3px 0 0; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sea-facts dd small { font-weight: 400; color: var(--grey); font-size: 12px; }

.sea-hours { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.sea-hours-title, .sea-alts-title { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--grey); margin: 0 0 8px; }
.sea-hour-strip { display: flex; gap: 3px; }
.sea-hour-cell { flex: 1 1 0; min-width: 0; text-align: center; }
.sea-hour-tick { height: 22px; border-radius: 3px; }
.sea-hour-cell span { display: block; font-family: var(--font-mono); font-size: 9px; color: var(--grey-dark); margin-top: 4px; }
.tick-o { background: var(--ok); opacity: 0.85; } .tick-w { background: var(--warn); opacity: 0.85; } .tick-d { background: var(--danger); opacity: 0.85; }

.sea-alts { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.sea-alt-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--hairline); }
.sea-alt-row:last-child { border-bottom: 0; }
.sea-alt-link { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; font-weight: 600; text-align: left; color: var(--ink); }
.sea-alt-link:hover { text-decoration: underline; }
.sea-alt-dist { font-family: var(--font-mono); font-size: 12px; color: var(--grey); white-space: nowrap; }
.sea-alt-state { font-size: 12px; font-weight: 600; color: var(--ok); }
.sea-alts-empty { color: var(--grey); font-size: 13px; margin: 4px 0 0; }

.sea-panel-meta { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--hairline); font-family: var(--font-mono); font-size: 11px; color: var(--grey); line-height: 1.7; }
.sea-panel-flag { color: var(--grey); font-size: 12px; margin: 10px 0 0; }

/* short laptop viewports (height, not the width ladder — the one place
   the coast page keys on it): the panel's vertical rhythm tightens so the
   whole reading fits under header + spine without an inner scroll */
@media (min-width: 1020px) and (max-height: 840px) {
  .sea-panel { padding: 14px 18px 16px; margin: 24px 0; max-height: calc(100dvh - 134px - 16px); }
  .sea-panel-name { font-size: 22px; }
  .sea-panel-days { margin-top: 6px; }
  .sea-panel-days .day-tab { padding: 3px 10px; font-size: 12px; }
  .sea-verdict { margin-top: 8px; padding: 5px 14px; font-size: 14px; }
  .sea-reason { margin-top: 6px; font-size: 13.5px; }
  .sea-facts { gap: 6px 16px; margin-top: 10px; padding-top: 10px; }
  .sea-facts dd { font-size: 16px; }
  .sea-hours, .sea-alts { margin-top: 8px; padding-top: 8px; }
  .sea-hour-tick { height: 14px; }
  .sea-hour-cell span { margin-top: 2px; }
  .sea-alt-row { padding: 4px 0; }
  .sea-panel-meta { margin-top: 8px; padding-top: 6px; line-height: 1.4; }
  .sea-panel-flag { margin-top: 5px; }
}

/* ---------- SVG cartography ---------- */
#sea-svg .land { fill: var(--canvas); }
#sea-svg .coastline { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
#sea-svg .depth { fill: none; stroke: var(--info); stroke-width: 0.7; stroke-dasharray: 1 7; stroke-linecap: round; }
#sea-svg .geo-label { font-family: var(--font-body); font-style: italic; font-size: 12px; fill: var(--grey); }
#sea-svg .sea-label { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: 0.55em; fill: var(--info); opacity: 0.28; text-transform: uppercase; }
#sea-svg .town-label { font-family: var(--font-display); font-weight: 700; font-size: 14px; fill: var(--ink); }
#sea-svg .compass, #sea-svg .scale-label { font-family: var(--font-mono); font-size: 10px; fill: var(--grey); letter-spacing: 0.1em; }

#sea-svg .beach { cursor: pointer; }
#sea-svg .beach .tick { stroke: var(--grey-dark); stroke-width: 1; }
#sea-svg .beach .b-dot { stroke: var(--paper); stroke-width: 1.5; transition: r 140ms var(--ease-out); }
#sea-svg .beach .b-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; fill: #3F4148; }
#sea-svg .beach:hover .b-dot { r: 9; }
#sea-svg .beach .b-ring { fill: none; stroke: var(--ink); stroke-width: 1.4; opacity: 0; }
#sea-svg .beach.is-sel .b-ring, #sea-svg .beach:focus-visible .b-ring { opacity: 1; }
#sea-svg .beach.is-sel .b-dot { r: 9; }
#sea-svg .beach.is-sel .b-label { font-weight: 700; fill: var(--ink); }
/* the group is focusable (keyboard reaches every beach), but the browser's
   own focus rectangle around its bbox reads as a stray box on click — the
   selection ring circle above is the one focus/selection indicator */
#sea-svg .beach:focus { outline: none; }
.st-o { fill: var(--ok); } .st-w { fill: var(--warn); } .st-d { fill: var(--danger); }
.st-na { fill: var(--grey-dark); }

/* ---------- under the map ---------- */
.sea-method { padding: clamp(36px, 6vw, 64px) 0 0; }
.sea-method h2 { font-family: var(--font-display); font-weight: 800; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -0.01em; margin: 0 0 6px; }
.sea-method-sub { color: var(--grey); max-width: 60ch; margin: 0 0 26px; }
.sea-method-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.sea-m-card { border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--paper); padding: 20px; box-shadow: var(--shadow-card); }
.sea-m-card h3 { font-family: var(--font-display); font-size: 16px; font-weight: 700; margin: 0 0 6px; }
.sea-m-card p { margin: 0; color: var(--grey); font-size: 13.5px; }
.sea-m-num { font-size: 11px; color: var(--grey-dark); letter-spacing: 0.1em; display: block; margin-bottom: 10px; }

.sea-warning { margin-top: clamp(24px, 4vw, 40px); }
.sea-warning-inner {
  border: 1px solid var(--hairline); border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm); background: var(--paper);
  padding: 16px 20px; color: var(--grey); font-size: 13.5px; max-width: 76ch; margin: 0;
}
.sea-warning-inner b { color: var(--ink); }
.tool-widget--canvas .trust-line { margin-top: 18px; }

/* ---------- keyboard ---------- */
.day-tab:focus-visible, .sea-region-chip:focus-visible, .sea-barcode button:focus-visible,
.sea-alt-link:focus-visible, .sea-sheet-grip:focus-visible, .sea-sheet-close:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}

/* ---------- tablet & phone: the bottom sheet ---------- */
@media (max-width: 1019px) {
  .sea-grid { grid-template-columns: minmax(0, 1fr); padding: 0 8px; }
  .sea-panel-col { position: static; }
  /* The side panel becomes a bottom sheet that exists ONLY while a beach is
     being read: off-screen until a tap opens it; Затвори, the grip, Escape,
     a swipe down or scrolling the map out of view all put it back. It never
     peeks — a fixed peek rode over the hero, the method cards and the
     footer, and fought the cookie pill for the same corner. `top: auto` is
     load-bearing: the desktop sticky `top: 134px` would otherwise win the
     over-constrained box and float the open sheet 12px off the screen edge.
     z 61 keeps it above the cookie pill (z 60) while that one fades. */
  .sea-panel {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 61;
    margin: 0 auto; max-width: 560px;
    border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0;
    box-shadow: 0 12px 40px rgba(13, 14, 19, 0.14);
    /* +48px: the shadow's reach, so nothing of it bleeds up when closed */
    transform: translateY(calc(100% + 48px));
    visibility: hidden;
    transition: transform 260ms var(--ease-out), visibility 0s linear 260ms;
    max-height: 78dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  }
  .sea-panel.is-open { transform: none; visibility: visible; transition-delay: 0s; }
  /* the cookie pill shares the sheet's corner; while the sheet is up it
     steps aside instead of poking half-cut from under the sheet's edge */
  .sea-sheet-open .cookie-note { opacity: 0; pointer-events: none; transition: opacity 200ms; }
  .sea-sheet-grip { display: block; width: 100%; border: 0; background: none; cursor: pointer; padding: 4px 0 10px; text-align: center; }
  .sea-sheet-grip::before {
    content: ""; display: inline-block; width: 44px; height: 4px;
    border-radius: 999px; background: var(--hairline-strong);
  }
  .sea-sheet-close {
    display: block; position: absolute; top: 14px; right: 14px;
    border: 0; background: none; cursor: pointer;
    font-family: var(--font-mono); font-size: 13px; color: var(--grey); padding: 4px 8px;
  }
  /* the sheet no longer peeks, so the map needs only breathing room under
     Резово — anything more reads as an empty blue band under the coast */
  .sea-map { padding-bottom: 16px; }
  .sea-tap-hint { display: block; }
  .sea-method-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 719px) {
  .sea-counts { display: none; }
  .sea-spine { top: 62px; }
  .sea-hero { margin-top: 8px; }
  .sea-hero .public-statement { font-size: clamp(24px, 7.5vw, 32px); }
  /* the phone viewBox crops the open sea (the JS swaps it), so SVG units
     render near 1:0.78 — sizes bump so labels stay legible, dots tappable */
  #sea-svg .garnish { display: none; }
  #sea-svg .beach .b-label { font-size: 15px; }
  #sea-svg .beach .b-dot { r: 9; }
  #sea-svg .beach:hover .b-dot, #sea-svg .beach.is-sel .b-dot { r: 11; }
  #sea-svg .beach .b-ring { r: 17; }
  #sea-svg .sea-label { opacity: 0.18; }
}

@media (max-width: 560px) {
  .sea-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .sea-panel, .day-tab, .sea-barcode button, #sea-svg .beach .b-dot { transition: none; }
}
