/* ============================================================
   SNU ECE 공지방 — mobile.css
   data-view="mobile"일 때만 적용되는 레이아웃 레이어.
   좌우 레일을 폭 좁은 화면에 밀어 넣지 않는다. 왼쪽 브랜드 레일은
   햄버거로 여는 서랍이 되고, 오른쪽 학내 홍보 레일은 목록 아래로 내려온다.
   ============================================================ */

html[data-view="mobile"] body { background: #f2f5fb; }
html[data-view="mobile"] .page-shell { padding: 0; min-width: 0; }
html[data-view="mobile"] .page-main { padding: 12px; max-width: 100%; }
html[data-view="mobile"][data-preview="1"] .page-main { padding-top: 40px; }
html[data-view="mobile"] .desktop-only { display: none !important; }
html[data-view="mobile"] button,
html[data-view="mobile"] input,
html[data-view="mobile"] select,
html[data-view="mobile"] textarea {
    border-radius: 13px;
}
html[data-view="mobile"] button,
html[data-view="mobile"] a,
html[data-view="mobile"] [role="button"] {
    -webkit-tap-highlight-color: rgba(31, 63, 143, 0.14);
    touch-action: manipulation;
    transition: transform 120ms ease, box-shadow 120ms ease,
        background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
html[data-view="mobile"] button:active:not(:disabled),
html[data-view="mobile"] a:active,
html[data-view="mobile"] [role="button"]:active {
    transform: translateY(1px) scale(0.97);
    filter: brightness(0.97);
}

/* ---------- 왼쪽 레일 → 서랍 ---------- */
html[data-view="mobile"] .rail-left {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 82vw);
    z-index: 1200;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-radius: 0 24px 24px 0;
}
html[data-view="mobile"][data-preview="1"] .rail-left { padding-top: 42px; }
html[data-view="mobile"] .rail-left.drawer-open { transform: translateX(0); }

html[data-view="mobile"] .drawer-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 44, 98, 0.5);
    z-index: 1100;
}
html[data-view="mobile"] .drawer-scrim.drawer-open { display: block; }

