/* RamDeck - in-vehicle launcher
   Design constraints that drove this file:
   - Sunlight readable: high contrast, no mid-grey text on dark
   - Glove and glance friendly: nothing tappable under 88px
   - Night mode must not blind you at 2am in a truck bed */

:root {
  --bg:        #0a0d12;
  --surface:   #151a22;
  --surface-2: #1e242e;
  --line:      #2c3542;
  --text:      #ffffff;
  --text-dim:  #9aa7b8;
  --accent:    #d33a2c;   /* Ram red */
  --accent-dim:#7d2019;
  --good:      #34c759;
  --warn:      #ff9f0a;
  --radius:    18px;
  --dim:       1;
  --tile-min:  180px;
  --tile-h:    152px;
  --icon-size: 40px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  filter: brightness(var(--dim));
  transition: filter .35s ease;
}

/* ---------- status bar ---------- */

.statusbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}

.clock {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
#time   { font-size: 40px; font-weight: 600; letter-spacing: -1px; line-height: 1; }
#ampm   { font-size: 16px; font-weight: 600; color: var(--text-dim); }

.status-mid  { color: var(--text-dim); font-size: 17px; font-weight: 500; }
.status-right{ display: flex; align-items: center; gap: 14px; }

.weather { color: var(--text-dim); font-size: 17px; font-weight: 500; white-space: nowrap; }

/* Shows only when the device has no connection, so a dead tile grid is
   obviously a signal problem and not a broken app. */
.offline-chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--warn);
  border-radius: 999px;
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
}
.offline-chip[hidden] { display: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- tile grid ---------- */

.grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--tile-min), 1fr));
  grid-auto-rows: var(--tile-h);
  gap: 14px;
  padding: 16px 22px;
  overflow-y: auto;
  align-content: start;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.tile:active { transform: scale(.975); background: var(--surface-2); }

.tile-icon      { display: block; color: var(--accent); line-height: 0; }
.tile-icon svg  { width: var(--icon-size); height: var(--icon-size); }
.tile-text  { display: block; min-width: 0; }
.tile-label {
  display: block;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-sub {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

/* With no connection, dim the tiles that need one and highlight the apps
   that can still play what you downloaded ahead of time. */
body.is-offline .tile:not(.offline-ok)          { opacity: .38; }
body.is-offline .tile.offline-ok .tile-sub      { color: var(--good); }

/* ---------- dock ---------- */

.dock {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
  padding: 10px 22px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.dock-btn:active { background: var(--surface-2); color: var(--text); }
.dock-btn.on     { color: var(--accent); }

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px);
  z-index: 50;
}
.overlay[hidden] { display: none; }

.overlay-card {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}
.overlay-card.wide { width: min(700px, 100%); }
.overlay-card h2 { margin: 0 0 12px; font-size: 27px; letter-spacing: -.4px; }
.overlay-card h3 { margin: 28px 0 6px; font-size: 19px; }
.overlay-card p  { margin: 0 0 20px; color: var(--text-dim); line-height: 1.5; }
.hint { font-size: 15px; }

.overlay-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 26px;
}

.btn {
  min-height: 60px;
  padding: 0 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.btn:active      { transform: scale(.97); }
.btn-primary     { background: var(--accent); border-color: var(--accent); }
.btn-ghost       { background: transparent; color: var(--text-dim); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 18px;
}
.row.stacked { flex-direction: column; align-items: stretch; gap: 12px; }
.row input[type="checkbox"] { width: 30px; height: 30px; accent-color: var(--accent); flex: 0 0 auto; }
.row input[type="range"]    { width: 100%; height: 34px; accent-color: var(--accent); }

.tile-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 4px 20px;
}
.tile-list label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  font-size: 17px;
  cursor: pointer;
}
.tile-list input { width: 26px; height: 26px; accent-color: var(--accent); }

/* ---------- phone portrait ---------- */

@media (max-width: 620px) {
  :root { --tile-min: 132px; --tile-h: 122px; --icon-size: 32px; }
  #time { font-size: 32px; }
  .status-mid { display: none; }
  .statusbar { padding: 10px 14px; gap: 10px; }
  .grid { padding: 12px 14px; gap: 10px; }
  .tile { gap: 8px; padding: 10px; }
  .tile-label { font-size: 17px; }
  .weather { display: none; }
  .dock { padding-left: 12px; padding-right: 12px; }
}

/* short landscape, i.e. a phone clipped to the vent */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --tile-h: 104px; --icon-size: 30px; }
  .tile { gap: 6px; }
  .tile-label { font-size: 17px; }
  .tile-sub { display: none; }
  #time { font-size: 28px; }
  .statusbar { padding: 8px 18px; }
  .grid { padding: 10px 18px; gap: 10px; }
  .dock-btn { min-height: 56px; }
}
