/*
 * PWA home: compact operation/design hybrid.
 *
 * Keeps the approved warm-white, navy and coral visual language while making
 * the selected site, address and primary punch action visible together on an
 * iPhone-sized first viewport.  Canonical punch controls remain in index.html;
 * pwa-home-v153.js only forwards to those controls.
 */

.app-view.hp153-installed {
  --hp153-paper: #faf7f0;
  --hp153-surface: #fffdf9;
  --hp153-surface-soft: #f5f0e7;
  --hp153-navy: #153653;
  --hp153-ink: #243e54;
  --hp153-muted: #596d81;
  --hp153-line: #e5ded2;
  --hp153-coral: #ef7658;
  --hp153-coral-deep: #b9492f;
  --hp153-coral-soft: #fff0e9;
  --hp153-blue: #286497;
  --hp153-green: #3f765d;
  --hp153-green-soft: #e9f2ec;
  --hp153-sans: var(--hd-sans);
  --hp153-serif: var(--hd-serif);
  --hp153-shadow: 0 6px 22px rgb(35 50 61 / 8%);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  background: var(--hp153-paper);
  color: var(--hp153-ink);
  color-scheme: light;
}

#pwa-home-v153,
#pwa-home-v153 button,
#pwa-home-brand-v153 button {
  font-family: var(--hp153-sans);
}

/* Canonical source nodes stay mounted for data and event bridging. */
.app-view.hp153-installed #tab-home > :not(#pwa-home-v153) {
  display: none !important;
}

.app-view.hp153-installed.hp153-home-active .app-header > :not(#pwa-home-brand-v153) {
  display: none !important;
}

.app-view.hp153-installed.hp153-home-active .app-header {
  width: min(100%, 560px);
  min-height: 76px;
  padding: calc(9px + env(safe-area-inset-top)) 17px 8px;
  background: var(--hp153-paper);
}

#pwa-home-brand-v153 {
  display: none;
  width: 100%;
  align-items: center;
  gap: 10px;
}

.hp153-home-active #pwa-home-brand-v153 {
  display: flex;
}

.hp153-brand-logo {
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  border: 1px solid rgb(21 54 83 / 16%);
  border-radius: 50%;
  background: #fff url('/icons/icon-192.png') center / cover no-repeat;
  box-shadow: 0 3px 11px rgb(35 50 61 / 9%);
}

.hp153-brand-copy {
  min-width: 0;
  color: var(--hp153-navy);
}

.hp153-brand-copy b {
  display: block;
  overflow: hidden;
  font-family: var(--hp153-serif);
  font-size: clamp(19px, 5.4vw, 23px);
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-brand-copy small {
  display: block;
  margin-top: 2px;
  font-family: var(--hp153-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .28em;
}

.hp153-bell {
  position: relative;
  width: 44px;
  height: 44px;
  min-width: 44px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--hp153-surface);
  color: var(--hp153-navy);
  box-shadow: 0 2px 10px rgb(35 50 61 / 6%);
}

.hp153-bell svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hp153-bell-dot {
  position: absolute;
  top: 5px;
  right: 4px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--hp153-surface);
  border-radius: 50%;
  background: var(--hp153-coral);
}

.hp153-bell-dot[hidden] { display: none; }

#pwa-home-v153 {
  position: relative;
  z-index: 0;
  display: grid;
  gap: 11px;
  min-width: 0;
  /* Keep the final interactive row outside the fixed navigation hit area. */
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

.hp153-hero {
  position: relative;
  display: grid;
  gap: 9px;
  overflow: hidden;
  padding: 13px;
  border: 1px solid var(--hp153-line);
  border-radius: 22px;
  background: var(--hp153-surface);
  box-shadow: var(--hp153-shadow);
}

