/* 대구 기상상황판 — dash/rain.dgsafe.kr 계열(흰 카드 · LED 특보판)과 같은 문법
 * 1200px 이상: 스크롤 없는 한 화면 상황판(3열). 그 미만: 세로로 쌓아 스크롤. */
:root {
    --ink: #17202e;
    --sub: #657183;
    --paper: #eef1f4;
    --card: #ffffff;
    --line: #dfe4ea;
    --accent: #1f5fbf;
    --led: #0e1320;
    --t-cold: #3b6fd8;
    --t-hot: #d8452b;
    --num: 'Barlow Condensed', 'Noto Sans KR', sans-serif;
    --radius: 12px;
    --gap: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--paper);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--sub); }
.small { font-size: 12px; }

/* ── 헤더 ── */
.top {
    display: flex; align-items: center; gap: 24px;
    background: var(--card);
    padding: 9px 20px;
    box-shadow: 0 1px 0 var(--line), 0 2px 10px rgba(23, 32, 46, .05);
    position: relative; z-index: 1000;
}
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.brand-sub { color: var(--sub); font-size: 13px; }
.led {
    flex: 1 1 0; min-width: 0; height: 46px;
    background: var(--led); border-radius: 10px;
    overflow: hidden; position: relative;
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, .65);
}
.led-msg {
    height: 46px; line-height: 46px; white-space: nowrap;
    font-family: 'Consolas', 'D2Coding', 'Menlo', monospace;
    font-size: 21px; font-weight: 700;
    position: absolute; left: 18px; right: 18px; overflow: hidden; text-overflow: ellipsis;
    transition: opacity .5s, transform .5s;
}
.led-msg.out { opacity: 0; transform: translateY(-10px); }
.led-msg.lvl0 { color: #6b7891; }
.led-msg.lvl1 { color: #5dd86a; text-shadow: 0 0 6px rgba(93, 216, 106, .55); }
.led-msg.lvl2 { color: #ffd54a; text-shadow: 0 0 6px rgba(255, 213, 74, .55); }
.led-msg.lvl3 { color: #ffa726; text-shadow: 0 0 7px rgba(255, 167, 38, .65); }
.led-msg.lvl4 { color: #ff5252; text-shadow: 0 0 9px rgba(255, 82, 82, .8); }
.top-meta { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.clock { font-family: var(--num); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.top-links { display: flex; gap: 6px; }
.top-links a {
    font-size: 13px; text-decoration: none; padding: 5px 11px;
    border: 1px solid var(--line); border-radius: 999px; color: var(--ink);
}
.top-links a:hover { border-color: var(--accent); color: var(--accent); }

.stale {
    margin: var(--gap) 16px 0; padding: 8px 14px; border-radius: 10px;
    background: #fff4e0; border: 1px solid #f3d29a; color: #8a5a00; font-size: 13px;
}

/* ── 보드 ── */
.board { display: grid; gap: var(--gap); padding: var(--gap) 16px; }
.col { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; min-height: 0; }
.card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(23, 32, 46, .06), 0 4px 16px rgba(23, 32, 46, .04);
    padding: 12px 14px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-foot { margin-top: 6px; font-size: 11px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-head { font-size: 12px; font-weight: 700; color: var(--sub); margin: 12px 0 4px; }
.eyebrow { font-size: 14px; font-weight: 700; }

.seg { display: inline-flex; background: var(--paper); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button {
    border: 0; background: none; cursor: pointer;
    padding: 3px 10px; border-radius: 6px; font-size: 12px; color: var(--sub);
}
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* ── 지금 대구 ── */
.now { display: flex; flex-direction: column; gap: 4px; }
.now-main { display: flex; align-items: center; gap: 12px; }
.now-icon svg { width: 64px; height: 64px; }
.now-temp {
    font-family: var(--num); font-weight: 600; font-size: 84px; line-height: .95;
    letter-spacing: -2px; font-variant-numeric: tabular-nums;
}
.now-temp small { font-size: 28px; font-weight: 500; letter-spacing: 0; margin-left: 2px; color: var(--sub); }
.now-desc { font-size: 14px; }
.now-desc b { font-weight: 700; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.facts div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.facts dt { color: var(--sub); font-size: 12px; white-space: nowrap; }
.facts dd { font-family: var(--num); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.facts dd small { font-family: 'Noto Sans KR', sans-serif; font-size: 11px; font-weight: 400; color: var(--sub); margin-left: 2px; }

/* ── 기온 흐름 ── */
.flow { display: flex; flex-direction: column; }
.legend { font-size: 12px; color: var(--sub); display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 3px solid #f0a020; margin-left: 8px; }
.legend .lg-fc { border-top-style: dashed; border-top-width: 2px; }
.legend .lg-pop { height: 9px; border: 0; background: rgba(31, 95, 191, .25); width: 9px; }
.chart { position: relative; flex: 1; min-height: 200px; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart .axis { font-family: var(--num); font-size: 13px; fill: var(--sub); }
.chart .day-label { font-size: 12px; fill: var(--ink); font-weight: 700; }
.chart .now-label { font-size: 12px; fill: var(--ink); font-weight: 700; }
.tip {
    position: absolute; pointer-events: none; transform: translate(-50%, -100%);
    background: var(--ink); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap;
}
.tip b { font-family: var(--num); font-size: 15px; }

/* ── 지도 ── */
.map { height: 340px; border-radius: 10px; overflow: hidden; background: #e6ebf0; }
.plot {
    display: flex; align-items: center; gap: 3px;
    background: #fff; border-radius: 999px; padding: 2px 7px 2px 3px;
    box-shadow: 0 1px 4px rgba(23, 32, 46, .3); white-space: nowrap; transform: translate(-50%, -50%);
    position: absolute; left: 0; top: 0;
}
.plot .dot { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; }
.plot .dot svg { width: 14px; height: 14px; }
.plot .v { font-family: var(--num); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plot .v small { font-size: 11px; font-weight: 500; margin-left: 1px; }
.plot .n { font-size: 11px; color: var(--sub); display: none; }
.show-names .plot .n { display: inline; }
.leaflet-div-icon.plot-icon { background: none; border: 0; }
.leaflet-tooltip { font-family: 'Noto Sans KR', sans-serif; font-size: 12px; }

/* ── 관측표 ── */
.table-wrap { overflow: auto; }
table.obs { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.obs th {
    position: sticky; top: 0; background: var(--card);
    white-space: nowrap; font-size: 11px; font-weight: 500; color: var(--sub); text-align: right;
    padding: 4px 6px; border-bottom: 1px solid var(--line); line-height: 1.2;
}
.obs th:first-child, .obs td:first-child { text-align: left; }
.obs td { padding: 3px 6px; border-bottom: 1px solid #f0f2f5; text-align: right; white-space: nowrap; font-size: 13px; }
.obs td.num { font-family: var(--num); font-size: 16px; font-weight: 600; }
.obs .stn { font-weight: 500; }
.obs .stn small { color: var(--sub); font-size: 11px; margin-left: 4px; }
.obs tr.main td { background: #f5f8fc; }
.obs .zero { color: #b3bcc8; }
.obs .rain { color: var(--accent); }
.obs .wind { display: inline-flex; align-items: center; gap: 3px; }
.obs .wind svg { width: 13px; height: 13px; }
.ext { font-size: 10px; font-weight: 700; padding: 0 3px; border-radius: 4px; margin-left: 3px; vertical-align: 2px; font-family: 'Noto Sans KR', sans-serif; }
.ext.hi { background: #fde6e1; color: var(--t-hot); }
.ext.lo { background: #e3ecfb; color: var(--t-cold); }

/* ── 시간별 예보 ── */
.hourly { display: flex; overflow-x: auto; scroll-snap-type: x proximity; }
.hr {
    flex: 1 0 54px; display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 2px 0; border-left: 1px solid #f0f2f5; scroll-snap-align: start;
}
.hr:first-child { border-left: 0; }
.hr.midnight { border-left: 2px solid var(--ink); }
.hr .d { font-size: 11px; font-weight: 700; color: var(--ink); min-height: 15px; }
.hr .h { font-size: 12px; color: var(--sub); }
.hr svg.ic { width: 30px; height: 30px; }
.hr .t { font-family: var(--num); font-size: 19px; font-weight: 600; }
.hr .p { font-size: 11px; color: var(--accent); min-height: 16px; }
.hr .p.none { color: #c3cad3; }
.hr .w { font-size: 11px; color: var(--sub); display: flex; align-items: center; gap: 2px; }
.hr .w svg { width: 11px; height: 11px; }

/* ── 날짜별 ── */
.days { list-style: none; }
.day {
    display: grid; grid-template-columns: 50px 58px 1fr 34px; align-items: center; gap: 8px;
    padding: 5px 0; border-bottom: 1px solid #f0f2f5;
}
.day:last-child { border-bottom: 0; }
.day .dn { font-weight: 700; font-size: 13px; line-height: 1.2; }
.day .dn small { display: block; font-weight: 400; color: var(--sub); font-size: 11px; }
.day .icons { display: flex; }
.day .icons svg { width: 29px; height: 29px; }
.day .wtxt { display: none; }
.range { display: flex; align-items: center; gap: 5px; font-family: var(--num); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.range .bar { position: relative; flex: 1; height: 6px; background: var(--paper); border-radius: 3px; }
.range .bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.range .lo { color: var(--t-cold); width: 20px; text-align: right; }
.range .hi { color: var(--t-hot); width: 20px; }
.day .pop { font-size: 12px; color: var(--accent); text-align: right; }
.day .pop.none { color: #c3cad3; }

/* ── 특보 ── */
.warns { list-style: none; display: grid; gap: 6px; }
.warn { border-radius: 10px; padding: 9px 12px; border-left: 5px solid; display: grid; gap: 1px; }
.warn .wn { font-size: 16px; font-weight: 700; }
.warn .wr { font-size: 13px; }
.warn .wt { font-size: 11px; color: var(--sub); }
.warn.lvl1 { background: #edf8ef; border-color: #43a047; }
.warn.lvl2 { background: #fff8e1; border-color: #f9a825; }
.warn.lvl3 { background: #fff1e3; border-color: #fb8c00; }
.warn.lvl4 { background: #fdecea; border-color: #e53935; }
.warn.none { background: var(--paper); border-color: #b8c1cc; color: var(--sub); }
.sub-head .muted { font-weight: 400; }
.notice { font-size: 13px; line-height: 1.5; }
.notice .sum { font-weight: 700; padding: 6px 10px; background: var(--paper); border-radius: 8px; margin-bottom: 4px; }
.notice dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; }
.notice dt { color: var(--accent); font-weight: 700; font-size: 12px; white-space: nowrap; padding-top: 1px; }
.notice dd { margin: 0; }
.notice .empty { color: var(--sub); }
.events { list-style: none; font-size: 12px; }
.events li { display: grid; grid-template-columns: 76px 30px 1fr; gap: 6px; padding: 4px 0; border-bottom: 1px dashed #edf0f3; }
.events time { font-family: var(--num); font-size: 13px; color: var(--sub); }
.events .ev { font-weight: 700; }
.events .ev.해제 { color: var(--sub); }
.events .ev.발표 { color: var(--t-hot); }
.events li.empty { display: block; color: var(--sub); }

/* ── 기상영상 벽 ── */
.wall { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.slot {
    background: var(--card); border-radius: var(--radius); overflow: hidden; min-width: 0; min-height: 0;
    box-shadow: 0 1px 2px rgba(23, 32, 46, .06), 0 4px 16px rgba(23, 32, 46, .04);
    display: flex; flex-direction: column;
}
.slot-head { display: flex; align-items: center; gap: 6px; padding: 7px 10px 5px; min-width: 0; }
.slot-head h3 { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-head time { margin-left: auto; font-family: var(--num); font-size: 13px; color: var(--sub); white-space: nowrap; }
.slot-tabs { display: flex; gap: 3px; padding: 0 10px 4px; flex-wrap: wrap; }
.slot-tabs button {
    border: 1px solid var(--line); background: var(--card); cursor: pointer;
    font-size: 11px; padding: 1px 7px; border-radius: 999px; color: var(--sub);
}
.slot-tabs button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.slot-img { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 6px 6px; cursor: zoom-in; }
.slot-img img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 6px; }  /* 작은 원본(특보도 300px)도 칸에 맞게 확대 */
.slot.fail .slot-img::after { content: '영상을 불러오지 못했습니다'; color: var(--sub); font-size: 12px; }
.slot.fail .slot-img img { display: none; }

.lightbox {
    position: fixed; inset: 0; z-index: 5000; background: rgba(14, 19, 32, .86);
    display: grid; place-items: center; padding: 24px; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox figure { display: grid; gap: 8px; justify-items: center; max-width: 100%; max-height: 100%; }
.lightbox img { max-width: 94vw; max-height: 86vh; background: #fff; border-radius: 8px; }
.lightbox figcaption { color: #fff; font-size: 14px; }
.lb-close {
    position: absolute; top: 16px; right: 16px; border: 0; cursor: pointer;
    background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700;
}

/* ── 푸터 ── */
.foot { padding: 0 16px 8px; color: var(--sub); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ══ 한 화면 상황판 (1200px 이상) — 그림(영상 벽)이 주인공 ══ */
.col-left { grid-area: left; }
.col-mid { grid-area: mid; }
.flow { grid-area: flow; }
.hourly-card { grid-area: hourly; }
.col-right { grid-area: wall; }

@media (min-width: 1200px) {
    html, body { height: 100%; overflow: hidden; }
    body { display: flex; flex-direction: column; }
    .board {
        flex: 1; min-height: 0;
        grid-template-columns: 280px 290px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) clamp(170px, 21vh, 230px);
        grid-template-areas: "left mid wall" "flow flow wall";
    }
    .hourly-card { display: none; }      /* 차트 위 날씨 아이콘 줄로 대신 */
    .card.fill { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
    .scroll { flex: 1; min-height: 0; overflow: auto; }
    .flow { min-height: 0; }
    .chart { min-height: 0; }
    .map { flex: 1; height: auto; min-height: 0; }
    .obs-card { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
    .obs .stn small, .obs .wind .wd { display: none; }
    .obs th, .obs td { padding-left: 4px; padding-right: 4px; }
    .obs td { padding-top: 2px; padding-bottom: 2px; }
    .col-right { min-height: 0; display: flex; }
    .wall { flex: 1; min-height: 0; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; }
    .slot-head h3 { font-size: 14px; }
}
@media (min-width: 1200px) and (max-width: 1599px) {
    .board { grid-template-rows: minmax(0, 1fr) clamp(160px, 20vh, 210px); }
    .obs th:nth-child(5), .obs td:nth-child(5) { display: none; }   /* 1시간강수 — 폭 부족 */
    .obs td { padding-top: 1px; padding-bottom: 1px; font-size: 12px; }
    .obs td.num { font-size: 15px; }
}
@media (min-width: 1600px) {
    .board { grid-template-columns: 320px 330px minmax(0, 1fr); }
    .wall { grid-template-columns: repeat(3, 1fr); }
}
/* 낮은 화면(1366×768 등): 지도·중복 항목을 접어 특보·관측표 자리를 지킨다 */
@media (min-width: 1200px) and (max-height: 800px) {
    .card.map-card { display: none; }
    .day:nth-child(n+4) { display: none; }
    .facts div:nth-child(n+5) { display: none; }
}
@media (min-width: 1200px) and (max-height: 820px) {
    .now-temp { font-size: 64px; }
    .now-icon svg { width: 48px; height: 48px; }
    .card { padding: 10px 12px; }
    .facts { margin-top: 2px; padding-top: 6px; }
    .day { padding: 3px 0; }
    .obs td { padding-top: 1px; padding-bottom: 1px; font-size: 12px; }
    .obs td.num { font-size: 15px; }
}

/* ══ 쌓기 (1200px 미만) ══ */
@media (max-width: 1199px) {
    .board { grid-template-columns: 1fr 1fr; grid-template-areas: "left mid" "flow flow" "hourly hourly" "wall wall"; }
    .chart { min-height: 260px; }
    .map { height: 340px; }
    .slot { height: 440px; }
}
@media (max-width: 768px) {
    .top { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
    .brand h1 { font-size: 19px; }
    .led { order: 3; flex-basis: 100%; height: 40px; }
    .led-msg { font-size: 17px; height: 40px; line-height: 40px; }
    .top-meta { margin-left: auto; }
    .clock { display: none; }
    .now-temp { font-size: 72px; }
    .board { grid-template-columns: 1fr; grid-template-areas: "left" "flow" "hourly" "mid" "wall"; }
    .wall { grid-template-columns: 1fr; }
    .slot { height: 400px; }
    .map { height: 320px; }
    .foot { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
    .led-msg { transition: none; }
}
