/* Scoped styles for Hex ↔ RGB ↔ CMYK converter
   Based on pageonaut tool/card structure (.card, .tool-layout, .tool-panel, .small, .hint, .mono) */

.tool-color-converter {
  /* Card-Layout kommt von globalem .card; hier nur Feintuning */
}

/* Panel header tuning */
.tool-color-converter .tool-panel-header h2 {
  margin-bottom: 0.25rem;
}

.tool-color-converter .tool-panel-header .small {
  margin: 0;
}

/* Field groups */
.tool-color-converter .field-group {
  margin-bottom: 1rem;
}

.tool-color-converter .field-group:last-of-type {
  margin-bottom: 0.75rem;
}

.tool-color-converter label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.tool-color-converter .field-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.tool-color-converter .field-hint,
.tool-color-converter .field-hint-inline {
  opacity: 0.9;
}

.tool-color-converter input[type="text"],
.tool-color-converter input[type="number"] {
  font-size: 0.95rem;
  padding: 8px 10px;
}

/* Hex row with picker */
.tool-color-converter .field-row--hex {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

/* Hex input with # prefix */
.tool-color-converter .field-with-addon {
  display: inline-flex;
  align-items: stretch;
  width: 100%;
}

.tool-color-converter .field-prefix {
  padding: 0 0.55rem;
  border-radius: 12px 0 0 12px;
  border: 1px solid var(--border);
  border-right: none;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--bg);
}

.tool-color-converter .field-with-addon input[type="text"] {
  border-radius: 0 12px 12px 0;
  border-left: none;
}

/* Color input (native color picker) */
.tool-color-converter .color-input {
  width: 42px;
  min-width: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0;
  background: var(--elev);
  cursor: pointer;
}

.tool-color-converter .color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.tool-color-converter .color-input::-webkit-color-swatch {
  border-radius: 10px;
  border: none;
}

.tool-color-converter .color-input::-moz-color-swatch {
  border-radius: 10px;
  border: none;
}

/* Compact RGB/CMYK rows */
.tool-color-converter .field-row {
  display: grid;
  gap: 0.75rem;
}

.tool-color-converter .field-row--rgb {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-color-converter .field-row--cmyk {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tool-color-converter .field-mini label {
  margin-bottom: 0.15rem;
  font-size: 0.8rem;
}

.tool-color-converter .field-mini input[type="number"] {
  text-align: right;
}

/* Footnote */
.tool-color-converter .field-footnote {
  margin-top: 0.15rem;
}

/* Preview block */
.tool-color-converter .preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.tool-color-converter .color-swatch {
  position: relative;
  border-radius: 16px;
  min-height: 120px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.tool-color-converter .color-swatch::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: soft-light;
  background:
    radial-gradient(120% 120% at -10% -10%, rgba(255,255,255,0.32), transparent 50%),
    radial-gradient(120% 120% at 110% 110%, rgba(0,0,0,0.16), transparent 50%);
}

.tool-color-converter .color-swatch__tag {
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.9;
}

.tool-color-converter .color-swatch__sample {
  position: relative;
  z-index: 1;
  font-size: 2.1rem;
  font-weight: 600;
}

/* Color meta */
.tool-color-converter .color-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.tool-color-converter .color-meta__main {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 1rem;
}

.tool-color-converter .color-meta__sub {
  font-size: 0.86rem;
  color: var(--muted);
}

/* Shades */
.tool-color-converter .shade-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
}

.tool-color-converter .shade {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  font-size: 0.78rem;
}

.tool-color-converter .shade__color {
  border-radius: 10px;
  min-height: 30px;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.tool-color-converter .shade__label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Copy sections */
.tool-color-converter .copy-section {
  margin-top: 1rem;
}

.tool-color-converter .copy-section__title {
  margin: 0 0 0.4rem 0;
  font-size: 0.92rem;
}

.tool-color-converter .copy-section__hint {
  margin: 0 0 0.5rem 0;
}

.tool-color-converter .copy-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tool-color-converter .copy-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.84rem;
}

.tool-color-converter .copy-label {
  color: var(--muted);
}

.tool-color-converter .copy-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact buttons */
.tool-color-converter .btn-compact {
  padding: 5px 9px;
  font-size: 0.78rem;
  box-shadow: none;
}

/* Channel chips */
.tool-color-converter .channel-groups {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tool-color-converter .channel-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tool-color-converter .channel-chip {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--elev);
  padding: 4px 10px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}

.tool-color-converter .channel-chip__label {
  font-weight: 600;
  min-width: 1ch;
}

.tool-color-converter .channel-chip__value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

/* Accessibility / WCAG section */
.tool-color-converter .accessibility-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.tool-color-converter .field-group-contrast {
  margin-bottom: 0.8rem;
}

.tool-color-converter .contrast-preview {
  margin-top: 0.4rem;
  margin-bottom: 0.75rem;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tool-color-converter .contrast-preview__sample {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tool-color-converter .contrast-preview__text {
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1;
}

.tool-color-converter .contrast-preview__info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.tool-color-converter .contrast-preview__ratio {
  font-size: 0.95rem;
}

/* WCAG grid */
.tool-color-converter .wcag-grid {
  display: grid;
  gap: 0.35rem;
}

.tool-color-converter .wcag-row {
  display: grid;
  grid-template-columns: 1.2fr auto auto;
  align-items: center;
  gap: 0.4rem;
}

.tool-color-converter .wcag-label {
  color: var(--muted);
}

.tool-color-converter .wcag-result {
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}

/* Explicit green/red for clear status, unabhängig vom Theme */
.tool-color-converter .wcag-result--pass {
  background: #1b9e5a;
  border-color: #128447;
  color: #ffffff;
}

.tool-color-converter .wcag-result--fail {
  background: #d64242;
  border-color: #b23333;
  color: #ffffff;
  opacity: 0.95;
}

/* Copy feedback */
.tool-color-converter .copy-btn.is-copied,
.tool-color-converter .channel-chip.is-copied {
  border-color: color-mix(in oklab, var(--brand) 55%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--brand) 40%, transparent);
}

/* Tool explainer */
.tool-color-converter .tool-explainer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.tool-color-converter .tool-explainer__title {
  margin: 0 0 0.4rem 0;
  font-size: 0.98rem;
}

.tool-color-converter .tool-explainer__list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
}

.tool-color-converter .tool-explainer__list li + li {
  margin-top: 0.2rem;
}

/* Responsive */
@media (max-width: 880px) {
  .tool-color-converter .copy-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "value button"
      "label button";
  }

  .tool-color-converter .copy-label {
    grid-area: label;
  }

  .tool-color-converter .copy-value {
    grid-area: value;
  }

  .tool-color-converter .copy-row .btn-compact {
    grid-area: button;
  }

  .tool-color-converter .wcag-row {
    grid-template-columns: 1.1fr auto;
    grid-auto-flow: row;
    grid-template-rows: auto auto;
  }

  .tool-color-converter .wcag-row .wcag-result:last-child {
    justify-self: flex-start;
  }

  .tool-color-converter .contrast-preview {
    flex-direction: column;
    align-items: flex-start;
  }

  .tool-color-converter .contrast-preview__info {
    align-items: flex-start;
  }
}

/* Dark mode tweaks */
html[data-theme="dark"] .tool-color-converter .copy-value {
  border-style: solid;
}

html[data-theme="dark"] .tool-color-converter .channel-chip {
  color: #ffffff;
}