.hp153-hero::before {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 13% 17%, rgb(70 58 43 / 3%) 0 1px, transparent 1.4px),
    radial-gradient(circle at 77% 63%, rgb(70 58 43 / 2.5%) 0 1px, transparent 1.4px);
  background-size: 19px 19px, 25px 25px;
  content: "";
  pointer-events: none;
}

.hp153-hero-top,
.hp153-site-panel,
.hp153-hero-actions {
  position: relative;
  z-index: 1;
}

.hp153-hero-top {
  min-height: 108px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 38%);
  gap: 12px;
}

.hp153-hero-main {
  min-width: 0;
  display: grid;
  align-content: center;
}

.hp153-date {
  margin: 0;
  color: var(--hp153-navy);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .035em;
}

.hp153-clock {
  margin: 2px 0 4px;
  color: var(--hp153-navy);
  font-family: var(--hp153-serif);
  font-size: clamp(39px, 11.2vw, 58px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -.055em;
  line-height: .98;
  white-space: nowrap;
}

.hp153-status-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.hp153-status {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid rgb(202 93 68 / 34%);
  border-radius: 999px;
  background: var(--hp153-coral-soft);
  color: var(--hp153-coral-deep);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.hp153-status::before {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.hp153-status.is-working {
  border-color: rgb(63 118 93 / 30%);
  background: var(--hp153-green-soft);
  color: var(--hp153-green);
}

.hp153-status-note {
  overflow: hidden;
  color: var(--hp153-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-photo-frame {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 16px;
  background: #d8dee0;
}

.hp153-hero-photo {
  position: absolute;
  inset: 0;
  background-color: #9db5c0;
  background-image: var(--pwa-photo-url, url('/assets/pwa/home-hero.jpg'));
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.hp153-hero-photo::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgb(20 43 59 / 12%));
  content: "";
}

.hp153-photo-edit {
  position: absolute;
  z-index: 2;
  top: 7px;
  right: 7px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #e2ddd4;
  border-radius: 50%;
  background: #fffdf9;
  color: var(--hp153-navy);
  -webkit-text-fill-color: var(--hp153-navy);
  box-shadow: 0 3px 12px rgb(31 45 59 / 11%);
}

.hp153-photo-edit svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.hp153-photo-message {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hp153-site-panel {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #e8dfd2;
  border-left: 3px solid var(--hp153-coral);
  border-radius: 14px;
  background: var(--hp153-surface-soft);
}

.hp153-site-heading,
.hp153-site-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp153-site-heading {
  justify-content: space-between;
}

.hp153-site-label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: var(--hp153-navy);
  font-size: 11px;
  font-weight: 700;
}

.hp153-site-label svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  fill: currentColor;
}

.hp153-target-state {
  min-height: 23px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid rgb(202 93 68 / 28%);
  border-radius: 999px;
  background: #fff8f3;
  color: var(--hp153-coral-deep);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.hp153-target-state::before {
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.hp153-target-state.is-selected {
  border-color: rgb(57 127 186 / 28%);
  background: #edf6fd;
  color: #296d9f;
}

.hp153-target-state.is-working {
  border-color: rgb(63 118 93 / 28%);
  background: var(--hp153-green-soft);
  color: var(--hp153-green);
}

.hp153-site {
  display: block;
  overflow: hidden;
  margin: 4px 0 2px;
  color: var(--hp153-navy);
  font-family: var(--hp153-serif);
  font-size: clamp(19px, 5.5vw, 25px);
  font-weight: 700;
  line-height: 1.24;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-site-meta {
  justify-content: space-between;
}

.hp153-site-address {
  min-width: 0;
  overflow: hidden;
  margin: 0;
  color: var(--hp153-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-site-change {
  min-width: 76px;
  min-height: 44px;
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid rgb(21 54 83 / 20%);
  border-radius: 10px;
  background: var(--hp153-surface);
  color: var(--hp153-navy);
  -webkit-text-fill-color: var(--hp153-navy);
  font-size: 11px;
  font-weight: 700;
}

.hp153-site-change[hidden] { display: none; }

.hp153-hero-actions {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(100px, .72fr) minmax(174px, 1.28fr);
  gap: 8px;
  align-items: stretch;
}

.hp153-signals {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.hp153-signal {
  min-width: 0;
  min-height: 29px;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  padding: 5px 8px;
  border: 1px solid #dfe4e6;
  border-radius: 10px;
  background: var(--hp153-surface);
  color: var(--hp153-blue);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-signal svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: currentColor;
}

.hp153-punch {
  min-width: 0;
  min-height: 64px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(135deg, #f38a69, var(--hp153-coral-deep));
  color: #fff;
  -webkit-text-fill-color: #fff;
  box-shadow: 0 7px 18px rgb(167 76 54 / 23%);
  text-align: left;
  touch-action: manipulation;
}

.hp153-punch:disabled {
  background: #aaa59e;
  box-shadow: none;
  opacity: .72;
}

.hp153-punch > svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.hp153-punch-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.hp153-punch b {
  overflow: hidden;
  font-family: var(--hp153-sans);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-punch-site {
  display: block;
  overflow: hidden;
  color: rgb(255 255 255 / 94%);
  -webkit-text-fill-color: rgb(255 255 255 / 94%);
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-punch-arrow {
  font-family: var(--hp153-sans);
  font-size: 25px;
  line-height: 1;
}

.hp153-summary-grid,
.hp153-lower-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.hp153-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--hp153-line);
  border-radius: 17px;
  background: var(--hp153-surface);
  box-shadow: 0 4px 15px rgb(35 50 61 / 6%);
}

.hp153-card-head {
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 11px 4px;
}

.hp153-card-head h2 {
  margin: 0;
  color: var(--hp153-navy);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}

.hp153-card-icon {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  flex: 0 0 31px;
  border-radius: 9px;
  background: #eaf2f8;
  color: var(--hp153-navy);
}

.hp153-card-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hp153-card-body {
  min-height: 73px;
  padding: 5px 11px 9px;
}

.hp153-schedule-list,
.hp153-record-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hp153-schedule-list li {
  min-width: 0;
  color: var(--hp153-ink);
  font-size: 11px;
  line-height: 1.3;
}

.hp153-schedule-list time {
  display: block;
  color: var(--hp153-coral-deep);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.hp153-schedule-list span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-card-link {
  width: 100%;
  min-height: 44px;
  padding: 7px 10px;
  border: 0;
  border-top: 1px solid var(--hp153-line);
  background: var(--hp153-surface);
  color: var(--hp153-navy);
  -webkit-text-fill-color: var(--hp153-navy);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.hp153-card-head > .hp153-card-link {
  width: auto;
  min-height: 44px;
  padding: 5px;
  border-top: 0;
}

.hp153-duration {
  min-height: 113px;
  display: grid;
  align-content: center;
  padding: 9px 11px 12px;
}

.hp153-duration b {
  display: block;
  color: var(--hp153-navy);
  font-family: var(--hp153-serif);
  font-size: clamp(21px, 6vw, 29px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
  white-space: nowrap;
}

.hp153-duration small {
  display: block;
  margin-top: 5px;
  color: var(--hp153-muted);
  font-size: 9px;
  line-height: 1.35;
}

.hp153-progress {
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: #e5e7e8;
}

.hp153-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #8bbce3;
}

.hp153-duration-status {
  margin: 7px 0 0;
  color: var(--hp153-muted);
  font-size: 10px;
}

.hp153-add {
  min-height: 44px;
  padding: 5px 8px;
  border: 1px solid rgb(202 93 68 / 28%);
  border-radius: 9px;
  background: var(--hp153-coral-soft);
  color: var(--hp153-coral-deep);
  -webkit-text-fill-color: var(--hp153-coral-deep);
  font-size: 10px;
  font-weight: 700;
}

.hp153-personal-entry {
  min-height: 72px;
  margin: 4px 9px 9px;
  padding: 10px;
  border: 1px solid var(--hp153-line);
  border-radius: 12px;
  background: #fff;
}

.hp153-personal-entry time {
  color: var(--hp153-blue);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.hp153-personal-entry b {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 4px;
  color: var(--hp153-navy);
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.hp153-personal-entry small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--hp153-muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-record-list {
  gap: 0;
  padding: 4px 10px 9px;
}

.hp153-record-list li {
  min-width: 0;
  min-height: 31px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  border-bottom: 1px solid var(--hp153-line);
  color: var(--hp153-ink);
  font-size: 9px;
}

.hp153-record-list li:last-child { border-bottom: 0; }

.hp153-record-list time {
  color: var(--hp153-navy);
  font-size: 9px;
  white-space: nowrap;
}

.hp153-record-type {
  min-width: 34px;
  padding: 3px 4px;
  border-radius: 6px;
  background: #e8f1f8;
  color: #286497;
  font-size: 8px;
  font-weight: 700;
  text-align: center;
}

.hp153-record-type.is-rest {
  background: #e8f1eb;
  color: #2f6348;
}

.hp153-record-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hp153-empty {
  color: var(--hp153-muted);
  font-size: 10px;
}

/* Navigation must stay visually solid over scrolled content on iOS. */
.app-view.hp153-installed .bottom-nav {
  z-index: 1000;
  isolation: isolate;
  border-top: 1px solid var(--hp153-line);
  background: #fffdf9;
  opacity: 1;
  pointer-events: auto;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: 0 -7px 20px rgb(35 50 61 / 7%);
}

.app-view.hp153-installed .bottom-nav::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: #fffdf9;
  content: "";
  pointer-events: none;
}

.app-view.hp153-installed .bottom-nav button {
  position: relative;
  z-index: 1;
  font-family: var(--hp153-sans);
  pointer-events: auto;
}

#pwa-home-v153 button:active,
#pwa-home-brand-v153 button:active {
  transform: scale(.985);
}

@media (max-width: 430px) {
  .app-view.hp153-installed .tab-stage { padding: 3px 12px 18px; }
  .app-view.hp153-installed.hp153-home-active .app-header { padding-inline: 14px; }
  .hp153-hero { padding: 12px; }
  .hp153-hero-top { grid-template-columns: minmax(0, 1fr) minmax(108px, 37%); }
}

@media (max-width: 360px) {
  .hp153-brand-copy b { font-size: 18px; }
  .hp153-hero-top { grid-template-columns: minmax(0, 1fr) 105px; gap: 8px; }
  .hp153-clock { font-size: 37px; }
  .hp153-status-note { display: none; }
  .hp153-hero-actions { grid-template-columns: 92px minmax(0, 1fr); }
  .hp153-signal { padding-inline: 6px; font-size: 9px; }
  .hp153-punch { padding-inline: 9px; grid-template-columns: 28px minmax(0, 1fr) 12px; }
  .hp153-punch > svg { width: 27px; height: 27px; }
  .hp153-punch b { font-size: 16px; }
  .hp153-site { font-size: 18px; }
  .hp153-card-head { padding-inline: 9px; }
  .hp153-card-head h2 { font-size: 12px; }
  .hp153-duration b { font-size: 20px; }
}

@media (prefers-color-scheme: dark) and (prefers-color-scheme: light) {
  .app-view.hp153-installed {
    --hp153-paper: #faf7f0;
    --hp153-surface: #fffdf9;
    --hp153-surface-soft: #f5f0e7;
    --hp153-navy: #153653;
    --hp153-ink: #243e54;
    --hp153-muted: #596d81;
    color-scheme: light;
  }
}

@media (prefers-reduced-motion: reduce) {
  #pwa-home-v153 *,
  #pwa-home-v153 *::before,
  #pwa-home-v153 *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
