/* Color Converter: styles for the color pages only. Shared styles live in /tools/shared/tools.css. */

html,
body {
  overflow-x: clip;
}
.cc-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* "Convert color from [HEX] to [RGB]" in the header, in place of the tool tabs */
.convert-bar {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  margin-top: -6px; /* the 28px menus stay centred on the breadcrumb line */
  color: var(--color-muted);
  white-space: nowrap;
}
.convert-bar:not(:has(.dropdown)) {
  margin-top: 0; /* the hub has no menus, so no offset is needed */
}
.convert-bar .dropdown {
  display: inline-block;
  flex: none;
}
.convert-bar .dropdown-btn {
  width: auto;
  height: 28px;
  gap: 6px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
  font-size: inherit;
  line-height: 1.2;
  color: var(--color-ink);
  cursor: pointer;
}
.convert-bar .dropdown-btn .icon {
  width: 12px;
  height: 12px;
  margin-left: 0;
}
.convert-bar .dropdown-list {
  width: max-content;
  min-width: 100%;
  font-size: var(--text-md);
  line-height: 1.2;
  text-align: left;
}
.convert-bar-title {
  color: var(--color-ink);
}
@media (max-width: 860px) {
  .topbar:has(.convert-bar) {
    flex-wrap: wrap;
    row-gap: var(--space-4);
  }
  .topbar:has(.convert-bar) .topbar-sep {
    display: none;
  }
  .convert-bar {
    order: 3;
    flex: 1 1 100%;
    margin-top: 0;
  }
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-8) var(--space-4) var(--space-16);
}
.cc-subtitle {
  width: 100%;
  max-width: 880px;
  margin: 0 0 var(--space-4);
  font-size: var(--text-md);
  color: var(--color-muted);
}
.cc-noscript {
  max-width: 880px;
  color: var(--color-text);
}

/* The card */
.cc-card {
  width: 100%;
  max-width: 880px;
  padding: var(--space-6);
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
}

/* Swatch: the color over a checkerboard, so transparency is visible */
.cc-swatch {
  position: relative;
  height: 11rem;
  margin-bottom: var(--space-6);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d9d9d9 25%, transparent 25%, transparent 75%, #d9d9d9 75%),
    linear-gradient(45deg, #d9d9d9 25%, transparent 25%, transparent 75%, #d9d9d9 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
.cc-swatch::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cc-color, transparent);
}

.cc-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-6);
}
.cc-col {
  min-width: 0;
}
.cc-col .field-label {
  display: block;
  padding-top: 0;
}
.cc-row {
  display: flex;
  gap: var(--space-2);
}
.cc-row .field {
  flex: 1;
  min-width: 0;
}
.cc-row .field input {
  font-family: var(--font-mono);
  font-size: var(--text-md);
}
.cc-field-invalid,
.cc-field-invalid:focus-within {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 1px var(--color-danger);
}
.cc-hint {
  min-height: 1.25rem;
  margin: var(--space-2) var(--space-1) 0;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--color-muted);
}
.cc-hint.is-error {
  color: var(--color-danger);
}
.cc-hint.is-note {
  color: var(--color-warning);
}

/* Native color picker, shaped like the input next to it */
.cc-picker {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.cc-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}
.cc-picker::-webkit-color-swatch {
  border: 0;
}
.cc-picker::-moz-color-swatch {
  border: 0;
}
.cc-picker:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.cc-copy {
  flex: none;
  width: 7.5rem;
  justify-content: center;
}
.cc-copy .icon {
  width: 16px;
  height: 16px;
}

.cc-all {
  display: inline-block;
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-decoration: none;
}
.cc-all:hover {
  color: var(--color-accent);
}

/* Hub: every format in a list */
.cc-input {
  margin-bottom: var(--space-6);
}
.cc-list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.cc-line {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.cc-fmt {
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.cc-line .field input {
  font-family: var(--font-mono);
}

@media (max-width: 680px) {
  .cc-card {
    padding: var(--space-4);
  }
  .cc-swatch {
    height: 8rem;
    margin-bottom: var(--space-4);
  }
  .cc-fields {
    grid-template-columns: minmax(0, 1fr);
  }
  .cc-copy {
    width: 7.5rem;
    padding: 0 var(--space-3);
  }
  .cc-line {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .cc-line .cc-fmt {
    grid-column: 1 / -1;
    margin-bottom: calc(var(--space-2) * -1);
  }
}

/* The palette base field takes hex, rgb() or oklch(), so the text keeps its case and has no # prefix */
#pg-field input[type="text"] {
  text-transform: none;
}
