/* =========================================================================
   COFFEEHOUSE, native Error-Handling + Style Guide (CoffeeHouse brand)
   prefix: cberr / cbf / cbnote / sg
   ========================================================================= */

:root { --ch-navy: #003566; --ch-yellow: #FFD60A; --ch-grey: #E0E0E0; }

/* ---- yellow sticky note (shared) --------------------------------------- */
.cbnote {
  position: relative; align-self: center; justify-self: center;
  max-width: 230px; padding: 16px 18px;
  font-family: var(--display); font-weight: 600; font-size: 14px; line-height: 1.32;
  transform: rotate(var(--rot, -2deg));
  box-shadow: 0 14px 28px rgba(0,0,0,.4), 0 2px 0 rgba(0,0,0,.12);
}
.cbnote--y { background: #FFD60A; color: rgba(0,0,0,.78); }
.cbnote--navy { background: #003566; color: #fff; }
/* tape */
.cbnote::before {
  content: ''; position: absolute; top: -9px; left: 50%; transform: translateX(-50%) rotate(2deg);
  width: 56px; height: 17px; background: rgba(255,255,255,.22);
  border-left: 1px dashed rgba(0,0,0,.12); border-right: 1px dashed rgba(0,0,0,.12);
}
.cbnote--navy::before { background: rgba(255,214,10,.3); }

/* ---- ERROR HANDLING ---------------------------------------------------- */
.cberr { margin-top: 6px; }
.cberr__legend { display: flex; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.cberr__leg { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.cberr__leg::before { content: ''; width: 10px; height: 10px; border-radius: 3px; }
.cberr__leg--e::before { background: var(--ink-4); }
.cberr__leg--v::before { background: var(--ch-yellow); }
.cberr__leg--i::before { background: #ff5a52; }

.cberr__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(14px, 1.8vw, 22px); align-items: start; min-width: 0; }
@media (max-width: 1024px) { .cberr__grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .cberr__grid { grid-template-columns: 1fr; } .cbnote { max-width: 100%; } }

/* field card, transparent, sits on dark page */
.cbf { display: flex; flex-direction: column; gap: 9px; }
.cbf__label { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }
.cbf__row {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: #f4f2ec; border-radius: 12px; padding: 13px 15px; min-height: 50px;
  box-shadow: 0 1px 0 rgba(0,0,0,.3);
}
.cbf__val { flex: 1; font-family: 'Kanit', var(--display); font-size: 14px; font-weight: 500; letter-spacing: .01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbf__ico { flex: none; display: flex; }
.cbf__err { font-family: 'Kanit', var(--display); font-size: 10px; font-weight: 600; color: #d11; white-space: nowrap; }

/* states */
.cbf__row--empty { background: #ececec; }
.cbf__row--empty .cbf__val { color: #9a9a9a; }
.cbf__row--empty .cbf__ico { color: #b4b4b4; }

.cbf__row--valid .cbf__val { color: var(--ch-navy); }
.cbf__row--valid .cbf__ico { color: var(--ch-yellow); }

.cbf__row--invalid { background: #fff; box-shadow: 0 0 0 1.5px #f0b4b0, 0 1px 0 rgba(0,0,0,.3); }
.cbf__row--invalid .cbf__val { color: #d11; }
.cbf__row--invalid .cbf__ico { color: #e5484d; }

/* ---- STYLE GUIDE ------------------------------------------------------- */
.sg { position: relative; margin-top: 6px; background: #fbfaf7; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sg__bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; background: var(--ch-navy); }
.sg__brand { font-family: 'Kanit', var(--display); font-weight: 600; font-size: 14px; color: #fff; letter-spacing: .02em; }
.sg__switch { display: inline-flex; gap: 3px; padding: 3px; background: rgba(255,255,255,.12); border-radius: 999px; }
.sg__sw { font-family: var(--mono); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; padding: 6px 12px; border-radius: 999px; color: rgba(255,255,255,.7); }
.sg__sw.is-on { background: var(--ch-yellow); color: #000; }

.sg__body { padding: clamp(20px, 3vw, 36px); display: grid; gap: clamp(22px, 3vw, 36px); }
.sg__block { position: relative; }
.sg__h { display: inline-block; font-family: 'Kanit', var(--display); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--ch-navy); padding-bottom: 6px; border-bottom: 2px solid var(--ch-yellow); margin-bottom: 16px; }

/* type specimen */
.sg__type { position: relative; }
.sg__specimen { display: flex; flex-direction: column; gap: 12px; }
.sg__line { display: grid; grid-template-columns: 88px 1fr; align-items: baseline; gap: 16px; border-bottom: 1px solid #efede8; padding-bottom: 11px; }
.sg__wt { font-family: 'Kanit', var(--display); font-weight: 600; font-size: 13px; color: #6a6a6a; }
.sg__chars { font-family: 'Kanit', var(--display); color: var(--ch-navy); line-height: 1; overflow: hidden; min-width: 0; }
.sg__chars--lc { font-weight: 400; font-size: clamp(15px, 1.7vw, 22px); letter-spacing: .04em; }
.sg__chars--m { font-weight: 500; font-size: clamp(14px, 1.6vw, 21px); letter-spacing: .03em; }
.sg__chars--sb { font-weight: 600; font-size: clamp(15px, 1.7vw, 22px); letter-spacing: .06em; }
.sg__aa { position: absolute; top: -6px; right: 6px; font-family: 'Kanit', var(--display); font-weight: 600; font-size: 64px; color: var(--ch-navy); line-height: 1; display: none; }

/* color swatches */
.sg__swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(10px, 1.4vw, 18px); }
@media (max-width: 560px) { .sg__swatches { grid-template-columns: repeat(2, 1fr); } }
.sg__sw-card { display: flex; flex-direction: column; gap: 8px; }
.sg__chip { aspect-ratio: 1; max-height: 180px; border-radius: 12px; display: flex; align-items: center; justify-content: center; padding: 22%; }
.sg__bean { width: 100%; height: 100%; }
.sg__hex { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--ch-navy); }
.sg__role { font-family: 'Kanit', var(--display); font-size: 11px; color: #8a8a8a; }

/* spacing + radius */
.sg__spacerow, .sg__radrow { display: flex; gap: clamp(14px, 2vw, 26px); align-items: flex-end; flex-wrap: wrap; }
.sg__radrow { margin-top: 18px; }
.sg__spaceitem, .sg__raditem { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sg__spacebox { background: var(--ch-yellow); border-radius: 3px; }
.sg__radbox { width: 46px; height: 46px; background: var(--ch-navy); }
.sg__spacelbl { font-family: var(--mono); font-size: 11px; color: #8a8a8a; }

/* buttons */
.sg__btnrow { display: flex; flex-wrap: wrap; gap: 12px; }
.sg__btn { font-family: 'Kanit', var(--display); font-weight: 600; font-size: 14px; padding: 11px 20px; border-radius: 10px; }
.sg__btn--primary { background: var(--ch-navy); color: #fff; }
.sg__btn--secondary { background: var(--ch-yellow); color: #1a1206; }
.sg__btn--ghost { background: transparent; border: 1.5px solid var(--ch-navy); color: var(--ch-navy); }
.sg__btn--disabled { background: var(--ch-grey); color: #9a9a9a; }

/* sticky note on the guide */
.sg__note { position: absolute; right: 18px; bottom: 16px; max-width: 200px; font-size: 12.5px; z-index: 4; }
@media (max-width: 700px) { .sg__note { position: static; margin: 18px auto 4px; } }

/* ---- VARIANT: SWATCH (color-forward, big chips) ------------------------ */
.sg--swatch .sg__body { grid-template-areas: 'color' 'type' 'space' 'btns'; }
.sg--swatch .sg__color { order: -1; }
.sg--swatch .sg__chip { border-radius: 50%; }
.sg--swatch .sg__swatches { gap: clamp(14px, 2vw, 26px); }

/* ---- VARIANT: SPECIMEN (type-forward, giant Aa) ------------------------ */
.sg--specimen .sg__aa { display: block; }
.sg--specimen .sg__type { order: -1; padding-right: 90px; }
.sg--specimen .sg__chars--lc, .sg--specimen .sg__chars--m, .sg--specimen .sg__chars--sb { font-size: clamp(16px, 2vw, 26px); }
