/* 대시보드 타일 (홈·농가 화면). 2026-11-11 흑(벤토)·백(클래식) 두 UI를 하나로 합침.
 *
 * 색·글꼴·표·폼은 app.css(백) 토큰을 그대로 쓰고, 여기서는 흑 버전의 타일 언어
 * (강조색 틴트, 큰 숫자+단위, 진행 막대, 스파크라인, 히어로 타일)만 얹는다.
 * 강조색(--acc-*)은 흰 바탕에서 글자 대비 4.5:1 이상이 되도록 진하게 잡고, 다크 모드에서는 밝게 바꾼다.
 */
:root {
  --mono-accent: var(--mono);
  --acc-teal: #0f6b45;    --acc-teal-bg: #eaf5ef;
  --acc-pink: #b0245f;    --acc-pink-bg: #fcedf3;
  --acc-orange: #9a4a00;  --acc-orange-bg: #fdf1e4;
  --acc-blue: #1d4f91;    --acc-blue-bg: #e9f0fb;
  --acc-violet: #5b3aa6;  --acc-violet-bg: #f1ecfb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --acc-teal: #3ddc97;    --acc-teal-bg: rgba(61, 220, 151, .10);
    --acc-pink: #ff5c9e;    --acc-pink-bg: rgba(255, 92, 158, .10);
    --acc-orange: #ff9d4d;  --acc-orange-bg: rgba(255, 157, 77, .10);
    --acc-blue: #5b9dff;    --acc-blue-bg: rgba(91, 157, 255, .10);
    --acc-violet: #b18bff;  --acc-violet-bg: rgba(177, 139, 255, .10);
  }
}

/* ------------------------------------------------------------ 그리드 */
.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 20px;
  align-items: stretch;
}
.bento > * { min-width: 0; }

.bento .t-1x1 { grid-column: span 1; }
.bento .t-2x1 { grid-column: span 2; }
.bento .t-4x1 { grid-column: span 4; }
.bento .t-2x2 { grid-column: span 2; grid-row: span 2; }

@media (max-width: 1099px) {
  .bento { grid-template-columns: repeat(2, 1fr); }
  .bento .t-2x1, .bento .t-2x2, .bento .t-4x1 { grid-column: span 2; }
  .bento .t-2x2 { grid-row: span 1; }
}
@media (max-width: 639px) {
  .bento { grid-template-columns: 1fr; gap: 16px; }
  .bento .t-1x1, .bento .t-2x1, .bento .t-2x2, .bento .t-4x1 { grid-column: span 1; grid-row: span 1; }
}

/* ------------------------------------------------------------ 타일 기본 */
.tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  overflow: hidden;
}
.tile.t-2x2 { justify-content: flex-start; gap: 12px; padding: 30px 30px 28px; }
.tile.t-4x1 { justify-content: flex-start; overflow: hidden; }
/* 표·카드가 타일의 "직속 자식"으로 바로 오면(홈 화면의 농가 표처럼) 여백을 없애 표가 타일에 꽉 차게 만든다.
   화면 상세(farm.html)처럼 <section> 안에 표·카드·제목이 함께 있는 경우는 이 규칙이 걸리지 않아
   다른 타일과 같은 기본 여백(28px 30px)을 그대로 받는다 — section 안 h2·설명 문구가 타일 테두리에
   바로 붙어버리는 문제(패딩 0이 전부 적용됨)를 막기 위함. */
.tile.t-4x1:has(> .scroll), .tile.t-4x1:has(> .card) { padding: 0; }
.tile.t-4x1 > .scroll { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.tile.t-4x1 > .card { margin: 0; border: 0; box-shadow: none; }

.tile a.tile-link { color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: 6px; height: 100%; justify-content: center; }
.tile a.tile-link:hover .big { color: var(--acc, var(--accent-hover)); }
.tile a.tile-link:focus-visible { outline: 3px solid var(--acc, var(--accent)); outline-offset: 3px; border-radius: 12px; }

/* 강조색 — 채워진(틴트 배경) 타일 */
.tile.acc-teal   { --acc: var(--acc-teal);   --acc-bg: var(--acc-teal-bg); }
.tile.acc-pink   { --acc: var(--acc-pink);   --acc-bg: var(--acc-pink-bg); }
.tile.acc-orange { --acc: var(--acc-orange); --acc-bg: var(--acc-orange-bg); }
.tile.acc-blue   { --acc: var(--acc-blue);   --acc-bg: var(--acc-blue-bg); }
.tile.acc-violet { --acc: var(--acc-violet); --acc-bg: var(--acc-violet-bg); }

.tile[class*="acc-"]:not(.outline) { background: var(--acc-bg); border-color: color-mix(in srgb, var(--acc) 30%, var(--line)); }

/* 윤곽선만(outline) 변형 — 채우지 않고 테두리를 더 밝게 */
.tile.outline { background: var(--surface); border: 1px solid color-mix(in srgb, var(--acc, var(--line-strong)) 55%, var(--line)); }

.tile.t-warn { border-color: var(--warn); }
.tile.t-bad { border-color: var(--bad); }
.tile.t-ok { border-color: var(--ok); }

/* ------------------------------------------------------------ 타일 헤더 (라벨 + 아이콘) */
.tile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.t-label {
  color: var(--acc, var(--muted));
  font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.t-icon { width: 22px; height: 22px; flex: none; color: var(--acc, var(--muted)); }

/* ------------------------------------------------------------ 큰 숫자 */
.big {
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  margin-top: 10px;
}
.big .unit { font-size: 1rem; font-weight: 700; color: var(--acc, var(--muted)); margin-left: 6px; vertical-align: middle; }
.big.small { font-size: 1.6rem; margin-top: 6px; }
/* 1칸 타일은 폭이 좁아 큰 숫자 뒤 단위가 다음 줄로 넘어간다 → 숫자를 조금 줄이고 한 줄로 */
.bento .t-1x1 .big:not(.small) { font-size: clamp(1.9rem, 2.6vw, 2.6rem); white-space: nowrap; }
.cap { color: var(--muted); font-size: .84rem; }

/* ------------------------------------------------------------ 진행 막대 */
.bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.bar-track { flex: 1; height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--acc, var(--line-strong)) 18%, var(--line)); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--acc, var(--accent)); min-width: 4px; }
.bar-pct { font-size: .82rem; font-weight: 700; color: var(--acc, var(--muted)); font-variant-numeric: tabular-nums; flex: none; }

