/*!
 * 123PhotoTool — Color Converter (color-converter.php).
 * The shared parts (the swatch, the code rows, the sliders, picking from a
 * photo) are in pt-color.css; this is the page's own layout.
 */

/* ── The colour: its swatch and the any-format box ─────────────────────── */
.cc-now { display: flex; gap: 12px; align-items: stretch; }
.cc-now .pt-cswatch { flex: 0 0 76px; min-height: 76px; height: auto; }
.cc-any-wrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.cc-any {
  height: 48px;
  border-radius: 10px;
  font: 0.8rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  direction: ltr;
}
[dir="rtl"] .cc-any { text-align: right; }
.cc-any-hint { color: var(--pt-muted, #6c757d); font-size: 0.7rem; line-height: 1.35; }
.cc-any.is-invalid { border-color: #dc3545; }
.cc-any.is-invalid ~ .cc-any-hint { color: #b02a37; }

/* ── Channels: the RGB / HSL / HSV switch and three sliders ───────────── */
.cc-channels-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.cc-modes { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--pt-surface, #f6f8fb); border: 1px solid var(--pt-line, #e3e7ee); }
.cc-mode {
  min-width: 56px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pt-muted, #6c757d);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.cc-mode:hover { color: var(--pt-ink, #343f52); }
.cc-mode.active { background: #fff; color: var(--pt-ink, #343f52); box-shadow: 0 1px 3px rgba(30, 34, 40, 0.15); }
.cc-mode:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 1px; }
.cc-mode-set[hidden] { display: none; }

/* ── Every format ──────────────────────────────────────────────────────── */
/* OKLCH and translated names need more room than the colour pickers' HEX. */
.cc-formats .pt-cvalue-name { flex-basis: 62px; padding: 0 4px; text-align: center; line-height: 1.1; overflow-wrap: anywhere; }
.cc-formats .pt-cvalue { height: 42px; }
.cc-formats .pt-cvalue input.is-invalid { color: #b02a37; }
/* In a narrow column (a phone, a tablet, a small laptop) each format's name
   sits above its code: an OKLCH code is 28 characters. */
.cc-formats { container: cc-formats / inline-size; }
@container cc-formats (max-width: 470px) {
  .cc-formats .pt-cvalue { display: grid; grid-template-columns: minmax(0, 1fr) 44px; grid-template-rows: auto auto; height: auto; }
  .cc-formats .pt-cvalue-name { grid-area: 1 / 1; justify-content: flex-start; padding: 6px 10px 0; border: 0; background: none; font-size: 0.6rem; line-height: 1.2; text-align: start; }
  /* The code takes the whole width under its name and its copy button. */
  .cc-formats .pt-cvalue input { grid-area: 2 / 1 / 3 / 3; height: 30px; padding: 0 10px 4px; letter-spacing: -0.02em; }
  .cc-formats .pt-ccopy { grid-area: 1 / 2; height: 32px; border-inline-start: 0; border-radius: 0 0 0 8px; }
  [dir="rtl"] .cc-formats .pt-ccopy { border-radius: 0 0 8px 0; }
}
/* A 320px phone: the longest OKLCH code (28 characters) still fits. */
@container cc-formats (max-width: 260px) {
  .cc-formats .pt-cvalue input { padding: 0 6px 4px; letter-spacing: -0.05em; }
}
.cc-name-row input { font-family: var(--bs-body-font-family, system-ui, sans-serif); }
.cc-name-row input::placeholder { color: #b6bcc6; }
.cc-name-note { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 1.4em; color: var(--pt-muted, #6c757d); font-size: 0.7rem; line-height: 1.35; }
.cc-name-note:empty { display: none; }
.cc-nearest {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 999px;
  background: #fff;
  color: var(--pt-ink, #343f52);
  font-weight: 600;
  font-size: 0.7rem;
}
.cc-nearest:hover, .cc-nearest:focus-visible { border-color: var(--pt-accent, #0f70e6); color: var(--pt-accent, #0f70e6); }
.cc-nearest i { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }

/* ── Quick colours ─────────────────────────────────────────────────────── */
.cc-samples { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.cc-sample {
  aspect-ratio: 1;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s;
}
.cc-sample:hover { transform: translateY(-2px); }
.cc-sample:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 2px; }
.cc-sample.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pt-accent, #0f70e6); }

/* ── The workspace: the colour card (or the photo), then the upload ────── */
#cc-viewport { display: flex; flex-direction: column; overflow: hidden; }
.cc-main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: stretch; justify-content: center; }
.cc-card {
  flex: 1 1 auto;
  min-width: 0;
  margin: 12px;
  padding: 24px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(30, 34, 40, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  transition: background-color 0.15s, color 0.15s;
}
.cc-card-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cc-card-hex { font: 700 2.2rem/1.1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); letter-spacing: 0.02em; direction: ltr; text-align: start; overflow-wrap: anywhere; }
[dir="rtl"] .cc-card-hex { text-align: right; } /* the code reads left to right, at the start of the line */
.cc-card-name { font-size: 0.9rem; font-weight: 600; opacity: 0.85; overflow-wrap: anywhere; }
.cc-card-text { display: flex; flex-wrap: wrap; gap: 10px; }
.cc-text-sample {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  direction: ltr;
}
.cc-text-sample b { font-size: 1.2rem; }
.cc-on-white { color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45); }
.cc-on-black { color: #000; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3); }

/* The photo instead of the card. */
.cc-main.cc-photo-view > .cc-card { display: none; }
.cc-main:not(.cc-photo-view) > .pt-pick-box, .cc-main:not(.cc-photo-view) > .pt-pick-loupe, .cc-main:not(.cc-photo-view) > .cc-pick-chip { display: none !important; }
.cc-views {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 6;
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.72);
}
.cc-views[hidden] { display: none; }
.cc-views button { border: 0; border-radius: 999px; min-height: 32px; padding: 0 12px; background: transparent; color: #fff; font-size: 0.75rem; font-weight: 600; }
.cc-views button[aria-pressed="true"] { background: #fff; color: var(--pt-ink, #343f52); }
.cc-views button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
/* With a photo, the card leaves room above it for the switch. */
.cc-has-photo .cc-main:not(.cc-photo-view) > .cc-card { margin-top: 54px; }
/* The colour under the pick, over the photo: a tap copies its code. */
.cc-pick-chip {
  position: absolute;
  bottom: 12px;
  left: 50%;
  z-index: 6;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px 0 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.8);
  color: #fff;
  font: 600 0.75rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  direction: ltr;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.cc-pick-chip[hidden] { display: none; }
.cc-pick-chip i { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); }
.cc-pick-chip.pt-cdone { color: #75d69c !important; }

.cc-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 12px 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(30, 34, 40, 0.06);
}
.cc-has-photo .cc-foot { display: none; }
.cc-foot .sample-thumbnails { display: flex; justify-content: center; gap: 8px; }
.cc-foot .sample-thumbnail {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}
.cc-foot .sample-thumbnail:hover { border-color: var(--pt-accent, #0f70e6); }
.cc-foot .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important; }

/* ── Narrow columns and phones ─────────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 991.98px) {
  .cc-card-hex { font-size: 1.7rem; }
}
@media (max-width: 767.98px) {
  /* On the page (no photo) the card is as tall as its content. */
  #cc-viewport:not(.cc-has-photo):not(.pt-app-viewport) { height: auto !important; min-height: 0 !important; }
  #cc-viewport:not(.cc-has-photo):not(.pt-app-viewport) .cc-main { flex: none; }
  .cc-card { margin: 10px; padding: 18px; min-height: 150px; }
  .cc-card-hex { font-size: 1.6rem; }
  /* The two text samples side by side; a long level wraps inside its own. */
  .cc-card-text { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cc-text-sample { padding: 6px 10px; gap: 6px; align-items: center; white-space: normal; font-size: 0.65rem; line-height: 1.2; }
  .cc-text-sample b { font-size: 1.05rem; flex: none; }
  .cc-samples { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
  .cc-sample { min-height: 0; border-radius: 8px; }
  .cc-any { font-size: 16px; } /* no iOS zoom on focus */
}
@media (max-width: 360px) {
  .cc-now .pt-cswatch { flex-basis: 60px; min-height: 60px; }
  .cc-mode { min-width: 48px; }
}
/* On the phone page a photo is not a work surface (a tap opens the editor). */
html.pt-phone:not(.pt-app-open) #cc-views, html.pt-phone:not(.pt-app-open) #cc-remove-photo { display: none !important; }

/* ── In the phone editor ───────────────────────────────────────────────── */
#pt-app #cc-views, #pt-app .cc-foot { display: none !important; }
#pt-app .cc-card { margin: 8px 4px; box-shadow: none; }
#pt-app .cc-has-photo .cc-main:not(.cc-photo-view) > .cc-card { margin-top: 8px; }
