/* HALIA Phase C home (REF3 desktop / REF4 mobile). Page layer; tokens only. */
@layer pages {
  .platform-home { padding: var(--space-2) 0 var(--space-4); }
  .home-layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--sidebar-width); gap: var(--space-6); align-items: start; }
  .home-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); min-width: 0; }
  .home-side { display: grid; gap: var(--space-4); padding: var(--space-4); border-radius: var(--radius-2xl); background: var(--bg-secondary); }
  #home-status:empty { display: none; }
  #home-status { margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--warning-subtle); color: var(--text-primary); font: var(--text-body-sm); }
  #home-status a { color: var(--accent); font-weight: 600; }

  /* Hero: brand illustration with a readable veil on the text side. */
  .home-hero {
    position: relative;
    isolation: isolate;
    min-height: 318px;
    overflow: hidden;
    border-radius: var(--radius-2xl);
    background: linear-gradient(120deg, var(--hero-sky), var(--hero-sky-end));
  }
  .home-hero-art { position: absolute; z-index: -2; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: right center; filter: var(--art-filter); }
  .home-hero::before { content: ""; position: absolute; z-index: -1; inset: 0; background: var(--hero-text-veil); }
  .home-hero-copy { display: grid; justify-items: start; gap: var(--space-3); max-width: 620px; padding: var(--space-10) var(--space-12); }
  .home-hero-eyebrow { margin: 0; font: 500 18px/1.45 var(--font-sans); color: var(--text-primary); }
  .home-hero h1 { margin: var(--space-1) 0 0; font: var(--text-hero); letter-spacing: -.025em; color: var(--text-primary); }
  .home-hero-lead { margin: 0; font: var(--text-body-lg); color: var(--text-secondary); }
  .home-hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }
  .home-hero-actions .btn { min-height: var(--control-xl); padding: 0 var(--space-8); border-radius: var(--radius-lg); font-size: 16px; }
  .home-hero-actions .btn-secondary { background: var(--surface); border-color: var(--border-subtle); box-shadow: var(--shadow-card); }

  /* Quick actions strip */
  .home-quick { position: static; inset: auto; flex-direction: row; font: inherit; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.15fr); align-items: center; padding: var(--space-4) var(--space-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-card); }
  .home-quick > a { display: flex; align-items: center; gap: var(--space-3); min-width: 0; padding: var(--space-2) var(--space-3); color: inherit; text-decoration: none; border-right: 1px solid var(--border-subtle); }
  .home-quick > a > span:last-child { min-width: 0; }
  .home-quick-icon { display: inline-grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: var(--radius-pill); background: var(--surface-mint); color: var(--accent); }
  .home-quick-icon .icon { width: 26px; height: 26px; }
  .home-quick strong { display: block; font: var(--text-card-title); color: var(--text-primary); }
  .home-quick strong { white-space: nowrap; }
  .home-quick small { display: block; font: var(--text-caption); font-size: 13px; line-height: 18px; color: var(--text-muted); }
  @media (hover: hover) { .home-quick > a:hover strong { color: var(--accent); } }
  .home-quick-quote { margin: 0; padding: 0 var(--space-3) 0 var(--space-5); font: italic 500 15px/1.5 var(--font-sans); color: var(--accent); }
  .home-quick-quote small { display: block; margin-top: var(--space-1); font: var(--text-caption); font-style: normal; color: var(--text-muted); }

  /* Card grid: 주요 토론 · 주목할 만한 프로젝트 · 프로젝트 매칭 / 연구 장비 공유 · 새로운 기회 · 최신 게시글 */
  .home-grid {
    display: grid;
    grid-template-columns: 354fr 350fr 147fr 213fr;
    grid-template-areas: "disc proj proj match" "res opp posts posts";
    gap: var(--space-4);
  }
  .home-discussions { grid-area: disc; }
  .home-projects { grid-area: proj; }
  .home-match { grid-area: match; }
  .home-resources { grid-area: res; }
  .home-opportunities { grid-area: opp; }
  .home-posts { grid-area: posts; }
  .home-panel { min-width: 0; padding: var(--space-5) var(--space-5) var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-card); }
  .home-section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-subtle); }
  .home-section-head h2 { display: flex; align-items: center; gap: var(--space-2); margin: 0; font: var(--text-section); color: var(--text-primary); }
  .home-section-icon { display: inline-grid; place-items: center; color: var(--accent); }
  .home-section-icon .ico-flame { fill: var(--tone-orange-fg); }
  .home-more { display: inline-flex; align-items: center; gap: 2px; min-height: 32px; font: var(--text-caption); font-size: 13px; color: var(--text-muted); text-decoration: none; }
  @media (hover: hover) { .home-more:hover { color: var(--accent); } }
  .home-panel-body { min-width: 0; }
  .home-skeleton { display: grid; gap: var(--space-3); padding: var(--space-4) 0; }
  .home-empty { display: grid; gap: var(--space-1); justify-items: start; margin: 0; padding: var(--space-6) var(--space-1); color: var(--text-muted); font: var(--text-body-sm); }
  .home-empty p { margin: 0; }
  .home-empty a { color: var(--accent); font-weight: 600; text-decoration: none; }
  .home-list { margin: 0; padding: 0; list-style: none; }
  .home-list > li + li { border-top: 1px solid var(--border-subtle); }
  .home-list a { display: flex; align-items: center; gap: var(--space-3); min-width: 0; padding: var(--space-3) 0; color: inherit; text-decoration: none; }
  .home-item-text { display: grid; gap: 3px; flex: 1; min-width: 0; justify-items: start; }
  .home-item-text strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--text-card-title); font-size: 15px; color: var(--text-primary); }
  @media (hover: hover) { .home-list a:hover .home-item-text strong, .home-project-link:hover strong { color: var(--accent); } }
  .home-discussion a { align-items: flex-start; padding-block: var(--space-4); }
  .home-resource .home-item-text strong, .home-opportunity .home-item-text strong { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .home-meta { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--text-body-sm); color: var(--text-muted); }
  .home-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: 100%; min-width: 0; }
  .home-row > .chip, .home-due { flex: none; }
  .home-due { font: var(--text-caption); color: var(--text-muted); white-space: nowrap; }
  .home-opportunity .home-row strong { -webkit-line-clamp: 1; }
  .home-discussion .home-item-text strong { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

  /* Projects: horizontal cards */
  .home-project-track { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: var(--space-3); padding: var(--space-4) 0 var(--space-2); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; }
  .home-project { scroll-snap-align: start; min-width: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface); }
  .home-project-link { display: grid; gap: var(--space-3); height: 100%; padding: var(--space-4); color: inherit; text-decoration: none; }
  .home-project-head { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: var(--space-3); align-items: start; }
  .home-project-head strong { font: var(--text-card-title); font-size: 15px; color: var(--text-primary); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .home-project-cover { width: 92px; height: 76px; border-radius: var(--radius-md); object-fit: cover; background: var(--surface-mint); }
  .home-project-cover-empty { display: grid; place-items: center; background: linear-gradient(135deg, var(--surface-mint), var(--surface-mint-strong)); color: var(--accent); font: var(--text-h2); }
  .home-project-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .home-project-summary { font: var(--text-body-sm); color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .home-project-org { display: flex; align-items: center; gap: var(--space-2); font: var(--text-body-sm); color: var(--text-secondary); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .home-project-org .icon { flex: none; color: var(--accent); }
  .home-project-foot { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: auto; }

  /* Matching card */
  .home-match { display: grid; align-content: start; gap: var(--space-3); padding-bottom: var(--space-5); }
  .home-match .home-section-head { border-bottom: 0; padding-bottom: 0; }
  .home-match-art { position: relative; justify-self: center; width: 150px; height: 118px; }
  .home-match-art .orbit { position: absolute; inset: 6px 14px; border: 1px dashed var(--border-default); border-radius: var(--radius-pill); }
  .home-match-art .orbit-2 { inset: 26px 38px; border-style: solid; border-color: var(--surface-mint-strong); background: var(--surface-mint); }
  .home-match-art img { position: absolute; left: 50%; top: 50%; width: 34px; transform: translate(-50%, -50%); }
  .home-match-art .dot { position: absolute; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-pill); background: var(--surface); color: var(--accent); box-shadow: var(--shadow-card); }
  .home-match-art .dot .icon { width: 18px; height: 18px; }
  .home-match-art .dot-1 { left: 6px; top: 8px; }
  .home-match-art .dot-2 { right: 0; top: 30px; }
  .home-match-art .dot-3 { right: 26px; bottom: 0; }
  .home-match-title { margin: 0; font: 700 19px/1.45 var(--font-sans); color: var(--accent); }
  .home-match-text { margin: 0; font: var(--text-body-sm); color: var(--text-secondary); }
  .home-match-cta { min-height: var(--control-lg); border-radius: var(--radius-lg); }

  /* Resources, opportunities, posts */
  .home-resource-thumb { display: grid; place-items: center; flex: none; width: 64px; height: 54px; overflow: hidden; border-radius: var(--radius-md); background: var(--surface-muted); color: var(--accent); }
  .home-resource-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .home-resource .chip { flex: none; min-height: 28px; padding: 0 10px; border-radius: var(--radius-pill); }
  .home-opportunity .icon-tile { width: 52px; height: 52px; background: var(--surface-muted); }
  .home-post a { align-items: flex-start; }
  .home-post .home-item-text { justify-items: stretch; }
  .home-post-title { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
  .home-post-title .chip { flex: none; }
  .home-post-title strong { min-width: 0; font-weight: 600; font-size: 14px; }
  .home-post-line { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-width: 0; }
  .home-post-stats { display: flex; gap: var(--space-3); flex: none; }

  /* Sidebar */
  .home-me { padding: var(--space-5); border-radius: var(--radius-xl); background: var(--surface-mint); }
  .home-me-card { display: flex; align-items: center; gap: var(--space-4); color: inherit; text-decoration: none; }
  .home-me-card > .icon { margin-left: auto; color: var(--accent); }
  .home-me-name { display: grid; gap: 2px; min-width: 0; }
  .home-me-name strong { font: var(--text-h2); color: var(--text-primary); overflow-wrap: anywhere; }
  .home-me-name span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--text-body-sm); color: var(--text-secondary); }
  .home-me-name span .icon { vertical-align: -3px; }
  .home-me-name .icon { color: var(--accent); }
  .home-me-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: var(--space-4) 0 0; padding: var(--space-4) 0; border-radius: var(--radius-lg); background: var(--surface); }
  .home-me-stats > div { display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; }
  .home-me-stats > div + div { border-left: 1px solid var(--border-subtle); }
  .home-me-stats dt { font: var(--text-caption); font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
  .home-me-stats dd { margin: 0; font: 700 24px/1.2 var(--font-sans); }
  .home-me-stats dd a { color: var(--accent); text-decoration: none; }
  .home-me-guest { display: grid; justify-items: start; gap: var(--space-2); }
  .home-me-guest h2 { margin: 0; font: var(--text-h3); }
  .home-me-guest p { margin: 0; font: var(--text-body-sm); color: var(--text-secondary); }
  .home-me-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }

  .home-quote { position: relative; isolation: isolate; min-height: 196px; margin: 0; overflow: hidden; border-radius: var(--radius-xl); background: var(--hero-sky); }
  .home-quote img, .home-cta img { position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .home-quote figcaption { display: grid; gap: var(--space-2); padding: var(--space-5) var(--space-6); color: var(--on-media); }
  .home-quote-label { font: var(--text-body-sm); color: var(--on-media-muted); }
  .home-quote blockquote { margin: 0; font: 600 20px/1.5 var(--font-sans); }
  .home-quote-by { font: var(--text-body-sm); color: var(--on-media-muted); }

  .home-events { padding-bottom: var(--space-4); }
  .home-events .home-section-head { border-bottom-color: var(--border-subtle); }
  .home-event-date { display: grid; justify-items: center; align-content: center; flex: none; width: 64px; height: 60px; border-radius: var(--radius-lg); background: var(--surface-mint); color: var(--accent); }
  .home-event-date strong { font: 700 17px/1.2 var(--font-sans); }
  .home-event-date small { font: var(--text-caption); color: var(--text-secondary); }
  .home-events-all { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-lg); margin-top: var(--space-2); padding: 0 var(--space-4); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); color: var(--text-primary); font: var(--text-label); text-decoration: none; }
  .home-events-all .icon { color: var(--accent); }
  @media (hover: hover) { .home-events-all:hover { background: var(--surface-hover); } }

  .home-cta { position: relative; isolation: isolate; display: grid; align-content: space-between; min-height: 330px; overflow: hidden; padding: var(--space-8) var(--space-6) var(--space-5); border-radius: var(--radius-xl); color: var(--on-media); }
  .home-cta h2 { margin: 0 0 var(--space-4); font: 700 19px/1.55 var(--font-sans); color: var(--on-media); }
  .home-cta-button, .btn.home-cta-button { min-height: var(--control-lg); padding: 0 var(--space-6); border: 0; border-radius: var(--radius-lg); background: var(--media-button); color: var(--on-media-button); font-weight: 700; }
  .home-cta-words { justify-self: end; margin: var(--space-6) 0 0; font: 500 15px/1.6 var(--font-sans); color: var(--on-media-muted); text-align: right; }

  /* Wide tablet / small desktop: sidebar folds below the main column. */
  @media (max-width: 1279px) {
    .home-layout { grid-template-columns: minmax(0, 1fr); }
    .home-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "disc match" "proj proj" "res opp" "posts posts"; }
    .home-quick { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .home-quick-quote { display: none; }
    .home-quick > a:nth-child(4) { border-right: 0; }
  }
  @media (max-width: 1023px) {
    .home-quick > a { flex-direction: column; text-align: center; gap: var(--space-2); }
    .home-quick small { display: none; }
    .home-hero-copy { padding: var(--space-8); }
  }

  /* Phone (REF4): one composed column — hero, shortcuts, my activity, then the cards in priority order. */
  @media (max-width: 767px) {
    .platform-home { padding-top: var(--space-2); }
    .home-layout, .home-main { display: flex; flex-direction: column; gap: var(--space-4); }
    .home-main, .home-side, .home-grid { display: contents; }
    .home-hero { order: 1; min-height: 0; border-radius: var(--radius-xl); }
    .home-hero-art { top: auto; height: 62%; object-position: 72% bottom; opacity: .5; }
    .home-hero::before { background: var(--hero-text-veil); }
    .home-hero-copy { gap: var(--space-2); padding: var(--space-6) var(--space-5) var(--space-5); }
    .home-hero-eyebrow { font-size: 14px; }
    .home-hero h1 { font-size: 26px; line-height: 36px; }
    .home-hero-lead { font: var(--text-body-sm); }
    .home-hero-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
    .home-hero-actions .btn { min-height: var(--control-lg); padding: 0 var(--space-3); font-size: 15px; }
    .home-quick { order: 2; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: var(--space-3) var(--space-1); }
    .home-quick > a { padding: var(--space-1); border-right: 0; }
    .home-quick-icon { width: 48px; height: 48px; }
    .home-quick-icon .icon { width: 22px; height: 22px; }
    .home-quick strong { font: var(--text-caption); font-weight: 700; }
    #home-status { order: 3; }
    .home-me { order: 4; padding: var(--space-4); }
    .home-me .avatar-xl { width: 56px; height: 56px; }
    .home-discussions { order: 5; }
    .home-projects { order: 6; }
    .home-events { order: 7; }
    .home-match { order: 8; }
    .home-posts { order: 9; }
    .home-opportunities { order: 10; }
    .home-resources { order: 11; }
    .home-quote { order: 12; min-height: 150px; }
    .home-cta { order: 13; min-height: 220px; padding: var(--space-6) var(--space-5); }
    .home-panel { padding: var(--space-4) var(--space-4) var(--space-2); }
    .home-project-track { grid-auto-columns: 82%; margin-right: calc(-1 * var(--space-4)); padding-right: var(--space-4); }
    .home-match { grid-template-columns: 1fr 110px; align-items: center; }
    .home-match .home-section-head, .home-match-text, .home-match-cta { grid-column: 1 / -1; }
    .home-match-art { grid-column: 2; grid-row: 2; width: 110px; height: 90px; }
    .home-match-title { grid-column: 1; grid-row: 2; font-size: 17px; }
    .home-due { display: none; }
    .home-resource-thumb { width: 60px; height: 50px; }
  }
}