/* ------------------------------------------------------------ 스파크라인(작은 막대 히스토그램) */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; margin-top: 10px; }
.spark span { flex: 1; min-height: 3px; border-radius: 3px 3px 1px 1px; background: var(--acc, var(--accent)); opacity: .85; }
.spark.flat span { opacity: .35; }

/* ------------------------------------------------------------ 히어로 타일 */
.tile.hero { justify-content: flex-start; }
.hero-badge {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--acc-bg); color: var(--acc); border: 1px solid color-mix(in srgb, var(--acc) 40%, var(--line));
  margin-bottom: 14px;
}
.hero-badge svg { width: 22px; height: 22px; }
.kicker { font-family: var(--mono-accent); font-size: .74rem; font-weight: 600; letter-spacing: .06em;
          color: var(--acc); text-transform: uppercase; margin-bottom: 6px; }
.hero h1 {
  font-weight: 800;
  font-size: clamp(1.9rem, 3.6vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: -.01em;
  margin: 0 0 12px;
  color: var(--fg);
}
.hero p { color: var(--muted); font-size: .96rem; line-height: 1.6; margin: 0 0 16px; max-width: 46ch; }
.hero-status { font-size: .86rem; font-weight: 700; color: var(--acc); margin: 0 0 18px; }
.hero-status .n { font-family: var(--mono-accent); }
.cta {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  background: var(--acc); color: var(--surface); font-weight: 700; font-size: .92rem;
  padding: 12px 20px; border-radius: 999px; text-decoration: none; border: 0;
}
.cta:hover { background: color-mix(in srgb, var(--acc) 85%, var(--fg)); color: var(--surface); }
.cta:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }
.cta svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------ 하위 카드 두 개(sub-cards) */
.sub-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; margin-top: 8px; }
.sub-card {
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 18px 20px;
}
@media (max-width: 520px) { .sub-cards { grid-template-columns: 1fr; } }

/* 타일 안 목록(막힌 항목 등) */
.tile .t-block-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tile .t-block-list li a { display: flex; justify-content: space-between; gap: 8px; text-decoration: none; color: var(--fg);
  font-size: .92rem; }
.tile .t-block-list li a:hover { color: var(--acc, var(--accent-hover)); }

/* 상태 표기용 작은 필 (계수 확인됨/가정치) — 기존 .pill과 같이 쓸 수 있게 여백만 보정 */
.coef-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* 7단계 세그먼트 진행 막대 (농가 상세 "MRV 진행 단계") */
.seg-bar { display: flex; gap: 6px; margin-top: 14px; }
.pseg { flex: 1; height: 10px; border-radius: 6px; background: color-mix(in srgb, var(--acc, var(--line-strong)) 18%, var(--line)); }
.pseg.done { background: var(--acc, var(--accent)); }
.pseg.warn { background: var(--warn); }
.seg-labels { display: flex; justify-content: space-between; gap: 4px; margin-top: 8px; }
.seg-labels span { font-size: .68rem; color: var(--muted); flex: 1; text-align: center; }
.seg-labels span.done { color: var(--acc, var(--accent)); font-weight: 700; }

/* 단계별 완료 조건·산출물 (MRV 진행 단계 타일 안 목록) */
.step-compact-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.step-compact-list li { border-left: 3px solid var(--line-strong); background: var(--sunken);
  border-radius: var(--radius-sm); padding: 8px 10px; }
.step-compact-list li.done { border-left-color: var(--acc, var(--accent)); }
.step-compact-list li.now { border-left-color: var(--acc, var(--accent)); box-shadow: inset 0 0 0 1px var(--acc, var(--accent)); }
.step-compact-list li.warn { border-left-color: var(--warn); }
.step-compact-list .sc-title { font-size: .85rem; font-weight: 700; margin-bottom: 2px; }
.step-compact-list .sc-cond, .step-compact-list .sc-out, .step-compact-list .sc-next { font-size: .72rem; color: var(--muted); }
.step-compact-list .sc-out a { color: var(--fg); }
.step-compact-list .sc-next { color: var(--acc, var(--accent)); font-weight: 600; margin-top: 2px; }

@media print {
  .bento { display: block; }
  .tile { box-shadow: none; break-inside: avoid; margin-bottom: 10px; }
}
