/* ui-v7.css
   UI polish pass: keeps the existing visual language, unifies the rhythm
   across the standalone pages and fixes small layout collisions. */

:root {
  --v7-page-top: 52px;
  --v7-page-bottom: 84px;
  --v7-coral: #ff8e71;
  --v7-yellow: #f2c64d;
}

/* Shared page rhythm for calendar, gallery and memories. */
.calendar-page,
.gallery-page,
.memories-page {
  padding-top: var(--v7-page-top);
  padding-bottom: var(--v7-page-bottom);
}

.calendar-hero,
.gallery-hero,
.memories-hero {
  gap: 32px;
  padding-bottom: 38px;
}

.calendar-hero h1,
.gallery-hero h1,
.memories-hero h1 {
  font-size: 62px;
  line-height: 1.04;
  letter-spacing: 0;
}

/* Memories hero gets the same pill label as the other standalone pages. */
.memories-hero__meta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 2px dashed rgba(39, 49, 58, .22);
  border-radius: 999px;
  background: rgba(255, 253, 247, .62);
}

.memories-hero__meta::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  content: '';
  background: var(--v7-coral);
  box-shadow: 0 0 0 4px rgba(255, 142, 113, .16);
}

/* Keep the header ticket from squeezing the nav on medium screens. */
.standalone-page .global-countdown {
  width: min(340px, 38vw);
}

@media (min-width: 981px) and (max-width: 1180px) {
  .standalone-page .global-countdown {
    width: min(300px, 32vw);
  }
}

@media (max-width: 620px) {
  .standalone-page .global-countdown {
    width: min(210px, 56vw);
  }
}

/* Floating controls must sit above the mobile quick nav. */
@media (max-width: 900px) {
  .ui3-backtop {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px));
  }

  .ui3-toast-region {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px));
    width: min(360px, calc(100vw - 24px));
  }
}

/* A slightly calmer focus ring on the dark home story. */
body.line-puppy-theme :focus-visible {
  outline-color: var(--amber, #efb593);
}

/* The page-in effect must not leave a transform on body, otherwise
   injected fixed controls (back-to-top, mobile nav) lose viewport anchoring. */
.standalone-page.ui3-ready {
  animation: ui3PageFade .45s var(--ease, ease) backwards;
}

@keyframes ui3PageFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

button:disabled {
  opacity: .5;
}

.command-button,
.icon-button,
.gallery-photo__favorite,
.calendar-day,
.segmented-control button,
.memories-note__actions button,
.global-nav__menu summary {
  -webkit-tap-highlight-color: transparent;
}

/* Gallery: search should fill the row before wrapping on small screens. */
.gallery-search {
  min-width: 0;
}

.gallery-search input {
  width: min(340px, 100%);
  min-width: 0;
}

.gallery-tools {
  justify-content: flex-end;
}

@media (max-width: 560px) {
  .gallery-search {
    width: 100%;
  }

  .gallery-search label {
    flex: 0 0 auto;
  }

  .gallery-search input {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
  }

  .gallery-tools {
    justify-content: flex-start;
  }
}

/* Gallery viewer: keep the action buttons comfortable on narrow phones. */
@media (max-width: 420px) {
  .gallery-viewer__actions {
    grid-template-columns: 1fr;
  }

  .gallery-viewer__actions button {
    justify-content: center;
  }
}

/* Calendar: a quiet divider under the legend. */
.calendar-legend {
  padding-top: 18px;
  border-top: 1px solid rgba(39, 49, 58, .1);
}

/* Memories: section titles share the calendar underline language. */
.memories-journal__head h2,
.memories-notes__head h2 {
  position: relative;
  width: fit-content;
  padding-bottom: 10px;
}

.memories-journal__head h2::after,
.memories-notes__head h2::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 4px;
  border-radius: 999px;
  content: '';
  background: linear-gradient(90deg, var(--v7-coral), var(--v7-yellow));
}

.memories-heatmap__cell {
  min-height: 48px;
  border-radius: 10px;
}

/* Dialogs: always center inside the viewport. */
dialog {
  margin: auto;
}

@media (max-width: 420px) {
  .gallery-dialog,
  .ui6-help-dialog {
    padding: 22px 18px;
  }

  .gallery-dialog h2,
  .ui6-help-dialog h2 {
    font-size: 22px;
  }
}

@media (max-width: 900px) {
  .calendar-hero h1,
  .gallery-hero h1,
  .memories-hero h1 {
    font-size: 46px;
  }
}

@media (max-width: 760px) {
  .calendar-page,
  .gallery-page,
  .memories-page {
    padding-top: 40px;
    padding-bottom: 64px;
  }

  .calendar-hero,
  .gallery-hero,
  .memories-hero {
    gap: 18px;
    padding-bottom: 28px;
  }

  .calendar-hero h1,
  .gallery-hero h1,
  .memories-hero h1 {
    font-size: 42px;
  }
}

@media (max-width: 480px) {
  .calendar-hero h1,
  .gallery-hero h1,
  .memories-hero h1 {
    font-size: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui3-backtop,
  .ui3-toast,
  .calendar-day,
  .gallery-photo,
  .gallery-photo__favorite,
  .command-button,
  .icon-button,
  .memories-heatmap__cell {
    transition: none;
    animation: none;
  }
}
