/* ==========================================================================
   App shell — header, main, footer
   ========================================================================== */

#app {
  min-height: 100%;
}

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: var(--footer-height);
  background: var(--app-bg);
}

/* ---- Header ---- */
.app-header {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  height: 2.6667rem; /* 48px, incl. the 2px accent rule */
  background: var(--app-header-bg);
  border-top: 2px solid var(--accent);
  padding: 0 0.8889rem; /* 16px */
  font-size: 0.7778rem;
  z-index: 300;
}

.app-header__container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 100%;
}

.app-header__item {
  display: flex;
  align-items: center;
  gap: 0.5556rem; /* live .app-header__item */
}

.app-header__item--search {
  justify-self: start;
}

.app-header__item--toolbar {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.5556rem;
}
/* live .app-header__btn — the "Today" shortcut, shown off-today */.app-header .ui-button {
  letter-spacing: 0.02em;
}
.app-header__btn {
  --btn-bg: #f7f8fa;
  --btn-color: #707070;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
[theme="dark"] .app-header__btn {
  --btn-bg: #0d0d0d;
  --btn-color: #707070;
}
.app-header__btn:hover,
.app-header__btn:focus-visible {
  --btn-hover-bg: #141414;
  color: #fff;
}
[theme="dark"] .app-header__btn:hover,
[theme="dark"] .app-header__btn:focus-visible {
  --btn-hover-bg: #fff;
  color: #000;
}
.app-header .ui-segmented-control {
  gap: 0.5556rem;
}

.app-header__item--logo {
  justify-self: center;
}

.app-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0.05em;
  position: relative;
}

.app-logo__input {
  width: auto;
  min-width: 4ch;
  max-width: 24ch;
  field-sizing: content;
  background: transparent;
  border: 0;
  outline: none;
  text-align: center;
  font-family: var(--ff-logo);
  font-weight: 400;
  font-size: 1.1111rem; /* 20px, matching the live wordmark */
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: uppercase;
  color: var(--accent-highlight); /* live .app-logo */
  padding: 0.1111rem 0;
}

/* Brand dot. Note: live's identical-looking dot is a notification badge
   (red, only present when there are unread notifications); the clone keeps a
   permanent accent dot as part of its wordmark. */
.app-logo__dot {
  width: 0.22em;
  height: 0.22em;
  border-radius: 50%;
  background: var(--accent);
  font-size: 1.1111rem;
  transform: translateY(-0.55em);
  flex: 0 0 auto;
}

.app-logo__input:focus {
  background: var(--surface-hover);
  border-radius: var(--radius-s);
}

/* ---- Main ---- */
.main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Day-grid viewport.
   Live gives the week grid a 54vh *minimum* and lets it grow with the tallest
   column (min-height on `.grid__item`), so a day with many tasks simply makes
   the page taller instead of clipping the overflow. */
.app__list {
  flex: 1 1 auto;
  min-height: 54vh;
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}

.app.app--primary {
  flex: 0 0 auto;
  min-height: 54vh;
}

/* With Someday visible, size the days from their content and the two blank
   writing rows. The collapsed view keeps its screen-filling flex layout. */
.main--expanded .app.app--primary,
.main--expanded .app__list,
.main--expanded .grid-wrapper,
.main--expanded .grid,
.main--expanded .grid__item {
  min-height: 0;
}
.main--expanded .app__list { flex: 0 0 auto; }
.main--expanded .grid { height: auto; }

.grid-wrapper {
  position: relative;
  height: auto;
  min-height: 54vh;
  min-width: 0;
  padding: 0 1.1111rem; /* 20px page gutter, as live */
  z-index: 1;
}

.grid {
  display: flex;
  height: 100%;
  position: relative;
  width: 100%;
  z-index: 0;
  /* The slide itself is a Web Animations API animation (js/index.js), since the
     grid element is rebuilt on every render and a CSS transition would never
     fire on a fresh node. */
}

/* ---- Arrow navigation ----
   Live renders the two arrows as one #f7f8fa panel pinned near the top of the
   day area (top: 35px, 5px padding, 10px gap), with outer-only rounded corners
   and 24px icon buttons. */
