/* Landing page mobile only (index.php) — does not affect other pages */

/* Select Year: hidden on tablet & desktop (phone chronological only) */
.home-year-controls,
.home-year-modal {
  display: none !important;
}

@media (max-width: 480px) {
  body.home-mobile-active {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body.home-mobile-active main.container.home-projects {
    padding: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  body.home-mobile-active .site-header {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  body.home-mobile-active .logo-secondary {
    display: inline;
  }

  body.home-mobile-active .footer {
    flex-shrink: 0;
    padding: 0.55rem 0.85rem 0.65rem;
  }

  body.home-mobile-active .home-projects {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 0.75rem;
    overflow: hidden;
    --home-dock-h: auto;
  }

  /* Override desktop fixed dock on phone */
  body.home-mobile-active .projects-dock {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    flex-shrink: 0;
    z-index: 20;
    background: #fff;
    border-top: 1px solid #e8e8e8;
    padding: 0.4rem 0 0.55rem;
    box-sizing: border-box;
  }

  /* Projects area scrolls vertically when content is tall */
  body.home-mobile-active .projects-viewport {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    touch-action: auto;
    padding: 0.4rem 0 0.65rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  /* Reset desktop absolute positioning so viewport can scroll tall grids */
  body.home-mobile-active #project-list {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100%;
    margin: 0;
    padding: 0;
    max-height: none !important;
    flex-shrink: 0;
    box-sizing: border-box;
    overflow: visible !important;
    touch-action: auto;
  }

  /* Kill desktop stack height limits on phone */
  body.home-mobile-active .home-projects .group-stack-static,
  body.home-mobile-active .group-stack-static {
    max-height: none !important;
    overflow: visible !important;
  }

  body.home-mobile-active .home-projects .group-block-static,
  body.home-mobile-active .group-block-static {
    overflow: visible !important;
  }

  body.home-mobile-active .home-projects .horizontal-group-wrapper-static,
  body.home-mobile-active .horizontal-group-wrapper-static {
    overflow: visible !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  body.home-mobile-active .home-projects .projects-viewport {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  body.home-mobile-active .home-projects #project-list {
    max-height: none !important;
    overflow: visible !important;
  }

  body.home-mobile-active .project-card-wrapper {
    overflow: visible;
    flex-shrink: 0;
  }

  body.home-mobile-active .group-label-bottom-static {
    flex-shrink: 0;
    overflow: visible;
    white-space: nowrap;
    line-height: 1.2;
    padding-bottom: 0.15rem;
  }

  /* Chronological: fixed 4 columns, stacks grow bottom → up */
  body.home-mobile-active.home-mobile-chrono .projects-viewport {
    justify-content: flex-start;
  }

  body.home-mobile-active.home-mobile-chrono #project-list {
    overflow-x: hidden;
    display: block;
    margin-top: auto;
    min-height: auto;
  }

  body.home-mobile-active.home-mobile-chrono .horizontal-group-wrapper-static {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
    margin: 0;
    padding: 0 0 0.2rem;
    min-width: 0;
    align-items: end;
  }

  body.home-mobile-active.home-mobile-chrono .group-block-static {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    min-width: 0;
    width: 100%;
    overflow: visible;
  }

  body.home-mobile-active.home-mobile-chrono .group-stack-static {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-end;
    gap: 0.35rem;
    max-height: none;
    overflow: visible;
  }

  body.home-mobile-active.home-mobile-chrono .project-card-wrapper {
    width: 100%;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  body.home-mobile-active.home-mobile-chrono .project-card {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    overflow: hidden;
  }

  body.home-mobile-active.home-mobile-chrono .project-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  body.home-mobile-active.home-mobile-chrono .group-label-bottom-static {
    display: none;
  }

  /* Alphabetical: flat 4-column grid, scroll when many rows */
  body.home-mobile-active.home-mobile-flat .projects-viewport {
    justify-content: flex-start;
  }

  body.home-mobile-active.home-mobile-flat #project-list {
    margin-top: auto;
  }

  body.home-mobile-active.home-mobile-flat .home-mobile-flat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  body.home-mobile-active.home-mobile-flat .home-mobile-flat-grid .project-card-wrapper {
    width: 100%;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  body.home-mobile-active.home-mobile-flat .home-mobile-flat-grid .project-card {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    overflow: hidden;
  }

  body.home-mobile-active.home-mobile-flat .home-mobile-flat-grid .project-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Other filters: one scroll surface — vertical + horizontal on viewport */
  body.home-mobile-active:not(.home-mobile-chrono):not(.home-mobile-flat) .projects-viewport {
    justify-content: flex-start;
    overflow: auto !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    touch-action: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.home-mobile-active:not(.home-mobile-chrono):not(.home-mobile-flat) #project-list {
    display: block;
    margin-top: auto;
    width: max-content;
    min-width: 100%;
    max-width: none;
    min-height: auto;
    overflow: visible !important;
    touch-action: auto;
    padding-bottom: 0.15rem;
  }

  body.home-mobile-active:not(.home-mobile-chrono):not(.home-mobile-flat) .horizontal-group-wrapper-static {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.55rem;
    width: max-content;
    min-width: 100%;
    margin: 0 !important;
    padding: 0 0.35rem 0.25rem;
    box-sizing: border-box;
    overflow: visible !important;
  }

  body.home-mobile-active:not(.home-mobile-chrono):not(.home-mobile-flat) .group-block-static {
    flex: 0 0 calc((100vw - 2.6rem) / 4);
    width: calc((100vw - 2.6rem) / 4);
    min-width: calc((100vw - 2.6rem) / 4);
    max-width: calc((100vw - 2.6rem) / 4);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    flex-shrink: 0;
    overflow: visible !important;
  }

  body.home-mobile-active:not(.home-mobile-chrono):not(.home-mobile-flat) .group-stack-static {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    flex-wrap: nowrap;
    overflow: visible !important;
    max-height: none !important;
  }

  body.home-mobile-active:not(.home-mobile-chrono):not(.home-mobile-flat) .group-label-bottom-static {
    white-space: normal;
    word-break: break-word;
    hyphens: auto;
    max-width: 100%;
  }

  body.home-mobile-active .project-code-label {
    font-size: 0.56rem;
    text-align: center;
    margin-top: 0.1rem;
  }

  body.home-mobile-active:not(.home-mobile-chrono) .group-label-bottom-static {
    display: block;
    font-size: 0.68rem;
    margin-top: 0.2rem;
    text-align: center;
    font-weight: 700;
  }

  /* Alphabetical uses same dual-axis viewport scroll as other non-chrono filters */
  body.home-mobile-active.home-mobile-alpha .projects-viewport {
    overflow: auto !important;
    touch-action: auto;
  }

  body.home-mobile-active.home-mobile-alpha #project-list {
    width: max-content;
    min-width: 100%;
    overflow: visible !important;
  }

  body.home-mobile-active.home-mobile-alpha .horizontal-group-wrapper-static {
    overflow: visible !important;
  }

  /* Alphabetical & other grouped filters: show letter/category under column */
  body.home-mobile-active.home-mobile-alpha .group-label-bottom-static,
  body.home-mobile-active:not(.home-mobile-chrono):not(.home-mobile-flat) .group-label-bottom-static {
    display: block;
  }

  body.home-mobile-active.home-mobile-chrono .home-year-controls {
    display: block !important;
    padding: 0.35rem 0.75rem 0.45rem;
  }

  body.home-mobile-active .home-year-slots {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.5rem;
  }

  body.home-mobile-active .home-year-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    min-height: 2rem;
    padding: 0.2rem 0.35rem 0.2rem 0.5rem;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    background: #f5f5f5;
    font-size: 0.8rem;
    font-weight: 600;
    color: #222;
    box-sizing: border-box;
  }

  body.home-mobile-active .home-year-slot__value {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
  }

  body.home-mobile-active .home-year-slot__arrows {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 0;
    line-height: 1;
  }

  body.home-mobile-active .home-year-slot__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 0.75rem;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: #888;
    font-size: 0.45rem;
    cursor: pointer;
    line-height: 1;
  }

  body.home-mobile-active .home-year-slot__arrow:hover {
    color: #0c58d0;
  }

  body.home-mobile-active .home-year-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
  }

  body.home-mobile-active .home-year-picker__trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font: inherit;
    text-align: left;
  }

  body.home-mobile-active .home-year-picker__label {
    flex: 1 1 auto;
    font-size: 0.85rem;
    color: #555;
  }

  body.home-mobile-active .home-year-picker__icon {
    color: #666;
    font-size: 0.95rem;
  }

  /* Year selection modal — only visible while open */
  body.home-mobile-active .home-year-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: none;
  }

  body.home-mobile-active .home-year-modal:not([hidden]) {
    display: block !important;
  }

  body.home-mobile-active.home-year-modal-open {
    overflow: hidden;
  }

  body.home-mobile-active .home-year-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
  }

  body.home-mobile-active .home-year-modal__panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(300px, calc(100vw - 2.5rem));
    max-height: min(70dvh, 420px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  body.home-mobile-active .home-year-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #e8e8e8;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    flex-shrink: 0;
  }

  body.home-mobile-active .home-year-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: #9a9a9a;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
  }

  body.home-mobile-active .home-year-modal__list {
    list-style: none;
    margin: 0;
    padding: 0.35rem 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.home-mobile-active .home-year-modal__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.72rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #9a9a9a;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  body.home-mobile-active .home-year-modal__item.is-selected {
    background: #e8f1fc;
    color: #0c58d0;
  }

  body.home-mobile-active .home-year-modal__item.is-disabled {
    cursor: default;
    opacity: 0.45;
  }

  body.home-mobile-active .home-year-modal__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    background: #0c58d0;
    color: #fff;
    font-size: 0.65rem;
    flex-shrink: 0;
  }

  body.home-mobile-active .home-year-picker__select {
    display: none;
  }

  /* Filter pills — horizontal scroll */
  body.home-mobile-active .filters-bar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.45rem;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    padding: 0.35rem 0.75rem 0;
    margin: 0;
    scrollbar-width: none;
  }

  body.home-mobile-active .filters-bar::-webkit-scrollbar {
    display: none;
  }

  body.home-mobile-active .filters-left {
    display: none;
  }

  body.home-mobile-active .filters-center,
  body.home-mobile-active .filters-right {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    width: auto;
  }

  body.home-mobile-active .filter-button {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.66rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-radius: 999px;
    border: 1px solid #d0d0d0;
    background: #fff;
    color: #111;
  }

  body.home-mobile-active .filter-button.active {
    background: #2a2a2a;
    border-color: #2a2a2a;
    color: #fff;
  }
}
