/* ====================================================================
   Pinaka Launcher — page styles. Small, boring, heavily commented.
   The grid IS the interface. Everything optimised for budget Android
   phones in sunlight: big tap targets, high contrast, no clutter.
   ==================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--pk-bg);
  color: var(--pk-text);
  font-family: var(--pk-font);
  font-display: swap;            /* never block render on fonts (R-4) */
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; color: inherit; }
svg { display: block; }

/* ---- page shell ---- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

/* ===================== HEADER BAND ===================== */
.header {
  background: linear-gradient(180deg, var(--pk-bg-tint) 0%, var(--pk-bg) 100%);
  border-bottom: 1px solid var(--pk-border);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.greeting h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 40px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.greeting h1 .en { font-weight: 700; color: var(--pk-text-muted); font-size: 0.62em; }
.greeting p {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--pk-text-muted);
}

/* brand badge + refresh, top-right */
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.brand-row { display: flex; align-items: center; gap: 9px; }
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--pk-accent-grad);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 19px;
  box-shadow: var(--pk-shadow-sm);
}
.brand-name { font-size: 12px; color: var(--pk-text-muted); text-align: right; line-height: 1.3; }
.brand-name b { color: var(--pk-text); font-weight: 700; }

.refresh {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--pk-border);
  background: var(--pk-card);
  color: var(--pk-text-muted);
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px; cursor: pointer;
  box-shadow: var(--pk-shadow-sm);
}
.refresh:active { transform: scale(0.97); }
.refresh svg { width: 14px; height: 14px; }
.refresh.spin svg { animation: pk-spin 0.7s linear infinite; }
@keyframes pk-spin { to { transform: rotate(360deg); } }

/* tiny "?" help link in the corner */
.help-link {
  width: 26px; height: 26px; border-radius: 999px;
  border: 1px solid var(--pk-border); background: var(--pk-card);
  color: var(--pk-text-muted);
  display: inline-grid; place-items: center;
  font-weight: 800; font-size: 14px;
}

/* ===================== APP GRID ===================== */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);   /* phones ≥360px → 2 cols */
  gap: 14px;
  margin-top: 18px;
}
@media (min-width: 768px)  { .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(4, 1fr); } }

/* ---- card ---- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 150px;
  background: var(--pk-card);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  padding: 14px;
  box-shadow: var(--pk-shadow);
  transition: transform .12s ease, box-shadow .12s ease;
  /* soft entrance fade (R-8: no animation beyond tap + this) */
  animation: pk-card-in .35s ease both;
  animation-delay: var(--pk-delay, 0ms);
  will-change: transform;
}
@keyframes pk-card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card:active { transform: scale(0.98); box-shadow: var(--pk-shadow-sm); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: auto;
}

/* icon tile */
.tile {
  position: relative;
  width: 52px; height: 52px;
  border-radius: 15px;
  background: var(--pk-accent-grad);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: var(--pk-shadow-sm);
}
.tile svg { width: 26px; height: 26px; stroke: #fff; }

/* status dot on the icon tile corner */
.dot {
  position: absolute;
  top: -3px; left: -3px;
  width: 13px; height: 13px;
  border-radius: 999px;
  background: var(--pk-grey);          /* default: unknown */
  border: 2.5px solid var(--pk-card);
}
.dot.up   { background: var(--pk-up); }
.dot.slow { background: var(--pk-slow); }
.dot.down { background: var(--pk-down); }

/* auth badge pill */
.badge {
  font-size: 11px; font-weight: 700;
  padding: 4px 9px; border-radius: 999px;
  letter-spacing: .2px; white-space: nowrap;
}
.badge.pin  { background: var(--pk-accent-soft); color: var(--pk-accent-dark); }
.badge.open { background: #EEF2F7; color: var(--pk-text-muted); }
.badge.off  { background: #FDECEC; color: var(--pk-down); }

/* card text block */
.card-name  { margin-top: 14px; font-size: 18px; font-weight: 700; line-height: 1.2; }
.card-hindi { margin-top: 3px; font-size: 14px; font-weight: 600; color: var(--pk-accent-dark); }
.card-desk  { margin-top: 4px; font-size: 12px; color: var(--pk-text-muted); }

/* disabled card */
.card.disabled {
  opacity: .55;
  pointer-events: none;
  box-shadow: none;
}
.card.disabled .tile { background: #CBD5E1; }

/* ---- error / empty state ---- */
.state {
  grid-column: 1 / -1;
  background: var(--pk-card);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--pk-shadow);
}
.state h2 { margin: 0 0 6px; font-size: 18px; }
.state p  { margin: 0; color: var(--pk-text-muted); font-size: 14px; }
.state button {
  margin-top: 16px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  color: #fff; background: var(--pk-accent-dark);
  border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer;
}

/* ===================== INSTALL NUDGE ===================== */
.install {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  max-width: 540px; margin: 0 auto;
  background: var(--pk-text);
  color: #fff;
  border-radius: 14px;
  padding: 13px 14px;
  display: none;                /* shown via .show when prompt fires */
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(15,23,42,.35);
  z-index: 50;
}
.install.show { display: flex; }
.install-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--pk-accent-grad);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 19px;
  flex-shrink: 0;
}
.install-text { flex: 1; line-height: 1.3; }
.install-text b { display: block; font-size: 14px; font-weight: 700; }
.install-text span { font-size: 12px; opacity: .8; }
.install-btn {
  font-family: inherit; font-weight: 700; font-size: 14px;
  background: var(--pk-accent); color: #062e22;
  border: 0; border-radius: 9px; padding: 9px 15px; cursor: pointer;
}
.install-close {
  background: transparent; border: 0; color: #fff; opacity: .6;
  font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1;
}

/* respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .refresh.spin svg { animation: none; }
}