.mobile-menu-btn {
    display: none;
    background: white;
    border: 1px solid var(--border);
    color: var(--primary-deep);
    width: 44px; height: 44px;
    border-radius: 14px;
    font-size: 20px; line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
html[data-view="mobile"] .mobile-menu-btn { display: block; }
.mobile-menu-btn:hover { background: var(--primary-light); border-color: var(--primary); }

.drawer-close-btn {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: 1px solid currentColor;
    color: var(--rail-text);
    width: auto;
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
    border-radius: 12px;
}
.drawer-close-btn span:first-child { font-size: 20px; font-weight: 500; }

/* ---------- 오른쪽 학내 홍보 레일 → 목록 아래 홍보 ---------- */
html[data-view="mobile"] .rail-right {
    display: flex;
    position: static;
    width: 100%;
    padding: 24px 0 32px;
}
html[data-view="mobile"] #right-rail-ad-content { height: auto; min-height: 0; }
html[data-view="mobile"] .rail-ad-viewport {
    width: 100%;
    min-height: 0;
    margin: 0;
}
/* 모바일 배너는 16:9 원본을 그대로 쓰므로 무대도 같은 비율로 잡는다.
   높이가 정해지므로 세로로 늘어나는 flex 규칙은 여기서 풀어준다. */
html[data-view="mobile"] .rail-ad-stage {
    height: auto;
    aspect-ratio: 16 / 9;
    flex: 0 0 auto;
}
html[data-view="mobile"] .rail-ad-image { object-fit: cover; }
/* 비율이 정확히 맞아 여백이 없으므로 흐린 배경 층은 필요 없다. */
html[data-view="mobile"] .rail-ad-backdrop { display: none; }

/* ---------- 헤더 ---------- */
html[data-view="mobile"] .header {
    row-gap: 10px;
    align-items: center;
    margin-bottom: 12px;
    padding: 12px;
    background: #fff;
    border: 0;
    border-radius: 20px;
    box-shadow: 0 5px 18px rgba(27, 52, 104, 0.07);
}
html[data-view="mobile"] .header-title-area { width: auto; flex: 1; }
html[data-view="mobile"] .header h1,
html[data-view="mobile"] .site-title { font-size: 22px; white-space: normal; }
html[data-view="mobile"] .site-title-mark { height: 44px; }
html[data-view="mobile"] .header-actions {
    width: auto;
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
}
html[data-view="mobile"] .btn { min-height: 44px; }
html[data-view="mobile"] .btn,
html[data-view="mobile"] .filter-btn,
html[data-view="mobile"] .filter-select,
html[data-view="mobile"] .detail-back,
html[data-view="mobile"] .close-btn,
html[data-view="mobile"] .image-viewer-action {
    border-radius: 14px;
}

/* 폰에서는 "모바일 모드" 버튼이 필요 없다. 미리보기 iframe 안에서도 감춘다. */
html[data-view="mobile"] .mobile-mode-btn,
html[data-preview="1"] .mobile-mode-btn { display: none !important; }

/* ---------- 카테고리 탭 ---------- */
html[data-view="mobile"] .category-tabs {
    height: 54px;
    margin: 0 0 12px;
    padding: 0;
    overflow: hidden;
    background: transparent;
    border-top: 2px solid var(--primary-deep);
    border-bottom: 1.5px solid var(--primary-deep);
    border-radius: 0;
}
html[data-view="mobile"] .category-tabs-inner {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    padding: 0;
}
html[data-view="mobile"] .category-tab {
    min-width: 0;
    min-height: 52px;
    justify-content: center;
    padding: 0 3px;
    margin: 0 0 -1.5px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-size: 12px;
}
html[data-view="mobile"] .category-tab.active {
    color: var(--primary-deep);
    background: transparent;
    border-bottom-color: var(--primary-deep);
}
html[data-view="mobile"] .notice-quick-filters {
    display: flex;
    justify-content: flex-start;
    gap: 5px;
    max-height: 0;
    order: 3;
    margin: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-7px);
    transition: max-height 220ms ease, margin 220ms ease,
        opacity 170ms ease, transform 220ms ease, visibility 0s linear 220ms;
}
html[data-view="mobile"] .notice-quick-filters.is-mobile-open {
    /* 칩이 커졌으므로 좁은 화면에서 세 줄로 접혀도 잘리지 않게 여유를 둔다. */
    max-height: 116px;
    margin: 5px 0 10px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s;
}
html[data-view="mobile"] .notice-quick-filters button {
    min-height: 32px;
    width: auto;
    min-width: 0;
    padding-inline: 12px;
    border-radius: 16px;
    white-space: nowrap;
    font-size: 11.5px;
    line-height: 1;
    opacity: 0;
    transform: translateY(-4px);
}
html[data-view="mobile"] .notice-quick-filters button::before { font-size: 10px; }
html[data-view="mobile"] .notice-quick-filters button.active::before { width: 10px; margin-right: 4px; }
html[data-view="mobile"] .notice-quick-filters.is-mobile-open button {
    opacity: 1;
    transform: translateY(0);
}
html[data-view="mobile"] .notice-quick-filters.is-mobile-open button:nth-child(2) { transition-delay: 25ms; }
html[data-view="mobile"] .notice-quick-filters.is-mobile-open button:nth-child(3) { transition-delay: 50ms; }
html[data-view="mobile"] .notice-quick-filters.is-mobile-open button:nth-child(4) { transition-delay: 75ms; }

/* 상세 필터 바 바로 아래에 붙는 줄이라 위쪽 간격을 좁게 잡는다. */
html[data-view="mobile"] .notice-results-toolbar {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    min-height: 0;
    margin: 4px 0 10px;
}
html[data-view="mobile"] .filter-result-count {
    flex: 0 0 auto;
    margin-right: 0;
    white-space: nowrap;
}
html[data-view="mobile"] .notice-sort-chips {
    width: auto;
    min-width: 0;
    margin-left: auto;
}
html[data-view="mobile"] .notice-sort-chips button {
    flex: 0 1 auto;
    min-height: 34px;
    padding-inline: 8px;
    font-size: 10.5px;
}