.arrow-nav {
  position: absolute;
  top: 1.9444rem;
  display: flex;
  flex-direction: column;
  gap: 0.5556rem;
  padding: 0.2778rem;
  background: var(--arrow-bg);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
  pointer-events: none;
}
.arrow-nav--left {
  left: 0;
  border-radius: 0 5px 5px 0;
}
.arrow-nav--right {
  right: 0;
  border-radius: 5px 0 0 5px;
}
.app__list:hover .arrow-nav,
.someday-list-section:hover .arrow-nav,
.arrow-nav:focus-within {
  opacity: 1;
  pointer-events: auto;
}
.arrow-nav .ui-button {
  width: 1.3333rem;
  height: 1.3333rem;
  min-width: 1.3333rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--arrow-color);
}
.arrow-nav .ui-button:hover {
  background: var(--arrow-hover-bg);
  color: var(--arrow-hover-color);
}
.arrow-nav .ui-button .ui-icon {
  width: 0.8889rem;
  height: 0.8889rem;
}

/* ---- Footer ---- */
.app-footer {
  flex: 0 0 auto;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--surface-muted);
  padding: 0 0.8889rem;
  z-index: 200;
}

/* Tiny divider above the action bar — a real hairline, not a shadow. */
.app-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--footer-border-color);
  pointer-events: none;
}

.app-footer-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch; /* live: items are full toolbar height */
  height: var(--footer-height);
  gap: 0.5556rem;
}

.app-footer-toolbar__item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  max-width: 100%;
  min-width: 5.1111rem; /* live .app-footer-toolbar__item */
}
.app-footer-toolbar__item:nth-child(2) {
  justify-content: center;
}
.app-footer-toolbar__item:nth-child(3) {
  justify-content: flex-end;
}

/* Give icon wrappers the same 24px box as the segmented controls. Their
   inherited text line-height otherwise shifts the glyphs onto three baselines. */
.app-footer-toolbar__item > .tooltip-wrap,
.app-footer-toolbar__item > .dropdown-menu-wrap {
  display: inline-flex;
  align-items: center;
  height: 1.3333rem;
  line-height: 1;
}
.app-footer-toolbar__item > .dropdown-menu-wrap > .tooltip-wrap {
  display: inline-flex;
  align-items: center;
  height: 100%;
}

.app-footer__trial {
  font-size: 0.5556rem;
}

/* ---- Collapsed someday panel (live's main--collapsed) ----
   The week grid takes the whole main area, the tabs bar collapses to zero
   height, and only the chevron tab stays visible at the bottom-right. */
.main--collapsed .app.app--primary {
  flex: 1 1 auto;
}
.main--collapsed .someday-toolbar {
  height: 0;
  padding: 0;
}
.main--collapsed .someday-list-tabs,
.main--collapsed .someday-list-tabs__add {
  display: none;
}
.main--collapsed .ui-button--someday-collapse {
  position: absolute;
  right: 0.8889rem;
  bottom: 100%;
}
.main--collapsed .someday-list-section {
  display: none;
}

/* In-app prayer reminder (fallback when system notifications are blocked). */
.prayer-reminder-toast {
  align-items: center;
  animation: prayer-reminder-in 0.25s ease both;
  background: var(--app-bg);
  border: 1px solid var(--line-strong);
  border-radius: 0.4444rem;
  bottom: 1.6667rem;
  box-shadow: var(--shadow-menu);
  color: var(--app-color);
  display: flex;
  gap: 0.6667rem;
  left: 50%;
  max-width: calc(100vw - 2rem);
  min-width: 16rem;
  padding: 0.8333rem 0.8889rem;
  position: fixed;
  transform: translateX(-50%);
  z-index: 1200;
}
.prayer-reminder-toast__mark {
  align-items: center;
  background: color-mix(in srgb, var(--accent-highlight) 14%, transparent);
  border-radius: 0.3333rem;
  color: var(--accent-highlight);
  display: flex;
  flex: 0 0 auto;
  font-size: 0.8889rem;
  height: 1.7778rem;
  justify-content: center;
  width: 1.7778rem;
}
.prayer-reminder-toast__copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.1111rem;
  min-width: 0;
}
.prayer-reminder-toast__title {
  font-size: 0.7222rem;
  font-weight: 700;
}
.prayer-reminder-toast__body {
  color: var(--text-dim);
  font-size: 0.6111rem;
}
.prayer-reminder-toast__close {
  align-items: center;
  background: transparent;
  color: var(--text-dim);
  display: flex;
  flex: 0 0 auto;
  font-size: 1rem;
  height: 1.3333rem;
  justify-content: center;
  width: 1.3333rem;
}
.prayer-reminder-toast__close:hover {
  color: var(--app-color);
}
@keyframes prayer-reminder-in {
  from {
    opacity: 0;
    transform: translate(-50%, 0.5rem);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .prayer-reminder-toast {
    animation: none;
  }
}
