/* ============================================================
   pages.css — 各畫面專屬樣式

   一個區塊對應一個畫面，順序跟 index.html 一樣：
     1. 調色
     2. 反查
     3. 漆櫃
   ============================================================ */


/* ============================================================
   1. 調色
   ============================================================ */

/* 大結果色塊。背景色由 js/mix.js 設。 */
.result {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 18px;
  min-height: 186px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.rformula {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.85;
  word-break: break-word;
}

.rbottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.rhex {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: .06em;
}

.rname {
  font-family: var(--serif);
  font-size: 15px;
  opacity: .85;
}


/* 配方裡的一列顏料 */

.mixrow {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.mixrow:last-of-type { border-bottom: 0; }

.mrtop {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.mrtop .sw {
  width: 22px;
  height: 22px;
}

.mrtop .nm {
  flex: 1;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mrtop .pct {
  font-family: var(--mono);
  font-size: 17px;
  min-width: 52px;
  text-align: right;
}


/* ============================================================
   2. 反查
   ============================================================ */

/* 目標色預覽 */
.target {
  height: 130px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .12);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 10px;
}

.target code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
}


/* 照片與取色點 */

canvas {
  width: 100%;
  border-radius: 8px;
  display: block;
  touch-action: none;
  background: #1A1B1E;
}

.cwrap      { display: none; }
.cwrap.on   { display: block; }

.picker {
  position: relative;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.picker.dragging { cursor: grabbing; }

.marker {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* 準心圓環 */
.ring {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .55),
              inset 0 0 0 1.5px rgba(0, 0, 0, .55);
}

.ring::before,
.ring::after {
  content: '';
  position: absolute;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
}

.ring::before {
  left: 50%;
  top: 50%;
  width: 1px;
  height: 9px;
  transform: translate(-50%, -50%);
}

.ring::after {
  left: 50%;
  top: 50%;
  width: 9px;
  height: 1px;
  transform: translate(-50%, -50%);
}

/* 準心上方的色碼氣泡 */
.bubble {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(18, 19, 21, .92);
  border-radius: 20px;
  padding: 4px 10px 4px 4px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}

.bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(18, 19, 21, .92);
}

.bdot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .32);
  flex-shrink: 0;
}

.bhex {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #fff;
  letter-spacing: .05em;
}

.pickhint {
  font-size: 12px;
  color: var(--faint);
  margin-top: 8px;
  text-align: center;
}

.pickhint.armed { color: var(--gold); }


/* 反查結果 */

.res {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

/* 第一組配方上面不要分隔線。
   用 first-of-type 不是 first-child，因為 #out 的第一個元素是那行
   說明文字（<p>），第一組配方已經不是 first-child 了。 */
.res:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.rhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.rank {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: .1em;
}

.de {
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
}


/* 目標色與調出來的顏色並排比較。
   兩塊直接貼在一起、中間不留縫也不畫線 —— 眼睛對「一條邊兩邊不一樣」
   遠比對「隔開的兩塊有點不一樣」敏感。看不到接縫就是調對了。 */

.compare {
  margin-bottom: 13px;
}

.compare-swatches {
  display: flex;
  height: 78px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
}

.compare-swatches b {
  display: block;
  flex: 1;
}

.compare-labels {
  display: flex;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--faint);
}

.compare-labels span { flex: 1; }
.compare-labels span:last-child { text-align: right; }


/* 差在哪：明度／彩度／色相三條軸。
   中線代表「跟目標一樣」，點往哪邊偏就是往哪個方向差。 */

.diff {
  display: grid;
  grid-template-columns: auto minmax(48px, 1fr) auto;
  gap: 8px 10px;
  align-items: center;
  margin-bottom: 14px;
}

.diff-name {
  font-size: 12.5px;
  color: var(--dim);
}

.diff-track {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--hi);
}

/* 中線 */
.diff-track::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--line);
}

.diff-mark {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--faint);
}

/* 看得出來的差異才用亮色喊，看不出來的留暗色，眼睛才知道要看哪一條 */
.diff-mark.visible { background: var(--gold); }

.diff-text {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  text-align: right;
  white-space: nowrap;
}

.diff-text.visible { color: var(--ink); }

/* 配方比例條 */
.bar {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14);
  margin-bottom: 11px;
}

.bar i {
  display: block;
  height: 100%;
}

/* 配方裡的一行 */
.fl {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px 0;
}

.fl .dot {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, .22);
  flex-shrink: 0;
}

.fl .fn {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fl .fp {
  font-family: var(--mono);
  font-size: 16px;
  min-width: 56px;
  text-align: right;
}

/* 少於 5%：顯示「少々」而不是數字 */
.fl.sukoshi .fp {
  color: var(--gold);
  font-size: 14px;
}


/* ============================================================
   3. 漆櫃
   ============================================================ */

/* 漆櫃裡的一罐漆 */
.pl {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 2px;
  border-radius: 6px;
}

.pl:hover { background: var(--hi); }

.pl .sw {
  width: 26px;
  height: 26px;
  border-color: rgba(255, 255, 255, .18);
}

.pl .nm {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 色卡校正的照片：點一下取色 */
#cardCv { cursor: crosshair; }