/* ---------- 공지 목록 ---------- */
/* 두 열이 나란히 끝나면 아래에 빈 띠가 남는다. 왼쪽 열을 조금 끌어올려
   벽돌처럼 어긋나게 두면 그 자리가 자연스럽게 메워진다. 끌어올린 만큼
   위쪽에 자리를 미리 비워 두어 첫 줄이 잘리지 않는다. */
html[data-view="mobile"] .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
    padding-top: 22px;
}
html[data-view="mobile"] .grid > .card:nth-child(2n+1) { margin-top: -22px; }
html[data-view="mobile"] .card {
    width: 100%;
    height: auto;
    min-width: 0;
    aspect-ratio: 0.72;
    border: 1px solid #dfe4ed;
    border-radius: 0;
    box-shadow: 0 8px 22px rgba(20, 43, 88, 0.14);
    touch-action: pan-y;
}
html[data-view="mobile"] .card.card-urgent {
    border: 2px solid #c0392b;
    box-shadow: 0 9px 24px rgba(192, 57, 43, 0.18);
}
html[data-view="mobile"] .card-poster {
    flex: 0 0 42%;
    height: 42%;
    min-height: 0;
    padding: 0;
    border-radius: 0;
}
html[data-view="mobile"] .card-poster.is-text { padding: 10px; }
html[data-view="mobile"] .card-img-preview {
    object-fit: cover;
    object-position: top center;
    -webkit-user-drag: none;
}
html[data-view="mobile"] .card-poster-title { font-size: 15px; line-height: 1.34; }
html[data-view="mobile"] .card-body { gap: 5px; padding: 8px; }
html[data-view="mobile"] .card .tags {
    max-height: 36px;
    gap: 3px;
    margin-bottom: 2px;
    overflow: hidden;
}
html[data-view="mobile"] .card .tag { padding: 3px 5px; font-size: 9.5px; }
html[data-view="mobile"] .card-title { font-size: 14px; line-height: 1.38; -webkit-line-clamp: 2; }
html[data-view="mobile"] .card-date { font-size: 10.5px; }
html[data-view="mobile"] .card-excerpt { font-size: 10.5px; line-height: 1.45; -webkit-line-clamp: 1; }
html[data-view="mobile"] .card-meta {
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    min-width: 0;
    font-size: 10px;
}
/* 좁은 칸이라 칩을 한 단계 줄인다. 흐르는 방식은 데스크톱과 같다. */
html[data-view="mobile"] .card-reward {
    padding: 2px 6px;
    font-size: 9.5px;
}
html[data-view="mobile"] .card-reward-icon { font-size: 9px; }
html[data-view="mobile"] .notice-pagination {
    display: flex;
    gap: 6px;
    margin: 16px 0 24px;
}
html[data-view="mobile"] .notice-pagination button {
    min-width: 42px;
    height: 42px;
    border-radius: 13px;
}

/* ---------- 공지 상세 ---------- */
html[data-view="mobile"] .detail-title { font-size: 24px; }
html[data-view="mobile"] .detail-image-nav { width: 38px; height: 38px; font-size: 27px; }
html[data-view="mobile"] .detail-image-nav.previous { left: 6px; }
html[data-view="mobile"] .detail-image-nav.next { right: 6px; }
/* 좁은 화면에서도 확대 버튼은 44px 터치 타겟을 지킨다. */
html[data-view="mobile"] .detail-image-zoom {
    right: 8px;
    bottom: 8px;
    min-height: 44px;
    padding: 0 14px;
    font-size: 12.5px;
}
html[data-view="mobile"] .detail-image-counter { left: 8px; bottom: 8px; }
html[data-view="mobile"] .image-viewer-toolbar {
    min-height: 60px;
    padding: 10px 12px;
    gap: 8px;
}
html[data-view="mobile"] .image-viewer-counter { min-width: 42px; font-size: 12px; }
html[data-view="mobile"] .image-viewer-actions { gap: 6px; }
html[data-view="mobile"] .image-viewer-action {
    min-height: 38px;
    padding: 0 10px;
    font-size: 11px;
}
html[data-view="mobile"] .image-viewer-close { width: 38px; min-height: 38px; }
html[data-view="mobile"] .image-viewer-stage { padding: 12px; }
html[data-view="mobile"] .image-viewer-stage img { max-height: calc(100vh - 86px); }
html[data-view="mobile"] .image-viewer .nav-btn {
    width: 38px;
    height: 44px;
    border-radius: 8px;
    font-size: 28px;
}
html[data-view="mobile"] .image-viewer .nav-btn.left { left: 8px; }
html[data-view="mobile"] .image-viewer .nav-btn.right { right: 8px; }

