@import url("./tokens.css");

/* =========================
   Pro UI Refresh (single page)
   ========================= */

* { box-sizing: border-box; }

/* Don’t force fixed height on scroll pages */
html, body { min-height: 100%; }

/* ut the background on html so it always paints the full scroll area */
html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;            /* extra safety */
  background: transparent;      /* important: don’t double-paint */

  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.45;
}


/* Shell */
.app-shell {
  max-width: var(--shell-max-wide);
  margin: 0 auto;
  padding: 24px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(14px);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 86%, transparent), color-mix(in srgb, var(--bg) 55%, transparent));
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--accent);
  box-shadow: none;
  border: 1px solid rgba(255,255,255,0.18);
}

.brand-text h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: 0.2px;
}

.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding-top: 22px;
}

/* Cards */
.section.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  overflow: hidden;
}

.card-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.card-head .muted {
  margin: 6px 0 14px;
}

/* Footer */
.app-footer {
  padding: 20px 0 10px;
  text-align: center;
}

/* Text */
.muted { color: var(--muted); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  color: rgba(255,255,255,0.86);
}

/* Inputs */
.input-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.input-field.stacked {
  flex-direction: column;
  align-items: stretch;
}

label {
  font-size: 13px;
  color: rgba(255,255,255,0.78);
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10, 11, 14, 0.55);
  color: rgba(255,255,255,0.92);
  outline: none;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}

input:focus, select:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 3px var(--focus);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.70) 50%),
    linear-gradient(135deg, rgba(255,255,255,0.70) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* Color row grid */
.input-field.color-row {
  display: grid;
  grid-template-columns: 120px 44px 1fr;
  align-items: center;
  gap: 12px;
}

/* Swatches */
.swatch {
  width: 44px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: none;
  cursor: pointer;
  position: relative;
  background: #000;
  transition: transform .08s, box-shadow .15s, border-color .15s;
}

.swatch:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.26);
  box-shadow: none;
}

.swatch:active { transform: translateY(0px); }

.swatch::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
  pointer-events: none;
}

.input-field.color-row input.hex {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.2px;
}

.input-field.color-row input.hex.invalid {
  border-color: rgba(239,68,68,0.8);
  box-shadow: 0 0 0 3px var(--danger);
}

/* Force Pickr's visible button to actually show the chosen colour */
.pickr .pcr-button {
  background: var(--pcr-color) !important;
  background-color: var(--pcr-color) !important;
}

/* Helper pill */
.helper-row { margin-top: 12px; }
.helper-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.74);
  font-size: 12px;
}

/* Preview */
.preview {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(10, 11, 14, 0.45);
  padding: 18px;
  text-align: center;
  margin-bottom: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

/* Results card spans full width */
.results-card { grid-column: 1 / -1; }
.result-block { padding-top: 6px; }

/* ===== Updated compact results ===== */

/* Ratio header strip */
.ratio-header {
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.10);
  font-weight: 650;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ratio-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ratio-header span {
  font-weight: 850;
  font-size: 18px;
  letter-spacing: 0.2px;
}

/* Mode summary badge */
.mode-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.88);
  white-space: nowrap;
}

.mode-badge.good { background: rgba(34,197,94,0.22); border-color: rgba(34,197,94,0.35); }
.mode-badge.ok   { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: color-mix(in srgb, var(--accent) 32%, transparent); }
.mode-badge.bad  { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.32); }
.mode-badge.neutral { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.14); }

/* Tile grid */
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
  align-items: stretch;
}

.result-item {
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  font-size: 13px;
}

.result-item div:last-child {
  margin-top: 6px;
  font-weight: 650;
  color: rgba(255,255,255,0.88);
}

/* Status circle */
.status {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: rgba(255,255,255,0.95);
  font-weight: 900;
  margin-bottom: 6px;
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: none;
}

.pass { background: rgba(34,197,94,0.85); }
.fail { background: rgba(239,68,68,0.85); }

/* Tooltip */
.tooltip-container {
  position: relative;
  cursor: help;
}

.tooltip-container:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  background: rgba(6, 8, 16, 0.95);
  color: rgba(255,255,255,0.92);
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: none;
  width: max-content;
  max-width: 320px;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  z-index: 10;
}


.btn {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10, 11, 14, 0.55);
  color: rgba(255,255,255,0.92);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.26);
}

.btn:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 3px var(--focus);
}

.toast {
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .15s, transform .15s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Tooltip: show on keyboard focus too */
.tooltip-container:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  background: rgba(6, 8, 16, 0.95);
  color: rgba(255,255,255,0.92);
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: none;
  width: max-content;
  max-width: 320px;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  z-index: 10;
}

.tooltip-container:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
  border-radius: var(--radius);
}



/* Controls */
.controls {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.control-group.actions {
  gap: 10px;
}

/* Export row (Copy CSS lives in left panel now) */
.control-group.export {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-group.export .btn {
  white-space: nowrap;
}

.control-group.export .toast {
  flex: 1;
  min-height: 1em; /* stops layout jump when toast appears */
}

.control-label {
  font-size: 12px;
  color: rgba(255,255,255,0.74);
  margin-right: 4px;
}

.seg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: transform .08s, border-color .15s, box-shadow .15s;
}

.seg:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.22);
}

.seg input {
  width: auto;
  padding: 0;
  margin: 0;
  accent-color: var(--primary);
}

.btn.secondary {
  background: rgba(0,0,0,0.18);
}

/* Preview: richer UI block */
.preview-stack {
  width: 100%;
  display: grid;
  gap: 10px;
}

.preview-title {
  font-weight: 800;
  letter-spacing: 0.2px;
  opacity: 0.92;
}

.preview-body {
  font-size: 18px;
  font-weight: 700;
}

.preview-small {
  font-size: 12px;
  opacity: 0.85;
}

.preview-ui {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2px;
}

.ui-btn {
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: rgba(0,0,0,0.14);
  color: inherit;
  cursor: pointer;
  font-weight: 700;
}

.ui-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 650;
}

.ui-chip {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.12);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

/* Results: meta lines + active highlight */
.result-meta {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.74);
  display: grid;
  gap: 4px;
}

.meta-line {
  opacity: 0.9;
}

.meta-delta {
  font-weight: 750;
  letter-spacing: 0.1px;
}

.meta-delta.ok { color: rgba(34,197,94,0.92); }
.meta-delta.no { color: rgba(239,68,68,0.92); }

.result-item.active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 0 0 3px var(--focus);
}

/* ===== Embed Mode ===== */
html.embed body {
  background: var(--bg);
}

html.embed .app-header,
html.embed .app-footer {
  display: none;
}

html.embed .app-shell {
  max-width: 1100px;
  padding: 12px;
}

html.embed .layout {
  padding-top: 12px;
}

html.embed .app-header {
  position: static;
}

/* Mobile */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .input-field.color-row { grid-template-columns: 110px 44px 1fr; }
}

@media (max-width: 520px) {
  .control-group.export {
    flex-direction: column;
    align-items: stretch;
  }

  .control-group.export .toast {
    text-align: center;
  }
}

