/**
 * Mobile polish — loaded last so it wins over responsive/mobile-unified.
 * Goals: one clear hierarchy (title → age → actions → strip → calendar),
 * single-line actions, quiet calendar cells, photos not covered by chrome.
 */

@media (max-width: 768px) {
  /* ---------- Header ---------- */
  header {
    position: relative;
  }

  .brand {
    gap: 0;
  }

  h1.title,
  .title {
    font-size: 1.55rem;
    line-height: 1.25;
    padding: 0 44px; /* room for the session button */
  }

  .subtitle {
    font-size: 0.78rem;
    opacity: 0.85;
    margin-top: 0.05rem;
  }

  .age-display {
    font-size: 0.9rem;
    font-weight: 700;
  }

  /* Session: small round icon in the corner instead of a big pill */
  #login-button {
    position: absolute;
    top: max(4px, env(safe-area-inset-top));
    right: 2px;
    flex: 0 0 auto !important;
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(147, 112, 219, 0.14) !important;
    z-index: 5;
  }

  #login-button .btn-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  #login-button .btn-icon {
    font-size: 1rem;
    margin: 0;
  }

  /* Actions: one tidy row, icon + label on a single line */
  .life-counter-actions {
    display: flex !important;
    gap: 0.45rem;
  }

  .life-counter-actions .header-btn:not(#login-button) {
    flex: 1 1 0;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    min-height: 2.75rem;
    padding: 0.45rem 0.35rem;
    font-size: 0.8rem;
    border-radius: 14px;
  }

  .life-counter-actions .header-btn--primary {
    flex: 0.9 1 0 !important;
    min-height: 2.75rem !important;
    font-size: 0.86rem !important;
  }

  #growth-compare-btn {
    flex-grow: 1.35 !important;
  }

  .life-counter-actions .header-btn .btn-icon {
    position: static;
    font-size: 1em;
    line-height: 1;
  }

  .life-counter-actions .header-btn .btn-text {
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
  }

  /* ---------- Highlights strip ---------- */
  .highlights-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    opacity: 0.8;
  }

  .highlight-item {
    width: 62px !important;
    height: 62px !important;
    border-radius: 16px !important;
  }

  .highlight-item img,
  .highlight-item video {
    border-radius: 16px !important;
  }

  /* Day number as a small corner tag, not a pill across the photo */
  .highlight-item .highlight-badge {
    left: auto !important;
    right: 4px !important;
    bottom: 4px !important;
    transform: none !important;
    padding: 1px 6px !important;
    background: rgba(255, 252, 255, 0.9) !important;
    box-shadow: 0 1px 4px rgba(70, 40, 90, 0.18);
  }

  .highlight-item .highlight-badge .flower-number {
    display: none;
  }

  .highlight-item .highlight-badge .day-number {
    font-size: 0.66rem !important;
    font-weight: 700;
    line-height: 1.3;
    color: #6b4d8a;
  }

  /* ---------- Calendar ---------- */
  .month-title {
    font-size: 1.15rem;
    font-weight: 700;
  }

  .calendar-header .nav-btn {
    width: 40px;
    height: 40px;
  }

  /* Weekday row: plain labels, no emoji stickers */
  .day-header .day-stickers-container {
    display: none !important;
  }

  .day-header {
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
    min-height: 0 !important;
    padding: 0.15rem 0 0.25rem !important;
  }

  .day-header .day-name {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.7;
  }

  /* Cells: portrait 3:4 instead of 1:2 slivers; grid sits at the top */
  .calendar-grid {
    grid-auto-rows: auto !important;
    align-content: start !important;
    row-gap: 5px !important;
    column-gap: 5px !important;
  }

  .calendar-day {
    aspect-ratio: 2 / 3;
    height: auto !important;
    min-height: 0 !important;
    border-radius: 10px !important;
  }

  .calendar-day.other-month {
    opacity: 0.35;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Only the date on the photo; counts move to one quiet chip bottom-right */
  .day-rail {
    left: 3px;
    top: 3px;
  }

  .day-rail .day-stat {
    display: none;
  }

  .day-number {
    font-size: 0.68rem !important;
    min-width: 1.3em;
    padding: 0.08em 0.32em !important;
    border-radius: 6px !important;
  }

  .calendar-day.has-photos[data-count]::after {
    content: attr(data-count);
    position: absolute;
    right: 3px;
    bottom: 3px;
    z-index: 2;
    font: 700 0.58rem/1 "Quicksand", sans-serif;
    color: #fff;
    padding: 2px 5px;
    border-radius: 6px;
    background: rgba(60, 35, 80, 0.55);
    pointer-events: none;
  }

  /* ---------- Album ---------- */
  .gallery-header h2,
  #gallery-title {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Admin buttons: small, in the corner, off the faces */
  .gallery-item-actions {
    left: auto !important;
    right: 6px !important;
    bottom: 6px !important;
    width: auto !important;
    padding: 0 !important;
    gap: 6px !important;
    background: none !important;
  }

  .gallery-item .highlight-btn,
  .gallery-item .date-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    padding: 0 !important; /* global mobile button padding left 0px for the icon */
    background: rgba(255, 252, 255, 0.82) !important;
    box-shadow: 0 2px 8px rgba(60, 35, 80, 0.2) !important;
  }

  .gallery-item .highlight-btn svg,
  .gallery-item .date-btn svg {
    width: 17px !important;
    height: 17px !important;
    flex-shrink: 0;
  }

  /* ---------- Photo viewer ---------- */
  .media-modal {
    background: rgba(246, 241, 252, 0.985) !important; /* page no longer shows through */
  }

  .modal-info h3,
  #modal-title {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: 0.95rem;
    line-height: 1.25;
  }
}