/* ---------- 검색 & 필터 ---------- */
html[data-view="mobile"] .search-container { display: block; }
html[data-view="mobile"] .search-field {
    width: 100%;
    min-height: 48px;
    grid-template-columns: minmax(0, 1fr) 42px;
    padding-left: 15px;
    border-width: 1.5px;
    border-radius: 24px;
}
html[data-view="mobile"] .search-container input { width: 100%; min-width: 0; font-size: 14px; }
html[data-view="mobile"] .search-submit { width: 38px; height: 38px; }
/* '상세 필터' 바가 빠른 필터 줄보다 먼저 온다. 바를 누르면 그 아래로
   빠른 필터가 펼쳐지고 이어서 상세 패널이 열린다. */
html[data-view="mobile"] .filter-toggle-bar {
    order: 2;
    min-height: 48px;
    padding: 8px 12px;
    height: auto;
    background: #fff;
    border-radius: 16px;
}
html[data-view="mobile"] .filter-toggle-bar.has-active { flex-wrap: wrap; }
html[data-view="mobile"] .filter-active-chips {
    min-width: 0;
    padding: 6px 0 0;
    overflow: hidden;
}
html[data-view="mobile"] .filter-toggle-bar.has-active .filter-active-chips {
    order: 3;
    width: 100%;
    flex-basis: 100%;
}
html[data-view="mobile"] .filter-chip {
    max-width: 100%;
    border-radius: 10px;
}
html[data-view="mobile"] .filter-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
html[data-view="mobile"] .filter-panel {
    order: 4;
    margin-top: 6px;
    background: #fff;
    border: 0;
    border-radius: 18px;
}
html[data-view="mobile"] .filter-panel-grid { grid-template-columns: 1fr; }
html[data-view="mobile"] .filter-panel-footer {
    align-items: stretch;
    justify-content: stretch;
}
html[data-view="mobile"] .filter-panel-footer .btn { flex: 1; }
html[data-view="mobile"] .filter-panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

html[data-view="mobile"] .notice-detail-view { padding-top: 8px; }
html[data-view="mobile"][data-preview="1"] .notice-detail-view { padding-top: 6px; }
html[data-view="mobile"] .detail-back {
    width: 40px;
    height: 40px;
    min-height: 40px;
    border-radius: 50%;
}

/* ---------- 모달 ---------- */
html[data-view="mobile"] .modal { padding: 24px 18px; border: 0; border-radius: 24px; }
html[data-view="mobile"] .form-row { flex-direction: column; gap: 0; }
/* 모바일에서는 비교·분할·6점 드래그 UI를 제공하지 않는다. */
html[data-view="mobile"] .card-block-controls,
html[data-view="mobile"] .compare-space,
html[data-view="mobile"] .split-drop-overlay,
html[data-view="mobile"] .compare-trash-zone {
    display: none !important;
}
html[data-view="mobile"] .card,
html[data-view="mobile"] .card * {
    -webkit-user-drag: none;
}
html[data-view="mobile"] .card.is-filter-entering {
    opacity: 1;
    transform: none;
}
html[data-view="mobile"] .card:hover {
    transform: none;
    box-shadow: 0 8px 22px rgba(20, 43, 88, 0.14);
}
html[data-view="mobile"] .card:active {
    transform: scale(0.985);
    box-shadow: 0 4px 12px rgba(20, 43, 88, 0.12);
}

