/* Shared kit of the free tools (form, chips, preview, result card). Loaded on every
   page with a tool section, before the tool's own stylesheet. */

@font-face {
  font-family: "Playfair Display";
  src: url("/assets/fonts/playfair-display-cyrillic-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Playfair Display";
  src: url("/assets/fonts/playfair-display-latin-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.ok-tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 40px;
  align-items: start;
  margin-top: 28px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--paper-soft);
}

.ok-form {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.ok-field {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ok-field legend,
.ok-label {
  margin: 0 0 10px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ok-field .ok-label {
  margin-bottom: 0;
}

.ok-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.ok-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.ok-input:focus-visible,
.ok-chip input:focus-visible + span,
.ok-swatch input:focus-visible + span,
.ok-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ok-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.ok-chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.ok-chip input,
.ok-swatch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ok-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ok-chip input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.ok-button {
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.ok-button--ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.ok-button--ghost:hover {
  border-color: var(--ink);
}

.ok-styles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ok-swatch {
  position: relative;
  cursor: pointer;
}

.ok-swatch span[aria-hidden] {
  display: block;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: radial-gradient(circle at 70% 30%, var(--fg) 0 22%, transparent 23%), var(--bg);
  box-shadow: 0 0 0 0 var(--ink);
  transition: box-shadow 0.15s;
}

.ok-swatch input:checked + span {
  box-shadow: 0 0 0 3px var(--paper-soft), 0 0 0 5px var(--ink);
}

.ok-preview {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 14px;
}

.ok-canvas {
  width: 100%;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(23, 20, 17, 0.18);
  background: #fff;
}

/* The picture with what belongs to it (slide pager, hint for phones). */
.ok-stage {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.ok-stage__hint {
  display: none;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.ok-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ok-actions .button {
  flex: 1 1 100%;
  justify-content: center;
}

.ok-actions .ok-button {
  flex: 1 1 auto;
}

/* The WhatsApp link for booking (okoshki, zapis). */
.ok-wa {
  display: grid;
  gap: 8px;
}

.ok-wa__row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ok-wa code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ok-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--accent-strong);
  font-weight: 600;
}

.ok-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.ok-result {
  display: grid;
  gap: 10px;
  padding: 20px;
  border-radius: 20px;
  background: var(--ink);
  color: #fff;
}

.ok-result h3 {
  margin: 0;
  font-size: 20px;
}

.ok-result p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

.ok-result .button {
  justify-self: start;
  background: var(--accent);
  color: #fff;
}

.ok-tool [hidden] {
  display: none !important;
}

.ok-mobile-download {
  display: none;
}

/* The picture over the page when the browser cannot save a file (tool-save.js). */
.ok-save-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 20, 17, 0.93);
  overflow-y: auto;
}

.ok-save-overlay__box {
  display: grid;
  gap: 14px;
  justify-items: center;
  width: min(100%, 440px);
}

.ok-save-overlay__box img {
  display: block;
  max-width: 100%;
  max-height: 66vh;
  border-radius: 14px;
  /* Long press must open the system «Save image» menu. */
  -webkit-touch-callout: default;
  user-select: auto;
}

.ok-save-overlay__hint {
  margin: 0;
  color: #fff;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 860px) {
  .ok-tool {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 18px;
    border-radius: 22px;
  }

  /* Phones: the picture is pinned to the top and the form scrolls under it, so a
     change is seen at once. The preview column dissolves (display: contents): the
     stage goes first, then the form, then the rest of the column — secondary
     buttons, notes, the result card. Behaviour — tool-stage.js. */
  .ok-preview {
    display: contents;
  }

  .ok-preview > .ok-label {
    display: none;
  }

  .ok-stage {
    position: sticky;
    top: 0;
    z-index: 5;
    order: -2;
    justify-items: center;
    gap: 6px;
    margin: -18px -18px 0;
    padding: 10px 18px 8px;
    border-bottom: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    background: var(--paper-soft);
  }

  .ok-stage .ok-canvas {
    width: auto;
    max-width: 100%;
    max-height: min(32vh, 240px);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(23, 20, 17, 0.16);
    cursor: zoom-in;
  }

  .ok-stage__hint {
    display: block;
  }

  /* A field has just changed: the picture blinks once. */
  .ok-stage.is-updated .ok-canvas {
    outline: 3px solid transparent;
    outline-offset: 3px;
    animation: ok-stage-updated 0.8s ease-out;
  }

  .ok-form {
    order: -1;
  }

  /* One download button, pinned to the bottom while the form is on screen; its twin
     in the preview column would be a second primary button far below. */
  .ok-actions > .button--accent {
    display: none;
  }

  .ok-mobile-download {
    position: sticky;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 5;
    display: flex;
    justify-content: center;
    box-shadow: 0 10px 28px rgba(23, 20, 17, 0.28);
  }

  /* The keyboard is open: leave the screen to the field being typed in. */
  .ok-tool.is-typing .ok-stage .ok-canvas {
    max-height: min(18vh, 120px);
  }

  .ok-tool.is-typing .ok-stage__hint {
    display: none;
  }

  .ok-tool.is-typing .ok-mobile-download {
    position: static;
  }

  /* The way to the tool is shorter: the section lead repeats the first screen. */
  [data-section="tool"] .section-head h2 {
    font-size: 26px;
    line-height: 1.15;
  }

  [data-section="tool"] .section-head .section-lead {
    display: none;
  }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .ok-stage.is-updated .ok-canvas {
    animation: none;
  }
}

@keyframes ok-stage-updated {
  from {
    outline-color: var(--accent);
  }

  to {
    outline-color: transparent;
  }
}

@media (max-width: 520px) {
  .ok-row {
    grid-template-columns: 1fr;
  }
}
