:root {
  --bg:       #F6F6F6;
  --navy:     #15293E;
  --navy-2:   #1E2A49;
  --accent:   #5F90FF;
  --accent-h: #4F78D7;
  --white:    #FFFFFF;
  --muted:    #808a90;
  --radius:   20px;
  --maxw:     3460px;   /* tuned for 3840×2160 (NearHub S Max, 16:9) */
  --ease:     cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--navy);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- MENU VIEW ---------- */
#menu {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(28px, 3.2vw, 96px) clamp(28px, 4.5vw, 150px);
  max-width: var(--maxw);
  margin: 0 auto;
  opacity: 1;
  transition: opacity .4s var(--ease);
}
#menu.hidden { opacity: 0; pointer-events: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.wordmark {
  font-weight: 800;
  font-size: clamp(20px, 1.7vw, 48px);
  letter-spacing: .1em;
  color: var(--navy);
}
.wordmark .dot { color: var(--accent); }
.kicker {
  font-weight: 600;
  font-size: clamp(11px, .95vw, 22px);
  letter-spacing: .22em;
  color: var(--muted);
  text-transform: uppercase;
}

.hero {
  flex: 0 0 auto;
  margin: clamp(20px, 2.6vw, 72px) 0 clamp(18px, 2.2vw, 54px);
}
.hero h1 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: clamp(34px, 4.8vw, 132px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.hero h1 .accent { color: var(--accent); }
.hero p {
  margin-top: clamp(12px, 1.2vw, 30px);
  font-size: clamp(14px, 1.3vw, 38px);
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- TILE GRID ---------- */
.grid {
  flex: 1 1 auto;
  display: grid;
  gap: clamp(16px, 1.6vw, 40px);
  min-height: 0;
  /* columns/rows set by JS based on how many apps are active */
}

.tile {
  position: relative;
  border: none;
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-rows: 1fr auto;
  box-shadow: 0 1px 2px rgba(23,32,57,.06), 0 8px 24px rgba(23,32,57,.05);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
  font-family: inherit;
  color: inherit;
}
.tile:hover, .tile:focus-visible {
  transform: translateY(-6px);
  box-shadow: 0 4px 10px rgba(23,32,57,.10), 0 22px 48px rgba(23,32,57,.14);
  outline: none;
}
.tile:focus-visible { box-shadow: 0 0 0 3px var(--accent), 0 22px 48px rgba(23,32,57,.14); }

/* Branded preview block (placeholder visuals) */
.preview {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: clamp(20px, 2vw, 54px);
}
.preview .mono {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: clamp(52px, 8vw, 220px);
  line-height: .8;
  letter-spacing: -.03em;
  align-self: flex-end;
}
.preview .tag {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: clamp(10px, .85vw, 22px);
  letter-spacing: .2em;
  text-transform: uppercase;
  opacity: .85;
}
/* decorative shape */
.preview::after {
  content: "";
  position: absolute;
  width: 60%; aspect-ratio: 1;
  right: -14%; top: -30%;
  border-radius: 50%;
  opacity: .18;
  transition: transform .5s var(--ease);
}
.tile:hover .preview::after { transform: scale(1.15) translate(-6%, 6%); }

/* preview with a real screenshot */
.preview.has-image {
  background-size: cover;
  background-position: center 12%;
  background-repeat: no-repeat;
}
.preview.has-image .tag {
  position: relative;
  z-index: 1;
  color: #fff;
  opacity: 1;
  background: rgba(23,32,57,.72);
  padding: .5em .85em;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
/* keep the decorative circle hidden on image tiles */
.preview.has-image::after { display: none; }
.tile:hover .preview.has-image::after { transform: none; }

/* four brand variants */
.v-navy   { background: var(--navy);  color: #fff; }
.v-navy   .mono { color: var(--accent); }

.v-accent { background: var(--accent); color: #fff; }
.v-accent .mono { color: #fff; }

.v-navy2  { background: var(--navy); color: #fff; }
.v-navy2  .mono { color: #fff; }

.v-grad   { background: linear-gradient(135deg, var(--accent) 0%, var(--navy) 100%); color:#fff; }
.v-grad   .mono { color: #fff; }

.tile .body {
  padding: clamp(16px, 1.6vw, 40px) clamp(18px, 1.8vw, 48px) clamp(18px, 1.8vw, 44px);
  display: flex;
  flex-direction: column;
  gap: clamp(6px, .5vw, 14px);
}
.tile .body h2 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: clamp(18px, 1.8vw, 46px);
  letter-spacing: -.01em;
}
.tile .body p {
  font-size: clamp(13px, 1.2vw, 27px);
  line-height: 1.45;
  color: var(--muted);
}
.launch {
  margin-top: clamp(8px, .8vw, 18px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: clamp(12px, 1vw, 24px);
  color: var(--accent);
}
.launch .arrow { transition: transform .3s var(--ease); }
.tile:hover .launch .arrow { transform: translateX(5px); }

.tile.todo { opacity: .96; }
.tile.todo .preview { outline: 2px dashed rgba(255,255,255,.35); outline-offset: -14px; }

.footnote {
  flex: 0 0 auto;
  margin-top: clamp(14px, 1.6vw, 24px);
  font-size: clamp(11px, .9vw, 13px);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.footnote .line { width: 22px; height: 1px; background: var(--accent); }

/* ---------- VIEWER ---------- */
#viewer {
  position: fixed;
  inset: 0;
  background: var(--navy);
  display: none;
  z-index: 100;
}
#viewer.active { display: flex; flex-direction: column; }

/* Top bar: keeps the controls out of the application's own UI, so nothing
   inside the iframe is covered. The iframe gets the remaining height. */
.viewerbar {
  flex: 0 0 auto;
  height: clamp(54px, 3.6vw, 88px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 1.5vw, 40px);
  padding: 0 clamp(14px, 1.2vw, 34px);
  background: var(--bg);
  border-bottom: 1px solid rgba(23,32,57,.10);
}
.viewerbar .brand {
  display: flex;
  align-items: center;
  gap: clamp(10px, .9vw, 22px);
  min-width: 0;
}
.viewerbar .wordmark {
  font-size: clamp(15px, 1.15vw, 30px);
}
.viewerbar .sep {
  flex: 0 0 auto;
  width: 1px;
  height: clamp(16px, 1.2vw, 30px);
  background: rgba(23,32,57,.20);
}
.viewerbar .apptitle {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: clamp(13px, 1vw, 25px);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
#frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--navy);
}

.controls {
  flex: 0 0 auto;
  display: flex;
  gap: clamp(8px, .7vw, 16px);
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: clamp(38px, 2.4vw, 58px);
  padding: 0 clamp(16px, 1.2vw, 28px);
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--white);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: clamp(14px, .95vw, 22px);
  cursor: pointer;
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.btn:hover { transform: translateY(-1px); background: var(--accent-h); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn.secondary {
  background: rgba(23,32,57,.08);
  color: var(--navy);
  width: clamp(38px, 2.4vw, 58px);
  padding: 0;
  justify-content: center;
}
.btn.secondary:hover { background: rgba(23,32,57,.16); }
.btn svg { display: block; width: 1.25em; height: 1.25em; }

/* loading shimmer — sits inside .stage, below the bar */
#loader {
  position: absolute; inset: 0; z-index: 1;
  display: none;
  align-items: center; justify-content: center;
  background: var(--navy); color: #fff;
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  letter-spacing: .05em;
}
#loader.show { display: flex; }
#loader .spin {
  width: 30px; height: 30px; margin-right: 14px;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: none; overflow-y: auto; }
  .tile { min-height: 240px; }
  body { overflow: auto; }
  #menu { height: auto; min-height: 100dvh; }
}

/* narrow screens: drop the app title so the buttons keep their full size */
@media (max-width: 620px) {
  .viewerbar .sep, .viewerbar .apptitle { display: none; }
}