@media (max-width: 420px) {
    html[data-view="mobile"] .category-tabs-inner { width: 100%; gap: 2px; padding: 0; }
    html[data-view="mobile"] .category-tab {
        min-width: 0;
        font-size: 13px;
        letter-spacing: -0.04em;
    }
}
html[data-view="mobile"] .compare-space-actions { width: 100%; justify-content: space-between; }
html[data-view="mobile"] .detail-actions { flex-direction: column; }
html[data-view="mobile"] .detail-actions .btn { width: 100%; }
html[data-view="mobile"] .detail-actions .btn-spacer { margin-right: 0; }
html[data-view="mobile"] #contact-modal .contact-row { flex-direction: column; align-items: stretch; }
html[data-view="mobile"] #contact-modal .contact-copy-btn { width: 100%; }
html[data-view="mobile"] #notification-category-list { grid-template-columns: 1fr; }
html[data-view="mobile"] .notice-hover-preview { display: none !important; }
/* ---------- 푸터 ----------
   모바일에서는 사이드바가 접혀 푸터가 사실상 주 내비게이션이 된다.
   그래서 데스크톱과 반대로 링크를 더 크고 진하게 키우고, 수집 신선도를
   맨 위 배지로 올린다. 순서 변경은 grid 영역 재배치로만 처리한다. */
html[data-view="mobile"] .site-footer {
    grid-template-areas: "sync" "links" "legal";
    margin-top: 44px;
    padding: 24px 4px 0;
}

/* 동기화 배지 — 상태에 따라 색·문구·아이콘이 함께 바뀐다. */
html[data-view="mobile"] .site-footer-sync {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-top: 0;
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--ok);
    background: var(--ok-bg);
    border-color: rgba(47, 107, 72, 0.22);
}
html[data-view="mobile"] .footer-sync-icon {
    width: 16px;
    height: 16px;
    margin-bottom: 2px;
}
html[data-view="mobile"] .footer-sync-label { font-size: 13px; font-weight: 800; }
html[data-view="mobile"] .footer-sync-detail { font-size: 11.5px; opacity: 0.85; }
html[data-view="mobile"] .site-footer-sync[data-state="stale"] {
    color: #8a6d1f;
    background: #fdf8e9;
    border-color: rgba(138, 109, 31, 0.25);
}
html[data-view="mobile"] .site-footer-sync[data-state="failed"] {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: rgba(192, 57, 43, 0.24);
}
html[data-view="mobile"] .site-footer-sync[data-state="loading"] {
    color: #6f7885;
    background: #f4f6f9;
    border-color: var(--border);
}
html[data-view="mobile"] .site-footer-sync[data-state="stale"] .footer-sync-icon,
html[data-view="mobile"] .site-footer-sync[data-state="stale"] .footer-sync-label,
html[data-view="mobile"] .site-footer-sync[data-state="failed"] .footer-sync-icon,
html[data-view="mobile"] .site-footer-sync[data-state="failed"] .footer-sync-label {
    color: inherit;
}

/* 2열 × 2행. 각 칸 오른쪽·아래에 1px 선을 두되 마지막 열과 행은 뺀다. */
html[data-view="mobile"] .site-footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 0;
}
html[data-view="mobile"] .footer-column {
    padding: 14px 12px;
    border-right: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
}
html[data-view="mobile"] .footer-column:nth-child(2n) { border-right: 0; padding-right: 2px; }
html[data-view="mobile"] .footer-column:nth-child(2n+1) { padding-left: 2px; }
html[data-view="mobile"] .footer-column:nth-last-child(-n+2) { border-bottom: 0; }
html[data-view="mobile"] .footer-column-title {
    margin-bottom: 8px;
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 700;
}
/* 터치 타겟은 글자 크기가 아니라 여백으로 44px를 확보한다. */
html[data-view="mobile"] .footer-link-list a,
html[data-view="mobile"] .footer-link-list button,
html[data-view="mobile"] .footer-link-list .footer-link-muted {
    min-height: 44px;
    padding: 12px 0;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}
html[data-view="mobile"] .footer-link-list .footer-link-muted { color: #aab0ba; }
html[data-view="mobile"] .footer-external-icon { width: 12px; height: 12px; }

html[data-view="mobile"] .site-footer-legal {
    flex-direction: column;
    align-items: flex-start;
    margin-top: 18px;
    padding: 14px 0 22px;
}
html[data-view="mobile"] .site-footer p { font-size: 11px; }

@media (prefers-reduced-motion: reduce) {
    html[data-view="mobile"] button,
    html[data-view="mobile"] a,
    html[data-view="mobile"] [role="button"],
    html[data-view="mobile"] .card {
        transition: none !important;
    }
}
