/*!
 * 123PhotoTool — Color Naming Tool (color-naming.php).
 *
 * The page uses the shared tool layout (pt-ui.css) and, with a photo on a
 * phone, the full-screen editor (pt-app.css). This file is only what the
 * tool adds: the colour and its codes, the name search, the names, the
 * details, the colour card in the photo box, and the photo picker.
 */

/* ── The colour ────────────────────────────────────────────────────────── */
.cn-current { display: flex; gap: 12px; align-items: stretch; }
/* The swatch is the system colour chooser: its <input type=color> lies over
   it, so the tap that opens the chooser is a real tap on the input. */
.cn-swatch {
  position: relative;
  flex: 0 0 104px;
  min-height: 104px;
  margin: 0;
  border-radius: var(--pt-radius-sm, 12px);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  cursor: pointer;
  overflow: hidden;
}
.cn-swatch:focus-within { outline: 3px solid var(--pt-accent, #3f78e0); outline-offset: 2px; }
.cn-native { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.cn-swatch-edit {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--pt-ink, #343f52);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.cn-swatch-edit svg { width: 14px; height: 14px; }
.cn-values { flex: 1 1 auto; min-width: 0; display: grid; gap: 6px; }
.cn-value {
  display: flex;
  align-items: stretch;
  height: 38px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.cn-value:focus-within { border-color: var(--pt-accent, #3f78e0); box-shadow: 0 0 0 3px var(--pt-accent-soft, rgba(63, 120, 224, 0.15)); }
.cn-value:has(.is-invalid) { border-color: #dc3545; }
.cn-value-name {
  flex: 0 0 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-inline-end: 1px solid var(--pt-line, #e3e7ee);
  background: var(--pt-surface, #f6f8fb);
  color: var(--pt-muted, #6c757d);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.cn-value input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  padding: 0 8px;
  background: transparent;
  color: var(--pt-ink, #343f52);
  font: 0.85rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  text-overflow: ellipsis;
  outline: none;
  direction: ltr;
}
[dir="rtl"] .cn-value input { text-align: right; }
.cn-value input::placeholder { color: #b6bcc6; }
.cn-readonly { background: var(--pt-surface, #f6f8fb); }
.cn-readonly input { cursor: copy; color: var(--pt-muted, #6c757d); }
.cn-copy {
  flex: 0 0 40px;
  border: 0;
  border-inline-start: 1px solid var(--pt-line, #e3e7ee);
  background: transparent;
  color: var(--pt-muted, #6c757d);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.cn-copy:hover, .cn-copy:focus-visible { color: var(--pt-accent, #3f78e0); background: var(--pt-accent-soft, rgba(63, 120, 224, 0.06)); }
.cn-copy svg { width: 16px; height: 16px; }
.cn-copy .cn-tick { display: none; }
.cn-done { color: #198754 !important; }
.cn-copy.cn-done .cn-clip { display: none; }
.cn-copy.cn-done .cn-tick { display: block; }
@media (min-width: 768px) and (max-width: 991.98px) {
  .cn-swatch { flex-basis: 84px; min-height: 84px; }
}
/* Phone and the desktop's 360px panel: the swatch is a bar above the codes,
   which get the full width ("rgb(63, 120, 224)" was cut beside it). */
@media (max-width: 575.98px), (min-width: 992px) {
  .cn-current { flex-direction: column; }
  .cn-swatch { flex: none; min-height: 56px; height: 56px; }
  .cn-swatch-edit { top: 50%; transform: translateY(-50%); inset-inline-end: 12px; }
}
@media (max-width: 575.98px) {
  .cn-value { height: 44px; }
  .cn-value input { font-size: 16px; } /* no iOS zoom on focus */
}
/* A name is a button's text: it wraps rather than ending in "…". Sizes in
   px, as the theme's: 1.05rem was 21px on this site's 20px root. */
.cn-name > button .cn-name-text { white-space: normal; overflow-wrap: anywhere; text-overflow: clip; }
@media (min-width: 768px) {
  .cn-name.cn-top .cn-name-text { font-size: 17px; }
  .cn-name-hex { font-size: 12.5px; }
  .cn-name-match { font-size: 12px; min-width: 42px; }
}

/* ── Find by name ──────────────────────────────────────────────────────── */
.cn-search { position: relative; }
.cn-search-icon { position: absolute; top: 50%; inset-inline-start: 14px; width: 15px; height: 15px; margin-top: -7.5px; color: var(--pt-muted, #6c757d); pointer-events: none; }
.cn-search .form-control { padding-inline-start: 38px; min-height: 44px; }
.cn-results, [dir="rtl"] .cn-results {
  margin: 6px 0 0;
  padding: 4px;
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(30, 34, 40, 0.08);
}
.cn-result, .cn-name > button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pt-ink, #343f52);
  text-align: start;
  cursor: pointer;
}
.cn-result:hover, .cn-result[aria-selected="true"] { background: var(--pt-accent-soft, rgba(63, 120, 224, 0.1)); }
.cn-result > i, .cn-name i { flex: 0 0 28px; height: 28px; border-radius: 7px; border: 1px solid rgba(0, 0, 0, 0.12); }
.cn-name-text { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cn-name-hex { flex: none; font: 0.78rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-muted, #6c757d); direction: ltr; }
.cn-result-none { padding: 10px; color: var(--pt-muted, #6c757d); font-size: 0.9rem; }

/* ── The names ─────────────────────────────────────────────────────────── */
/* [dir="rtl"] too: style.css gives RTL lists padding-right: 2rem at (0,1,1), above a class. */
.cn-names, [dir="rtl"] .cn-names { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.cn-name > button { border: 1px solid var(--pt-line, #e3e7ee); background: #fff; cursor: copy; }
.cn-name > button:hover, .cn-name > button:focus-visible { border-color: var(--pt-accent, #3f78e0); }
.cn-name.cn-top > button { min-height: 52px; border-color: var(--pt-accent, #3f78e0); box-shadow: 0 0 0 2px var(--pt-accent-soft, rgba(63, 120, 224, 0.15)); }
.cn-name.cn-top .cn-name-text { font-size: 1.05rem; }
.cn-name.cn-top i { flex-basis: 34px; height: 34px; }
.cn-name > button.cn-done { border-color: #198754; }
.cn-name-match {
  flex: none;
  min-width: 46px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pt-surface, #f1f4f8);
  color: var(--pt-muted, #6c757d);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.cn-top .cn-name-match { background: rgba(25, 135, 84, 0.12); color: #146c43; }

/* ── Details ───────────────────────────────────────────────────────────── */
.cn-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; }
.cn-details > div { padding: 8px 12px; border: 1px solid var(--pt-line, #e3e7ee); border-radius: 10px; background: var(--pt-surface, #f6f8fb); min-width: 0; }
.cn-details dt { font-size: 0.72rem; font-weight: 600; color: var(--pt-muted, #6c757d); margin: 0; }
.cn-details dd { margin: 2px 0 0; font-weight: 700; color: var(--pt-ink, #343f52); font-variant-numeric: tabular-nums; direction: ltr; text-align: start; }
[dir="rtl"] .cn-details dd { text-align: right; }

/* ── Samples, save ─────────────────────────────────────────────────────── */
.cn-samples { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
.cn-sample {
  aspect-ratio: 1;
  min-height: 32px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14);
  cursor: pointer;
  transition: transform 0.12s;
}
.cn-sample:hover, .cn-sample:focus-visible { transform: scale(1.08); box-shadow: 0 0 0 2px var(--pt-accent, #3f78e0); }
@media (max-width: 575.98px) { .cn-samples { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.cn-save #cn-copy-name { font-weight: 600; }

/* ── The photo box: the colour card, or the photo ──────────────────────── */
#cn-viewport { overflow: hidden; }
.cn-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: inherit;
  color: #1e2228;
  transition: background-color 0.15s;
}
.cn-dark .cn-card { color: #fff; }
.cn-has-photo .cn-card { display: none; }
.cn-card-main { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 20px; text-align: center; min-height: 0; }
.cn-card-match { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.75; }
.cn-card-name { font-size: clamp(1.6rem, 3.4vw, 2.6rem); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.cn-card-hex { font: 600 1rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); opacity: 0.85; direction: ltr; }
.cn-card-foot {
  flex: none;
  margin: 0 12px 12px;
  padding: 14px 12px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.cn-card-foot p { font-size: 0.85rem; }
.cn-card-foot .sample-thumbnails { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.cn-card-foot .sample-thumbnail {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}
.cn-card-foot .sample-thumbnail:hover { border-color: var(--pt-accent, #0f70e6); }
.cn-card-foot .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important; }
@media (max-width: 767px) {
  .cn-card-main { padding: 14px; }
  .cn-card-foot { padding: 10px; }
  .cn-card-foot p { display: none; }
  .cn-card-foot .sample-thumbnails { margin-top: 8px; }
  .cn-card-foot .sample-thumbnail { width: 52px; height: 52px; }
}

#cn-image-box {
  position: absolute;
  display: none;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
  border-radius: 4px;
}
.cn-has-photo #cn-image-box { display: block; }
#cn-image-box:focus-visible { box-shadow: 0 0 0 3px var(--pt-accent, #3f78e0); }
#photo-picker-canvas { display: block; width: 100%; height: 100%; }
#cn-marker {
  position: absolute;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.7), inset 0 0 0 1.5px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
#cn-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7);
}
#cn-marker[hidden], #cn-image-box.cn-picking #cn-marker { display: none; }
#cn-loupe {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 7;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  will-change: transform;
}
#cn-loupe.show { display: flex; }
#cn-loupe-canvas {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 7px solid #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.95), 0 0 0 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  background: #9aa1ab;
}
#cn-loupe-hex {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.86);
  color: #fff;
  font: 600 0.78rem/1.4 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
}
#cn-loupe-hex > i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.7); }

/* The name of the pick, over the photo. */
.cn-chip {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 6;
  max-width: calc(100% - 24px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.86);
  color: #fff;
  pointer-events: none;
}
[dir="rtl"] .cn-chip { left: auto; right: 12px; padding: 6px 6px 6px 14px; }
.cn-chip[hidden] { display: none; }
.cn-chip > i { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.8); }
.cn-chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.cn-chip-text b { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cn-chip-text small { font: 0.72rem/1.2 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); opacity: 0.8; direction: ltr; text-align: start; }
.cn-remove {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 6;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 19, 23, 0.7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cn-remove[hidden] { display: none; }
.cn-remove:hover, .cn-remove:focus-visible { background: rgba(17, 19, 23, 0.9); }
.cn-remove svg { width: 20px; height: 20px; }

/* ── In the phone editor ───────────────────────────────────────────────── */
/* The editor has its own close and colour bar. */
.pt-app-open .cn-remove, #pt-app .cn-remove, #pt-app .cn-chip { display: none !important; }
.cn-bar { padding: 4px 8px; }
.pt-app-panels > #cn-color-bar.pt-app-panel-on { display: flex !important; align-items: center; gap: 12px; }
.cn-bar-swatch { flex: 0 0 48px; height: 48px; border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 12px; }
.cn-bar-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.cn-bar-name { font-size: 1.05rem; font-weight: 700; color: var(--pt-app-fg, #fff); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cn-bar-hex { font: 0.82rem/1.3 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-app-muted, #c2c8d0); direction: ltr; text-align: start; }
.cn-bar-copy {
  flex: none;
  min-width: 44px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--pt-app-line, rgba(255, 255, 255, 0.1));
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--pt-app-fg, #fff);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}
.cn-bar-copy .uil { font-size: 1.1rem; line-height: 1; }
.cn-bar-copy.cn-done { border-color: #198754; }
.pt-app-sheet .cn-save { border-top: 0; padding-top: 0; margin-top: 0; }
.pt-app-sheet .cn-save .pt-tool-savebar > .btn { flex: 1 1 auto; }
